Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

sycl: keep cudaStreamQuery's answer in the per-layer ring waits

LocalXPUa5682fea1667
diff --git a/sycl/src/core/session.cpp b/sycl/src/core/session.cpp
index 308540493..e3bc11676 100644
--- a/sycl/src/core/session.cpp
+++ b/sycl/src/core/session.cpp
@@ -1367,7 +1367,10 @@ bool session_run_token(const ModelGeometry &g, int64_t pos, int32_t pos_base,
// A slow ring: flush the submission queue once more, and notice a fault or a finished graph.
last_flush = now;
++tg.flushes;
- const dpct::err0 q = DPCT_CHECK_ERROR((cs->ext_oneapi_empty()));
+ // SYCL port fix: cudaStreamQuery's answer (0 finished, 1 still running) was lost in the migration
+ // (DPCT_CHECK_ERROR of ext_oneapi_empty() is always 0), so ANY wait over 2 ms was reported as
+ // "graph finished". Layers whose GPU time exceeds 2 ms (host-mirrored experts read over PCIe) failed that way.
+ const dpct::err0 q = cs->ext_oneapi_empty() ? 0 : 1;
if (q != 1 && *seq < want) {
err = "session_run_token: layer " + std::to_string(l) +
" never rang (" +
diff --git a/sycl/src/core/verify.cpp b/sycl/src/core/verify.cpp
index 038f4d43a..27aa6fb40 100644
--- a/sycl/src/core/verify.cpp
+++ b/sycl/src/core/verify.cpp
@@ -1376,8 +1376,10 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,
const auto now = Clock::now();
if (now - last_flush > std::chrono::microseconds(2000)) {
last_flush = now;
- const dpct::err0 q =
- DPCT_CHECK_ERROR(((cs_)->ext_oneapi_empty()));
+ // SYCL port fix: cudaStreamQuery's answer (0 finished, 1 still running) was lost in the migration
+ // (DPCT_CHECK_ERROR of ext_oneapi_empty() is always 0), so ANY wait over 2 ms was reported as
+ // "graph finished". Layers whose GPU time exceeds 2 ms (host-mirrored experts read over PCIe) failed that way.
+ const dpct::err0 q = cs_->ext_oneapi_empty() ? 0 : 1;
if (q != 1 && *seq < want) {
trace_ev("NEVER-RANG", k, l, (int64_t) q);
trace_dump(stderr);
diff --git a/sycl/tools/fixups.py b/sycl/tools/fixups.py
index b07d6a0e8..26d942c90 100644
--- a/sycl/tools/fixups.py
+++ b/sycl/tools/fixups.py
@@ -53,6 +53,10 @@ for rel in all_sources():
edit(rel, sub(r"__nanosleep\(\d+\);", "/* spin (no __nanosleep on SYCL) */;"))
# 7. `__fadd_rn(a, b ? c : d)` lost its parentheses.
edit(rel, sub(r"= (\w+) \+ (\w+) \? (\w+\[\w+\]) : 0\.0f;", r"= \1 + (\2 ? \3 : 0.0f);"))
+ # 8. cudaStreamQuery(s): dpct writes `DPCT_CHECK_ERROR(s->ext_oneapi_empty())`, which is 0 whenever the call does not
+ # throw, so the ring waits' `q != 1` guard (1 = still running) was always true and any wait over 2 ms "never rang".
+ edit(rel, sub(r"(const dpct::err0 q =)\s*DPCT_CHECK_ERROR\(\(+(\w+)\)*->ext_oneapi_empty\(\)\)+;",
+ r"\1 \2->ext_oneapi_empty() ? 0 : 1;"))
# 2b. every `(dpct::queue_ptr) stream` cast goes through strata::q_of(), which maps CUDA's null stream to the
# default in-order queue instead of dereferencing a null sycl::queue* (include/strata/sycl_queue.hpp).