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 layer split: a REFUSED start exits cleanly, and a later stage's misses no longer read the first stage's mirror table (#1980)
Niko12211955774783e7
diff --git a/sycl/include/strata/kernels/resident_plan_mirror.hpp b/sycl/include/strata/kernels/resident_plan_mirror.hppindex b974c1a70..63cc95b86 100644--- a/sycl/include/strata/kernels/resident_plan_mirror.hpp+++ b/sycl/include/strata/kernels/resident_plan_mirror.hpp@@ -6,5 +6,10 @@ namespace strata::kernels {/// that is not in the VRAM cache but has a non-zero entry in `mirror_table` ([n_layers][n_expert] device-readable/// addresses, 0 = none) as planned: the expert kernels read it from that address, over PCIe. `d_res` is the residency/// table whose per-layer slices resident_plan receives, so the layer of a call is found from its pointer.-void resident_plan_set_mirror(const int32_t* d_res, const unsigned long long* mirror_table, int32_t* usage = nullptr);+/// `entries` (#1980): the length of `d_res`, `mirror_table` and `usage` (n_layers x n_expert). A call whose residency+/// slice lies outside `d_res` - a later layer-split stage's own table - gets no mirror and no counts (a plain miss): the+/// slice used to be taken as an offset from `d_res` anyway and read another allocation (xe page fault on the second card).+/// 0: unchecked, as before.+void resident_plan_set_mirror(const int32_t* d_res, const unsigned long long* mirror_table, int32_t* usage = nullptr,+ long long entries = 0);}diff --git a/sycl/src/kernels/cuda/verify_kernels.dp.cpp b/sycl/src/kernels/cuda/verify_kernels.dp.cppindex a268cd692..229b0f8be 100644--- a/sycl/src/kernels/cuda/verify_kernels.dp.cpp+++ b/sycl/src/kernels/cuda/verify_kernels.dp.cpp@@ -2366,8 +2366,15 @@ namespace {const int32_t* g_mirror_res = nullptr;const unsigned long long* g_mirror_table = nullptr;int32_t* g_usage = nullptr;+long long g_mirror_entries = 0; // 0: unchecked+// #1980: the layer slice `res_layer` belongs to the table the mirror was set for (a later stage passes its own)+bool in_mirror_table(const int32_t* res_layer) {+ if (g_mirror_res == nullptr || res_layer < g_mirror_res) return false;+ return g_mirror_entries <= 0 || res_layer - g_mirror_res < g_mirror_entries;}-void resident_plan_set_mirror(const int32_t* d_res, const unsigned long long* mirror_table, int32_t* usage) {+}+void resident_plan_set_mirror(const int32_t* d_res, const unsigned long long* mirror_table, int32_t* usage, long long entries) {+ g_mirror_entries = entries;g_usage = usage;g_mirror_res = d_res;g_mirror_table = mirror_table;@@ -2377,9 +2384,8 @@ void resident_plan(const int32_t* ids, int n_entries, int k, const int32_t* res_long long capx, uint32_t* skip, uint32_t ring, void* stream, uint32_t* plan_err) {const unsigned long long* mir = nullptr; // SYCL port: the layer's slice of the host-mirror table, if anyint32_t* use = nullptr; // the layer's slice of the device routing counts, if on- if (g_mirror_table != nullptr && g_mirror_res != nullptr && res_layer >= g_mirror_res)- mir = g_mirror_table + (res_layer - g_mirror_res);- if (g_usage != nullptr && g_mirror_res != nullptr && res_layer >= g_mirror_res) use = g_usage + (res_layer - g_mirror_res);+ if (g_mirror_table != nullptr && in_mirror_table(res_layer)) mir = g_mirror_table + (res_layer - g_mirror_res);+ if (g_usage != nullptr && in_mirror_table(res_layer)) use = g_usage + (res_layer - g_mirror_res);{auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};diff --git a/sycl/src/program/generate.cpp b/sycl/src/program/generate.cppindex 07852748f..933b55ca9 100644--- a/sycl/src/program/generate.cpp+++ b/sycl/src/program/generate.cpp@@ -1654,6 +1654,21 @@ static double ple_direct_rows_per_s(strata::kernels::PleTable& t) {return el > 0 ? (double) done / el : -1.0;}+// #1980: a start-up refusal ends the process here instead of returning from main. Returning ran main's destructors+// (the stages' caches, queues and Level Zero objects) in an order the UR loader did not survive: 2x Arc Pro B60, every+// REFUSED start segfaulted in libur_loader after its message, and a trimmed one also left an xe page fault (bcs CAT error)+// on the second card that hung the next start. The device work queued so far finishes first; nothing is freed.+[[noreturn]] static void refuse_exit(int code) {+ std::fflush(stdout);+ std::fflush(stderr);+ try {+ for (unsigned int d = 0; d < dpct::device_count(); ++d) dpct::get_device(d).queues_wait_and_throw();+ } catch (...) {+ }+ std::fflush(stderr);+ std::_Exit(code);+}+int main(int argc, char **argv) try {// **UNBUFFERED, BECAUSE THE INTERESTING OUTPUT IS THE OUTPUT BEFORE A CRASH.** `stdout` redirected to a// pipe or a file is block-buffered, so a program that dies loses every line it had already printed - which@@ -4932,7 +4947,7 @@ int main(int argc, char **argv) try {std::fprintf(stderr, "strata generate: REFUSED: %lld experts are neither in VRAM nor mirrored; with STRATA_VERIFY_NO_HOST ""the device plan cannot run them and generation would lack a safe host fallback - raise ""STRATA_MIRROR_MIB or the free RAM, or lower --max-context\n", (long long) unmirrored_misses);- return 2;+ refuse_exit(2);}// The same rule after the start: the mirror holds the start's misses only, so an expert an adaptive swap moves// out of VRAM would be in neither, and the device plan would wait for a host that never serves it (every token@@ -5040,7 +5055,7 @@ int main(int argc, char **argv) try {"and the card is lost at the first verify window - set STRATA_STAGE_TRIM=1 (with --layer-split N) to free ""each card's duplicate dense weights, lower --max-context or --vram-reserve-mib, or unset ""STRATA_VERIFY_NO_HOST\n", (long long) later_misses);- return 2;+ refuse_exit(2);}if (later_misses > 0)std::fprintf(stderr, "strata generate: layer split: %lld experts of the later stages are not in VRAM (served by the host)\n",@@ -7079,7 +7094,7 @@ int main(int argc, char **argv) try {usage_dev_srv = sycl::malloc_device<int32_t>((size_t) (g.n_layers * g.n_expert), dpct::get_in_order_queue());dpct::get_in_order_queue().memset(usage_dev_srv, 0, (size_t) (g.n_layers * g.n_expert) * 4).wait();}- if (mirror_table_d) strata::kernels::resident_plan_set_mirror(thits.d_res, mirror_table_d, usage_dev_srv);+ if (mirror_table_d) strata::kernels::resident_plan_set_mirror(thits.d_res, mirror_table_d, usage_dev_srv, (long long) (g.n_layers * g.n_expert));vh.h_res = host_res.empty() ? nullptr : host_res.data();vh.cache_base = thits.cache_base;vh.blob = thits.blob;@@ -12225,7 +12240,7 @@ int main(int argc, char **argv) try {usage_dev = sycl::malloc_device<int32_t>((size_t) (g.n_layers * g.n_expert), dpct::get_in_order_queue());dpct::get_in_order_queue().memset(usage_dev, 0, (size_t) (g.n_layers * g.n_expert) * 4).wait();}- if (mirror_table_d) strata::kernels::resident_plan_set_mirror(thits.d_res, mirror_table_d, usage_dev);+ if (mirror_table_d) strata::kernels::resident_plan_set_mirror(thits.d_res, mirror_table_d, usage_dev, (long long) (g.n_layers * g.n_expert));vh.h_res = host_res.empty() ? nullptr : host_res.data();vh.cache_base = thits.cache_base;vh.blob = thits.blob;