[GH-ISSUE #1555] dpct migration: \cudaStream_t ext_stream_ = nullptr\ becomes a captured queue, so a multi-device stage runs on the constructing device's queue #622

Closed
opened 2026-11-04 01:44:35 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @demetree on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1555

cudaStream_t ext_stream_ = nullptr migrated to a queue, and "no stream" became "this device's in-order queue"

Not Windows-specific: this is the dpct migration of a null-stream sentinel, and it affects any backend with more
than one device. Found by TeppeiLan1104 while testing the SYCL port (PR #1390) on two GPUs.

sycl/include/strata/core/verify.hpp:

-    cudaStream_t ext_stream_ = nullptr;
+    dpct::queue_ptr ext_stream_ = &dpct::get_in_order_queue();   // what dpct emits

The pointer form is evaluated when the Verifier is constructed, so the member initialiser captures the in-order
queue of whichever device happens to be current at that moment - not "no stream". Two places then compare against it:

-    if (ext_stream_ != nullptr) cs_ = ext_stream_;          // CUDA: null stream means "the default stream"
+    if (ext_stream_ != &dpct::get_in_order_queue()) cs_ = ext_stream_;   // sycl/src/core/verify.cpp init()

With the initialiser changed and the test unchanged, the condition is almost never true on the constructing device
(it compares a pointer to itself), so the assignment usually does not happen - but on a stage constructed on device 0
and init'ed on device 1, the in-order queue pointer differs and cs_ takes device 0's queue:

stage [17, 48):  cs_ = 0000:0d:00.0     sh_cs_ = 0000:b0:00.0     copy_ = 0000:b0:00.0

Two failures follow, depending on the shared-expert path:

  • with the 0.1.40 shared-expert fork: Cannot submit to a queue with a dependency from a graph that is associated with a different context at the first window;
  • with STRATA_SH_STREAM=0: UR_RESULT_ERROR_DEVICE_LOST.

The same initialiser also decides teardown, where if (cs_ && cs_ != ext_stream_) is the "this stream is ours to
destroy" test.

What I would change

Keep the sentinel a sentinel. nullptr means "no explicit stream", which is what the CUDA source says, and the
migration should either preserve that or rewrite every comparison site at once:

-    dpct::queue_ptr ext_stream_ = &dpct::get_in_order_queue();
+    dpct::queue_ptr ext_stream_ = nullptr;                       // nullptr = none until set_stream()
-    if (ext_stream_ != &dpct::get_in_order_queue()) cs_ = ext_stream_;
+    if (ext_stream_ != nullptr) cs_ = ext_stream_;

and the same in the destructor. I have carried this correction in the SYCL port's sycl/tools/fixups.py so a
re-migration keeps it, but the migration output itself should not emit a captured queue for a null sentinel - that
will bite the next dpct consumer the same way.

PR #1390 has the port's side with the measurements. Happy to test anything on two devices if a second one turns up.

Originally created by @demetree on GitHub (Oct 8, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1555 ### `cudaStream_t ext_stream_ = nullptr` migrated to a queue, and "no stream" became "this device's in-order queue" Not Windows-specific: this is the dpct migration of a null-stream sentinel, and it affects any backend with more than one device. Found by TeppeiLan1104 while testing the SYCL port (PR #1390) on two GPUs. `sycl/include/strata/core/verify.hpp`: ```c++ - cudaStream_t ext_stream_ = nullptr; + dpct::queue_ptr ext_stream_ = &dpct::get_in_order_queue(); // what dpct emits ``` The pointer form is evaluated **when the Verifier is constructed**, so the member initialiser captures the in-order queue of whichever device happens to be current at that moment - not "no stream". Two places then compare against it: ```c++ - if (ext_stream_ != nullptr) cs_ = ext_stream_; // CUDA: null stream means "the default stream" + if (ext_stream_ != &dpct::get_in_order_queue()) cs_ = ext_stream_; // sycl/src/core/verify.cpp init() ``` With the initialiser changed and the test unchanged, the condition is *almost never* true on the constructing device (it compares a pointer to itself), so the assignment usually does not happen - but on a stage constructed on device 0 and `init`'ed on device 1, the in-order queue pointer differs and `cs_` takes **device 0's** queue: ``` stage [17, 48): cs_ = 0000:0d:00.0 sh_cs_ = 0000:b0:00.0 copy_ = 0000:b0:00.0 ``` Two failures follow, depending on the shared-expert path: - with the 0.1.40 shared-expert fork: `Cannot submit to a queue with a dependency from a graph that is associated with a different context` at the first window; - with `STRATA_SH_STREAM=0`: `UR_RESULT_ERROR_DEVICE_LOST`. The same initialiser also decides teardown, where `if (cs_ && cs_ != ext_stream_)` is the "this stream is ours to destroy" test. ### What I would change Keep the sentinel a sentinel. `nullptr` means "no explicit stream", which is what the CUDA source says, and the migration should either preserve that or rewrite every comparison site at once: ```c++ - dpct::queue_ptr ext_stream_ = &dpct::get_in_order_queue(); + dpct::queue_ptr ext_stream_ = nullptr; // nullptr = none until set_stream() ``` ```c++ - if (ext_stream_ != &dpct::get_in_order_queue()) cs_ = ext_stream_; + if (ext_stream_ != nullptr) cs_ = ext_stream_; ``` and the same in the destructor. I have carried this correction in the SYCL port's `sycl/tools/fixups.py` so a re-migration keeps it, but the migration output itself should not emit a captured queue for a null sentinel - that will bite the next dpct consumer the same way. PR #1390 has the port's side with the measurements. Happy to test anything on two devices if a second one turns up.
Author
Owner

@tylerfloyd commented on GitHub (Oct 8, 2026):

Confirming this on 2× Arc Pro B70 (xe, kernel 7.0.0-31, compute-runtime 26.35) at d5ea713 (0.1.40.3), AOT bmg-g31, IQ3_S, --layer-split auto --stream-experts --kv int8 --kv-resident 32768 --spec 4 --mtp, ONEAPI_DEVICE_SELECTOR=level_zero:0,1.

With the #1440 item-2 fix applied locally (it is the device_free_bytes() change that went into 0.1.41), the split loads with layer split: 100% of the experts resident (layers 0-24 on card 0, 25-47 plus the head on card 1). The first request then fails exactly as described here:

strata verify: captured the 6-token window (upload no error, sync no error)
Cannot submit to a queue with a dependency from a graph that is associated with a different context.Exception caught at file:/work/Strata/sycl/src/core/verify.cpp, line:1706

One data point that may help: STRATA_VERIFY_EAGER=1 does not avoid it. Without the graph, the first request returns verify: error, then level_zero backend failed with error: 20 (UR_RESULT_ERROR_DEVICE_LOST) and the engine segfaults (exit 139). That fits cs_ holding card 0's queue for the card-1 stage, which your analysis points to, rather than anything specific to graph capture. Killing the engine while it was in that state left ccs engine resets on both cards (Fault response: Unsuccessful -EINVAL, a CAT error on card 1, Timedout job ... in strata); both cards recovered without a reboot.

A single B70 with the same build and model is stable and fast for us (IQ3_S: ~55 tok/s decode, ~566 tok/s prefill at 252K context), so we'll retest the split once this fix lands.

<!-- gh-comment-id:6061817349 --> @tylerfloyd commented on GitHub (Oct 8, 2026): Confirming this on **2× Arc Pro B70** (xe, kernel 7.0.0-31, compute-runtime 26.35) at `d5ea713` (0.1.40.3), AOT `bmg-g31`, IQ3_S, `--layer-split auto --stream-experts --kv int8 --kv-resident 32768 --spec 4 --mtp`, `ONEAPI_DEVICE_SELECTOR=level_zero:0,1`. With the #1440 item-2 fix applied locally (it is the `device_free_bytes()` change that went into 0.1.41), the split loads with `layer split: 100% of the experts resident` (layers 0-24 on card 0, 25-47 plus the head on card 1). The first request then fails exactly as described here: ``` strata verify: captured the 6-token window (upload no error, sync no error) Cannot submit to a queue with a dependency from a graph that is associated with a different context.Exception caught at file:/work/Strata/sycl/src/core/verify.cpp, line:1706 ``` One data point that may help: **`STRATA_VERIFY_EAGER=1` does not avoid it.** Without the graph, the first request returns `verify: error`, then `level_zero backend failed with error: 20 (UR_RESULT_ERROR_DEVICE_LOST)` and the engine segfaults (exit 139). That fits `cs_` holding card 0's queue for the card-1 stage, which your analysis points to, rather than anything specific to graph capture. Killing the engine while it was in that state left `ccs` engine resets on both cards (`Fault response: Unsuccessful -EINVAL`, a `CAT error` on card 1, `Timedout job ... in strata`); both cards recovered without a reboot. A single B70 with the same build and model is stable and fast for us (IQ3_S: ~55 tok/s decode, ~566 tok/s prefill at 252K context), so we'll retest the split once this fix lands.
Author
Owner

@Niko1221 commented on GitHub (Oct 10, 2026):

Fixed in v0.1.42 with PR #1589 (nekomario28): ext_stream_ is a nullptr sentinel again, so a verifier built on one device and initialised on another no longer adopts the constructing device's queue. Thank you for the precise diagnosis.

<!-- gh-comment-id:6099604547 --> @Niko1221 commented on GitHub (Oct 10, 2026): Fixed in v0.1.42 with PR #1589 (nekomario28): `ext_stream_` is a nullptr sentinel again, so a verifier built on one device and initialised on another no longer adopts the constructing device's queue. Thank you for the precise diagnosis.
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6156133843 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#622
No description provided.