#6637 [Engine] sycl inkling: honor --gpu N — the SYCL backend never read BackendOpts::gpu_index

open · @kgmkm · 0 comentários · No GitHub

Setup & installServer & APIAMD / HIPNVIDIA / CUDA

Descrição

## Problem

`strata-inkling` parses `--gpu N` into `BackendOpts::gpu_index` on every backend: the CUDA backend `cudaSetDevice()`s with it (ink_cuda_backend.cu:99-100) and HIP `hipSetDevice()`s with it (ink_hip_backend.hip.cpp:470). The SYCL backend never read the field — every start took `gpu_selector_v`'s own pick (device 0 here), and a two-Intel-GPU host had no supported way to reach the second card. The only working escape hatch was the runtime-internal `ONEAPI_DEVICE_SELECTOR`, which this SYCL runtime accepts only in the two-component form: the documented `level_zero:gpu:N` aborts with "Too many colons (:)".

## Result

`--gpu 1` now loads and serves on the second card; `--gpu 0`/unset and `--gpus 2` keep exactly today's behavior; an explicitly exported `ONEAPI_DEVICE_SELECTOR` keeps precedence; and the usage lines finally list the flag the CLI always parsed.

## Approach

`ink_sycl::apply_gpu_index(idx, gpus)` (sycl/ink_sy_common.h) sets `ONEAPI_DEVICE_SELECTOR=level_zero:<N>` before the first `Q()`/`dev_caps()` touch — the selector the engine's `Q()` already honors whenever the env is unset (it only installs its own default then). A nonzero `--gpu` pins, 0 is the "not said" default, and `--gpus 2` (dual-GPU EP) is never overridden because it needs both devices visible. `make_sycl_backend(opts)` now receives the factory's opts, so the no-model `--selfcheck` applies the same choice. The changed declaration in ink_backend.h sits under `#ifdef INKLING_ENABLE_SYCL`, so no other backend recompiles.

## Validation

**Passed** (one host: Arc B580 12 GB at `level_zero:0`, Arc Pro B70 32 GB at `level_zero:1`; oneAPI DPC++ 2026.2.0; cmake `-DSTRATA_ENABLE_SYCL=ON -DSTRATA_SYCL_TARGETS=spir64,intel_gpu_bmg_g31`, out-of-source build):

- unmodified main at `c6f6427d9`, built the same way: `--serve --native SQ-20 --gpu 1` → `dev=…B580` (the bug); no flag → B580.
- with this change: `--gpu 1` serve / `--selfcheck --native` / `--selfcheck` (no model) → the B70, every time; `--gpu 0` and no flag → B580, unchanged; `ONEAPI_DEVICE_SELECTOR=level_zero:0` together with `--gpu 1` → B580 (the explicit selector wins).
- the repo's own e2e suite against the changed binary: `STRATA_INKLING_BIN=<build>/strata-inkling python -m unittest test_inkling_e2e` (terminal/serve) — 5/5 OK, including `test_strata_inkling_binary_c1_4_8_32_64_and_vision` (needs `numpy`/`zstandard` in the venv for its tiny in-test model).

**Failed:** none on the hardware above.

**Not run:** CUDA/HIP builds (no toolchains on this machine; their `gpu_index` paths are untouched), Metal, `--gpus 2` on SYCL beyond checking the override stays off. `ink_main.cpp`'s change is the usage string only; the SYCL binary carries it here, the other backends were not rebuilt.

## Limits

0 and an explicit `--gpu 0` are indistinguishable in `BackendOpts` today (same ambiguity the CUDA path lives with), so a host whose `gpu_selector_v` picks a non-zero device keeps that pick unless the user passes a nonzero `--gpu`.

No site

Links install, modelos, releases.