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: first light - the SYCL engine generates correct text on the Arc Pro B70
maxfridbecf0e9c1e6e5c
diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txtindex 01698a51d..eda1ff0d4 100644--- a/sycl/CMakeLists.txt+++ b/sycl/CMakeLists.txt@@ -36,6 +36,9 @@ list(APPEND _sycl_link "-Xsycl-target-backend=spir64" "-cl-fp32-correctly-rounde# Every translation unit gets -fsycl: the migrated host files construct queues and USM, not only the kernels.# icpx defaults to a fast floating-point model (reciprocal approximations, reassociation); the kernels are# compared byte-for-byte against ggml's, which nvcc built value-safe, so ask for the same here.+# Every kernel was written for 32-lane warps (lane = tid & 31, warp-synchronous reductions). dpct pins the+# sub-group size only where it saw a shuffle; the rest would get Xe2's default of 16 and race. Force 32 everywhere.+list(APPEND _sycl_flags -fsycl-default-sub-group-size=32)add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${_sycl_flags}>" -fp-model=precise -Wno-unused-parameter-Wno-unused-variable -Wno-deprecated-declarations)add_link_options(${_sycl_link})@@ -141,7 +144,7 @@ target_link_libraries(strata_kernels PUBLIC strata_core)strata_resolve(_engine src/core/layer.cpp src/core/session.cpp src/core/expert_source.cpp src/core/remote_experts.cppsrc/core/expert_cache.cpp src/core/native_head.cpp src/core/native_dense.cpp src/core/verify.cppsrc/core/mtp.cpp)-add_library(strata_engine STATIC ${_engine})+add_library(strata_engine STATIC ${_engine} ${CMAKE_CURRENT_SOURCE_DIR}/src/core/gguf_expert_source.cpp)target_link_libraries(strata_engine PUBLIC strata_core strata_kernels strata_kernels_cpu)# cuBLAS -> oneMKL through dpct::blas (needs the MKL SYCL BLAS domain)@@ -172,4 +175,11 @@ if(STRATA_SYCL_PARITY)strata_resolve(_src src/kernels/qsa_prompt_attn_parity.cpp)add_executable(qsa_prompt_attn_parity ${_src})target_link_libraries(qsa_prompt_attn_parity PRIVATE strata_kernels)+ # one native expert three ways on real GGUF rows (ggml reference, CPU path, GPU native_expert_grouped):+ # native_expert_parity <shard1.gguf> [layer ...]+ if(STRATA_NATIVE_EXPERTS)+ add_executable(native_expert_parity ${CMAKE_CURRENT_SOURCE_DIR}/src/kernels/native_expert_parity.cpp)+ target_include_directories(native_expert_parity PRIVATE ${STRATA_ROOT}/third_party/ggml)+ target_link_libraries(native_expert_parity PRIVATE strata_kernels strata_kernels_cpu)+ endif()endif()diff --git a/sycl/include/strata/core/gguf_expert_source.hpp b/sycl/include/strata/core/gguf_expert_source.hppnew file mode 100644index 000000000..a08a0a21b--- /dev/null+++ b/sycl/include/strata/core/gguf_expert_source.hpp@@ -0,0 +1,52 @@+// include/strata/core/gguf_expert_source.hpp - the SYCL port: experts read from the GGUF on demand, no host arena.+//+// **WHY.** `ArenaExpertSource` keeps every expert as a resident host copy (R2.1): 23.4 GiB for the Coder, which+// the CPU pool computes misses from. On a card that holds every expert (12,288 slots on a 32 GB Arc) nothing is+// ever computed from that copy after the fill, and on a 23 GiB machine the copy cannot exist at all. This source+// gathers one blob at a time straight from the model's shard - the same three tensor slices the arena loader+// concatenates - into a small ring of staging buffers. The pointer is valid until the ring wraps, which is the+// `ExpertSource` contract ("until the next `blob()` call") with slack.+//+// It is slow per blob (three reads, ~2.7 MB) and that is fine: the profile fill reads each expert once at start,+// the prefill's lent slots are refilled a few hundred at a time, and with every expert resident the pool never+// asks. `pinned()` is false and `device_alias()` null, so nothing tries to DMA from it.+#pragma once++#include "strata/core/expert_source.hpp"++#include <cstdint>+#include <string>+#include <vector>++namespace strata::core {++class GgufExpertSource : public ExpertSource {+public:+ GgufExpertSource() = default;+ ~GgufExpertSource() override;+ GgufExpertSource(const GgufExpertSource&) = delete;+ GgufExpertSource& operator=(const GgufExpertSource&) = delete;++ /// Needs `expert_layout()` loaded from a native pack (`native_experts.txt` with the tensor offsets) and the+ /// `--native` shard. Refuses a canonical pack: that one has experts.bin and the arena is the right source.+ bool open(const std::string& shard1, int64_t n_layers, int64_t n_expert, std::string& err);+ void close();++ const uint8_t* blob(int64_t layer, int64_t expert) override;+ int64_t reads() const override { return reads_; }++private:+ int fd_of(int64_t layer, std::string& err);++ std::string shard_;+ std::string dir_;+ std::vector<int> fds_; ///< per distinct file name, opened once+ std::vector<std::string> names_;+ std::vector<int> layer_fd_; ///< per layer: index into fds_+ std::vector<std::vector<uint8_t>> ring_;+ size_t ring_next_ = 0;+ int64_t n_layers_ = 0, n_expert_ = 0;+ int64_t reads_ = 0;+};++} // namespace strata::corediff --git a/sycl/include/strata/core/verify.hpp b/sycl/include/strata/core/verify.hppindex f6f7835c7..dd90e57cf 100644--- a/sycl/include/strata/core/verify.hpp+++ b/sycl/include/strata/core/verify.hpp@@ -174,6 +174,8 @@ private:int32_t last_tokens_[8] = {};int64_t n_vocab_ = 0;dpct::queue_ptr cs_ = &dpct::get_in_order_queue();+ float* dbgR_ = nullptr; ///< SYCL port debug: R (token 0) after every layer, n_layers x n_embd+ float* dbgM_ = nullptr; ///< SYCL port debug: mixed_ (token 0) after every layerdpct::experimental::command_graph_exec_ptr exec_[9] = {};dpct::experimental::command_graph_exec_ptr commit_exec_ = nullptr;diff --git a/sycl/include/strata/sycl_doorbell.hpp b/sycl/include/strata/sycl_doorbell.hppnew file mode 100644index 000000000..1ba27301b--- /dev/null+++ b/sycl/include/strata/sycl_doorbell.hpp@@ -0,0 +1,29 @@+// include/strata/sycl_doorbell.hpp - the SYCL port: host<->device flag traffic that must bypass the GPU's caches.+//+// Strata's decode loop is a handshake through host-mapped memory: the GPU rings a sequence number the host polls,+// and a one-thread kernel spins on a flag the host writes. In CUDA those are `volatile` loads and stores, which+// nvcc turns into cache-bypassing accesses. A `volatile` in SYCL device code carries no such meaning on Intel+// GPUs: the spin read its first value from L3 forever (measured: the GPU at 100% and the host seeing no ring).+// Atomic loads and stores with system scope are the accesses that go to memory, so every side of the handshake+// goes through these two.+#pragma once+#include <sycl/sycl.hpp>+#include <cstdint>++namespace strata {+using sys_atomic_u32 = sycl::atomic_ref<uint32_t, sycl::memory_order::relaxed, sycl::memory_scope::system>;++inline uint32_t sys_load(const volatile uint32_t* p) {+ return sys_atomic_u32(*const_cast<uint32_t*>(p)).load();+}+inline void sys_store(volatile uint32_t* p, uint32_t v) {+ sys_atomic_u32(*const_cast<uint32_t*>(p)).store(v);+ sycl::atomic_fence(sycl::memory_order::release, sycl::memory_scope::system);+}++// Every device spin is bounded. An unbounded spin that never sees its flag is not a hang of one process: the+// xe driver times the queue out, resets the GT node by node (a window graph has 2,366 of them), and the card+// stays wedged until a reboot - measured twice. With a bound the failure is a wrong window instead, which the+// verifier's checks catch. ~2 M host-memory reads is a few seconds at PCIe latency.+inline constexpr uint32_t kSpinMax = 2u * 1000u * 1000u;+} // namespace stratadiff --git a/sycl/src/core/concurrent_main.cpp b/sycl/src/core/concurrent_main.cppindex 845615e54..599e98be1 100644--- a/sycl/src/core/concurrent_main.cpp+++ b/sycl/src/core/concurrent_main.cpp@@ -117,7 +117,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, hx.data(), hx.size() * sizeof(uint16_t))),+ d_x, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"copy x");/*DPCT1114:923: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -126,7 +126,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, hs.data(), hs.size() * sizeof(float))),+ d_scales, hs.data(), hs.size() * sizeof(float)).wait()),"copy scales");dpct::queue_ptr s_copy{}, s_comp{};check(DPCT_CHECK_ERROR(s_copy =diff --git a/sycl/src/core/expert_cache.cpp b/sycl/src/core/expert_cache.cppindex c6a4ca9f4..752bebab2 100644--- a/sycl/src/core/expert_cache.cpp+++ b/sycl/src/core/expert_cache.cpp@@ -316,7 +316,7 @@ bool ExpertCache::fill_slot_blocking(int32_t slot, const uint8_t *host_blob,synchronization behavior.*/const dpct::err0 e =- DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(dst, host_blob, n));+ DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(dst, host_blob, n).wait());/*DPCT1000:767: Error handling if-stmt was detected but could not berewritten.@@ -359,7 +359,7 @@ bool ExpertCache::fill_slot_queued(int32_t slot, const uint8_t *host_blob,ensure synchronization behavior.*/const dpct::err0 e =- DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(dst, host_blob, n));+ DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(dst, host_blob, n).wait());/*DPCT1000:771: Error handling if-stmt was detected but could not berewritten.diff --git a/sycl/src/core/gguf_expert_source.cpp b/sycl/src/core/gguf_expert_source.cppnew file mode 100644index 000000000..ae0595874--- /dev/null+++ b/sycl/src/core/gguf_expert_source.cpp@@ -0,0 +1,88 @@+// src/core/gguf_expert_source.cpp - see the header. Plain C++, no device code.+#include "strata/core/gguf_expert_source.hpp"+#include "strata/kernels/cpu/expert_layout.hpp"++#include <cstring>+#include <fcntl.h>+#include <unistd.h>++namespace strata::core {++namespace {+constexpr size_t kRing = 8; // blobs alive at once: the fill holds one, verify_slot a second; the rest is slack+}++GgufExpertSource::~GgufExpertSource() { close(); }++void GgufExpertSource::close() {+ for (int fd : fds_) if (fd >= 0) ::close(fd);+ fds_.clear(); names_.clear(); layer_fd_.clear(); ring_.clear();+ ring_next_ = 0;+}++bool GgufExpertSource::open(const std::string& shard1, int64_t n_layers, int64_t n_expert, std::string& err) {+ close();+ const auto& lay = strata::kernels::cpu::expert_layout();+ if (!lay.native || lay.gguf_off.size() < (size_t) (3 * n_layers)) {+ err = "--stream-experts needs a native (IQ) pack whose native_experts.txt carries the GGUF tensor offsets";+ return false;+ }+ for (int64_t l = 0; l < n_layers; ++l)+ for (int r = 0; r < 3; ++r)+ if (lay.gguf_off[(size_t) (3 * l + r)] == 0) {+ err = "--stream-experts: layer " + std::to_string(l) + " has no GGUF offset for its experts";+ return false;+ }+ shard_ = shard1;+ const size_t cut = shard1.find_last_of("/\\");+ dir_ = cut == std::string::npos ? std::string() : shard1.substr(0, cut + 1);+ n_layers_ = n_layers;+ n_expert_ = n_expert;+ layer_fd_.assign((size_t) n_layers, -1);+ for (int64_t l = 0; l < n_layers; ++l)+ if (fd_of(l, err) < 0) { close(); return false; }+ ring_.resize(kRing);+ for (auto& b : ring_) b.resize((size_t) lay.max_blob);+ return true;+}++int GgufExpertSource::fd_of(int64_t layer, std::string& err) {+ if (layer_fd_[(size_t) layer] >= 0) return fds_[(size_t) layer_fd_[(size_t) layer]];+ const auto& lay = strata::kernels::cpu::expert_layout();+ std::string name = shard_;+ if (!lay.gguf_file.empty() && !lay.gguf_file[(size_t) layer].empty()) name = dir_ + lay.gguf_file[(size_t) layer];+ for (size_t i = 0; i < names_.size(); ++i)+ if (names_[i] == name) { layer_fd_[(size_t) layer] = (int) i; return fds_[i]; }+ const int fd = ::open(name.c_str(), O_RDONLY | O_CLOEXEC);+ if (fd < 0) { err = "--stream-experts: cannot open " + name; return -1; }+ names_.push_back(name);+ fds_.push_back(fd);+ layer_fd_[(size_t) layer] = (int) fds_.size() - 1;+ return fd;+}++const uint8_t* GgufExpertSource::blob(int64_t layer, int64_t expert) {+ if (layer < 0 || layer >= n_layers_ || expert < 0 || expert >= n_expert_ || ring_.empty()) return nullptr;+ const auto& lay = strata::kernels::cpu::expert_layout();+ const auto& fm = lay.fmt[(size_t) layer];+ const uint64_t blob = lay.bytes[(size_t) layer];+ // the arena loader's gather, for one expert: [gate | up | down] from the three tensors+ const uint64_t per[3] = {fm.up_off, fm.up_off, blob - fm.down_off};+ const uint64_t at[3] = {0, fm.up_off, fm.down_off};+ const int fd = fds_[(size_t) layer_fd_[(size_t) layer]];+ std::vector<uint8_t>& buf = ring_[ring_next_];+ ring_next_ = (ring_next_ + 1) % ring_.size();+ for (int r = 0; r < 3; ++r) {+ const uint64_t src = lay.gguf_off[(size_t) (3 * layer + r)] + per[r] * (uint64_t) expert;+ uint64_t done = 0;+ while (done < per[r]) {+ const ssize_t n = ::pread(fd, buf.data() + at[r] + done, (size_t) (per[r] - done), (off_t) (src + done));+ if (n <= 0) return nullptr;+ done += (uint64_t) n;+ }+ }+ ++reads_;+ return buf.data();+}++} // namespace strata::corediff --git a/sycl/src/core/mtp.cpp b/sycl/src/core/mtp.cppindex 8c90e6c30..ec52da5b0 100644--- a/sycl/src/core/mtp.cpp+++ b/sycl/src/core/mtp.cpp@@ -212,7 +212,7 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,memory is not pageable, call wait() on event return by memcpy API toensure synchronization behavior.*/- dpct::get_in_order_queue().memcpy(dense_, blob.data(), blob.size());+ dpct::get_in_order_queue().memcpy(dense_, blob.data(), blob.size()).wait();vram_ += blob.size();}// ---- the 512 routed experts, one blob each@@ -342,7 +342,7 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,memory is not pageable, call wait() on event return by memcpy API toensure synchronization behavior.*/- dpct::get_in_order_queue().memcpy(ident_, id.data(), id.size() * 4);+ dpct::get_in_order_queue().memcpy(ident_, id.data(), id.size() * 4).wait();}/*DPCT1025:16: The SYCL queue is created ignoring the flag and priority@@ -981,7 +981,7 @@ bool MtpDrafter::draft_first(int T, const float *R_row, int32_t token,for (int t = 0; t < T; ++t)if (DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy((void *)(window_R_ + (size_t)t * HCN), R_row,- (size_t)HCN * sizeof(float))) != 0) {+ (size_t)HCN * sizeof(float)).wait()) != 0) {err = "mtp: staging the first residual failed";return false;}diff --git a/sycl/src/core/overlap_main.cpp b/sycl/src/core/overlap_main.cppindex c49f1a659..3297a2e5f 100644--- a/sycl/src/core/overlap_main.cpp+++ b/sycl/src/core/overlap_main.cpp@@ -110,7 +110,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, hx.data(), hx.size() * sizeof(uint16_t))),+ d_x, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"copy x");/*DPCT1114:658: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -119,7 +119,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, hs.data(), hs.size() * sizeof(float))),+ d_scales, hs.data(), hs.size() * sizeof(float)).wait()),"copy scales");dpct::queue_ptr s_copy{}, s_comp{};@@ -149,7 +149,7 @@ int main(int argc, char** argv) {*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_codes[0], arena.data() + (uint64_t)i * role_codes,- role_codes)),+ role_codes).wait()),"serial copy");strata::kernels::s_gemv_split_async(d_x, d_codes[0], d_scales, nullptr, d_y, n_in, n_out, form,diff --git a/sycl/src/core/verify.cpp b/sycl/src/core/verify.cppindex 05b753ed9..8d3856a9d 100644--- a/sycl/src/core/verify.cpp+++ b/sycl/src/core/verify.cpp@@ -354,6 +354,10 @@ bool Verifier::init(const WeightTable &wt, const ModelGeometry &g,*/if (!ok2) {; device_plan_ = false; }}+ if (std::getenv("STRATA_VERIFY_DEBUG") != nullptr) { // SYCL port: the per-layer residual ladder (token 0)+ dbgR_ = (float*) sycl::malloc_device((size_t) g.n_layers * g.n_embd * 4, dpct::get_in_order_queue());+ dbgM_ = (float*) sycl::malloc_device((size_t) g.n_layers * g.n_embd * 4, dpct::get_in_order_queue());+ }std::fprintf(stderr, "strata verify: window up to %d tokens, %.1f MiB of device buffers\n", max_t,(double) count.used / 1048576.0);return true;@@ -813,6 +817,10 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {for (int64_t l = lb_; l < le_; ++l)for (int grp = 0; grp < G; ++grp) {if (!post(l, grp)) return false;+ if (dbgR_ && grp == 0) { // recorded into the window graph as memcpy nodes+ cs->memcpy(dbgR_ + (size_t) l * N, Rt(0), (size_t) N * 4);+ cs->memcpy(dbgM_ + (size_t) l * N, mixed_, (size_t) N * 4);+ }if (l + 1 < le_ && !pre(l + 1, grp)) return false;}if (le_ < g.n_layers) { // a layer split's earlier stage: hand the residual on, no head@@ -1133,7 +1141,13 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,volatile uint32_t* const flag = h_flag_;const int G = groups_[T] > 0 ? groups_[T] : 1;const int gtb[2] = {0, (T + 1) / 2}, gte[2] = {G == 2 ? (T + 1) / 2 : T, T};- for (int64_t k = 0; k < (le_ - lb_) * G; ++k) {+ // SYCL port: with every routed expert resident the GPU takes its own plan (`device_plan_`) and skips every+ // host flag, so the host has nothing to do per layer - and on this platform a kernel's writes to host-mapped+ // memory are not reliably visible while the graph runs (measured: the ring is seen late or not at all),+ // so waiting on them per layer fails. STRATA_VERIFY_NO_HOST=1 waits for the whole window instead. Only for+ // an all-resident cache: a missed expert would leave the GPU waiting for a plan that never comes.+ static const bool no_host = std::getenv("STRATA_VERIFY_NO_HOST") != nullptr;+ for (int64_t k = 0; !no_host && k < (le_ - lb_) * G; ++k) {const int64_t l = lb_ + k / G;const int grp = (int) (k % G);const uint32_t want = (uint32_t) (k + 1);@@ -1211,6 +1225,64 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,err = std::string("verify: ") + dpct::get_error_string_dummy(se);return false;}+ if (no_host && std::getenv("STRATA_VERIFY_DEBUG") != nullptr) { // SYCL port: what the window left behind+ const int Gd = groups_[T] > 0 ? groups_[T] : 1;+ std::vector<uint32_t> sk((size_t) Gd, 0);+ std::vector<int32_t> id0((size_t) ss.k, 0);+ std::vector<int32_t> res0((size_t) 16, 0);+ cs_->memcpy(sk.data(), skip_, sk.size() * 4).wait();+ cs_->memcpy(id0.data(), ids_, id0.size() * 4).wait();+ cs_->memcpy(res0.data(), hits_.d_res, res0.size() * 4).wait();+ std::fprintf(stderr, "verify dbg: window T=%d: host seq=%u (expected %lld), skip[]=", T, *(volatile uint32_t*) h_seq_,+ (long long) ((le_ - lb_) * Gd));+ for (int i = 0; i < Gd; ++i) std::fprintf(stderr, " %u", sk[(size_t) i]);+ std::vector<float> w0((size_t) ss.k, 0.f);+ cs_->memcpy(w0.data(), w_, w0.size() * 4).wait();+ std::fprintf(stderr, "; layer-0 weights:");+ for (size_t i = 0; i < w0.size(); ++i) std::fprintf(stderr, " %.3g", w0[i]);+ std::fprintf(stderr, "; layer-0 ids:");+ for (size_t i = 0; i < id0.size(); ++i) std::fprintf(stderr, " %d", id0[i]);+ std::fprintf(stderr, "; d_res[0..15]:");+ for (size_t i = 0; i < res0.size(); ++i) std::fprintf(stderr, " %d", res0[i]);+ std::fprintf(stderr, "; out[0..3]: %d %d %d %d\n", ((volatile int32_t*) h_out_)[0], ((volatile int32_t*) h_out_)[1],+ ((volatile int32_t*) h_out_)[2], ((volatile int32_t*) h_out_)[3]);+ auto stat = [&](const char* what, const float* dev, size_t n) { // token 0's vector: where do the zeros begin?+ std::vector<float> v(n, 0.f);+ cs_->memcpy(v.data(), dev, n * 4).wait();+ double sum = 0, mx = 0; size_t nonfinite = 0;+ for (float x : v) { if (!std::isfinite(x)) { ++nonfinite; continue; } sum += std::fabs(x); mx = std::max(mx, (double) std::fabs(x)); }+ std::fprintf(stderr, "verify dbg: %-8s n=%zu mean|.|=%.4g max|.|=%.4g nonfinite=%zu first4=%g %g %g %g\n", what, n,+ sum / (double) n, mx, nonfinite, v[0], v[1], v[2], v[3]);+ };+ if (dbgR_) {+ const size_t N = (size_t) g.n_embd;+ std::vector<float> r((size_t) g.n_layers * N), m((size_t) g.n_layers * N);+ cs_->memcpy(r.data(), dbgR_, r.size() * 4).wait();+ cs_->memcpy(m.data(), dbgM_, m.size() * 4).wait();+ for (int64_t l = 0; l < g.n_layers; ++l) {+ double sr = 0, sm = 0; size_t nr = 0, nm = 0;+ for (size_t i = 0; i < N; ++i) {+ const float x = r[(size_t) l * N + i], y = m[(size_t) l * N + i];+ if (std::isfinite(x)) sr += std::fabs(x); else ++nr;+ if (std::isfinite(y)) sm += std::fabs(y); else ++nm;+ }+ std::fprintf(stderr, "verify dbg: layer %2lld %s R mean|.|=%.4g nonfinite=%zu mixed mean|.|=%.4g nonfinite=%zu\n",+ (long long) l, is_qsa_layer(g, l) ? "QSA" : "GDN", sr / N, nr, sm / N, nm);+ }+ }+ { // the device plan of the last layer group and the MoE parts it produced (token 0)+ std::vector<int32_t> pc(4, 0);+ cs_->memcpy(pc.data(), plan_, 16).wait();+ std::fprintf(stderr, "verify dbg: plan (last layer, grp 0): groups=%d entries=%d pcie=%d\n", pc[0], pc[1], pc[2]);+ }+ stat("parts_", parts_, (size_t) ss.k * g.n_embd);+ stat("hit_out_", hit_out_, (size_t) ss.k * g.n_embd);+ stat("shared_", shared_, (size_t) g.n_embd);+ stat("emb_", emb_, (size_t) g.n_embd);+ stat("ple_", ple_, (size_t) g.n_embd);+ stat("R_", R_, (size_t) g.n_embd);+ stat("mixed_", mixed_, (size_t) g.n_embd);+ }progress_at("verify window: waiting for the expert copies", (int64_t) T);copy_->wait(); // no host function of this window may raise flag B in the// next onediff --git a/sycl/src/core/weights.cpp b/sycl/src/core/weights.cppindex 3ab7f2fee..e4119797b 100644--- a/sycl/src/core/weights.cpp+++ b/sycl/src/core/weights.cpp@@ -437,7 +437,7 @@ bool WeightTable::load(const std::string &pack_dir, void *arena_base,event return by memcpy API to ensure synchronization behavior.*/if (DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- dst_base + r.dst_off + out_at, host_src, out_bytes)) !=+ dst_base + r.dst_off + out_at, host_src, out_bytes).wait()) !=0) {err = "cudaMemcpy failed for " + r.name;sycl::free(stage_in, dpct::get_in_order_queue());diff --git a/sycl/src/kernels/bf16_gemv_parity.cpp b/sycl/src/kernels/bf16_gemv_parity.cppindex b01f3bed2..18c579345 100644--- a/sycl/src/kernels/bf16_gemv_parity.cpp+++ b/sycl/src/kernels/bf16_gemv_parity.cpp@@ -109,7 +109,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_x, x.data(),- x.size() * 2)),+ x.size() * 2).wait()),"cx");/*DPCT1114:1142: cudaMemcpy is migrated to asynchronization memcpy,@@ -118,7 +118,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_w, w.data(),- w.size() * 2)),+ w.size() * 2).wait()),"cw");std::vector<float> naive((size_t) s.n_out), warp((size_t) s.n_out), split((size_t) s.n_out);@@ -164,7 +164,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * 2)),+ d_x, x.data(), x.size() * 2).wait()),"cx2");std::vector<float> rival((size_t) s.n_out);strata::kernels::bf16_gemv(d_x, d_w, d_y, s.n_in, s.n_out, nullptr);diff --git a/sycl/src/kernels/cuda/cvec.dp.cpp b/sycl/src/kernels/cuda/cvec.dp.cppindex 346f0e78f..246fe5ca3 100644--- a/sycl/src/kernels/cuda/cvec.dp.cpp+++ b/sycl/src/kernels/cuda/cvec.dp.cpp@@ -50,7 +50,7 @@ bool upload_here(std::string &err) try {to ensure synchronization behavior.*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- t.dir, g_dir_host.data(), g_dir_host.size() * sizeof(float))) !=+ t.dir, g_dir_host.data(), g_dir_host.size() * sizeof(float)).wait()) !=0 ||/*DPCT1114:508: cudaMemcpy is migrated to asynchronization memcpy,@@ -59,7 +59,7 @@ bool upload_here(std::string &err) try {to ensure synchronization behavior.*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- t.s, g_s_host.data(), g_s_host.size() * sizeof(float))) != 0 ||+ t.s, g_s_host.data(), g_s_host.size() * sizeof(float)).wait()) != 0 ||DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(t.on, &flag, sizeof(int)).wait()) != 0) {diff --git a/sycl/src/kernels/cuda/elementwise.dp.cpp b/sycl/src/kernels/cuda/elementwise.dp.cppindex 6cc4f4901..377de2cbf 100644--- a/sycl/src/kernels/cuda/elementwise.dp.cpp+++ b/sycl/src/kernels/cuda/elementwise.dp.cpp@@ -3,6 +3,7 @@#include <sycl/sycl.hpp>#include <dpct/dpct.hpp>#include "strata/sycl_queue.hpp"+#include "strata/sycl_doorbell.hpp"#include "strata/kernels/elementwise.hpp"#include "strata/kernels/bf16_bits.hpp"@@ -369,18 +370,18 @@ __dpct_inline__ void doorbell_ring_kernel(uint32_t *seq) {are needed.*/sycl::atomic_fence(sycl::memory_order::acq_rel, sycl::memory_scope::system);- *seq = *seq + 1u;+ strata::sys_store(seq, strata::sys_load(seq) + 1u);}__dpct_inline__ void doorbell_wait_kernel(const volatile uint32_t *flag,const volatile uint32_t *seq) {- const uint32_t want = *seq;+ const uint32_t want = strata::sys_load(seq);/*DPCT1008:1061: __nanosleep function is not defined in SYCL. This is ahardware-specific feature. Consult with your hardware vendor to find areplacement.*/- while (*flag != want) /* spin (no __nanosleep on SYCL) */;+ for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) != want; ++spin) {}/*DPCT1078:278: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictions@@ -555,7 +556,7 @@ __dpct_inline__ void doorbell_publish_kernel(const float *__restrict__ x,*/sycl::atomic_fence(sycl::memory_order::acq_rel,sycl::memory_scope::system);- *(volatile uint32_t*) seq = *(volatile uint32_t*) seq + 1u;+ strata::sys_store(seq, strata::sys_load(seq) + 1u);}}diff --git a/sycl/src/kernels/cuda/qsa.dp.cpp b/sycl/src/kernels/cuda/qsa.dp.cppindex 87641aa06..767417f35 100644--- a/sycl/src/kernels/cuda/qsa.dp.cpp+++ b/sycl/src/kernels/cuda/qsa.dp.cpp@@ -805,7 +805,7 @@ void step_upload_raw(const int32_t *h_step) try {synchronization behavior.*/if (DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d, h_step, qsa_step_bytes())) != 0) {+ d, h_step, qsa_step_bytes()).wait()) != 0) {std::fprintf(stderr, "qsa: step upload: cudaMemcpy failed\n");std::exit(1);}diff --git a/sycl/src/kernels/cuda/verify_kernels.dp.cpp b/sycl/src/kernels/cuda/verify_kernels.dp.cppindex a71a7eaca..bdc700906 100644--- a/sycl/src/kernels/cuda/verify_kernels.dp.cpp+++ b/sycl/src/kernels/cuda/verify_kernels.dp.cpp@@ -6,6 +6,7 @@#include <sycl/sycl.hpp>#include <dpct/dpct.hpp>#include "strata/sycl_queue.hpp"+#include "strata/sycl_doorbell.hpp"#include "strata/kernels/verify_kernels.hpp"#include <cstdio>@@ -911,7 +912,7 @@ __dpct_inline__ void wait_flag_ge_kernel(const volatile uint32_t *flag,hardware-specific feature. Consult with your hardware vendor to find areplacement.*/- while (*flag < value) /* spin (no __nanosleep on SYCL) */;+ for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) < value; ++spin) {}/*DPCT1078:199: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictions@@ -971,18 +972,18 @@ __dpct_inline__ void resident_plan_kernel(are needed.*/sycl::atomic_fence(sycl::memory_order::acq_rel, sycl::memory_scope::device);- *skip = ring;+ strata::sys_store(skip, ring);}__dpct_inline__ void wait_flag_ge_or_kernel(const volatile uint32_t *flag,uint32_t value,const volatile uint32_t *skip) {- if (*skip == value) return;+ if (strata::sys_load(skip) == value) return;/*DPCT1008:884: __nanosleep function is not defined in SYCL. This is ahardware-specific feature. Consult with your hardware vendor to find areplacement.*/- while (*flag < value) /* spin (no __nanosleep on SYCL) */;+ for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) < value; ++spin) {}/*DPCT1078:201: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictions@@ -995,7 +996,7 @@ __dpct_inline__ void copy_i32_unless_kernel(int32_t *__restrict__ dst,const uint32_t *skip,uint32_t value) {auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();- if (*skip == value) return;+ if (strata::sys_load(skip) == value) return;#pragma unrollfor (int i = item_ct1.get_local_id(2); i < n;i += item_ct1.get_local_range(2)) dst[i] = src[i];diff --git a/sycl/src/kernels/cvec_parity.cpp b/sycl/src/kernels/cvec_parity.cppindex 856f1d80a..239a1a353 100644--- a/sycl/src/kernels/cvec_parity.cpp+++ b/sycl/src/kernels/cvec_parity.cpp@@ -45,7 +45,7 @@ behavior.*/void up(T *d, const std::vector<T> &h) {ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d, h.data(), h.size() * sizeof(T))),+ d, h.data(), h.size() * sizeof(T)).wait()),"up");}template <typename T>diff --git a/sycl/src/kernels/dequant_bf16_test.cpp b/sycl/src/kernels/dequant_bf16_test.cppindex a84bc9da3..7e100c315 100644--- a/sycl/src/kernels/dequant_bf16_test.cpp+++ b/sycl/src/kernels/dequant_bf16_test.cpp@@ -81,7 +81,7 @@ int main(int argc, char** argv) {strata::kernels::dequant_bf16(type, d_blocks, 0, rows, cols, d_h, nullptr);std::vector<float> gf((size_t) (rows * cols));std::vector<uint16_t> gh((size_t) (rows * cols));- dpct::get_in_order_queue().memcpy(gf.data(), d_f, gf.size() * 4);+ dpct::get_in_order_queue().memcpy(gf.data(), d_f, gf.size() * 4).wait();dpct::get_in_order_queue().memcpy(gh.data(), d_h, gh.size() * 2).wait();diff --git a/sycl/src/kernels/dequant_s2_parity.cpp b/sycl/src/kernels/dequant_s2_parity.cppindex b5984e0bb..a1f6680ea 100644--- a/sycl/src/kernels/dequant_s2_parity.cpp+++ b/sycl/src/kernels/dequant_s2_parity.cpp@@ -93,7 +93,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"copy codes");/*DPCT1114:371: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -102,7 +102,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * sizeof(float))),+ d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"copy scales");strata::kernels::dequant_s2(d_codes, d_scales, d_out, n_blocks);diff --git a/sycl/src/kernels/elementwise_parity.cpp b/sycl/src/kernels/elementwise_parity.cppindex 5d61559ff..dc086e62d 100644--- a/sycl/src/kernels/elementwise_parity.cpp+++ b/sycl/src/kernels/elementwise_parity.cpp@@ -114,7 +114,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_a, alpha.data(), n * 4)),+ dpct::get_in_order_queue().memcpy(d_a, alpha.data(), n * 4).wait()),"ca");/*DPCT1114:713: cudaMemcpy is migrated to asynchronization memcpy,@@ -123,7 +123,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_dt, dt.data(), n * 4)),+ dpct::get_in_order_queue().memcpy(d_dt, dt.data(), n * 4).wait()),"cd");/*DPCT1114:714: cudaMemcpy is migrated to asynchronization memcpy,@@ -132,7 +132,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_sa, a.data(), n * 4)),+ dpct::get_in_order_queue().memcpy(d_sa, a.data(), n * 4).wait()),"cs");strata::kernels::gdn_gate(d_a, d_dt, d_sa, d_g, 1, H_V, nullptr);std::vector<float> got((size_t) n);@@ -211,7 +211,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_x, x.data(), n * 4)),+ dpct::get_in_order_queue().memcpy(d_x, x.data(), n * 4).wait()),"csx");strata::kernels::silu_inplace(d_x, n, nullptr);std::vector<float> got((size_t) n);@@ -248,7 +248,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_x, x.data(), n * 4)),+ dpct::get_in_order_queue().memcpy(d_x, x.data(), n * 4).wait()),"cex");strata::kernels::scale_inplace(d_x, n, s, nullptr);std::vector<float> got((size_t) n);@@ -344,7 +344,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_x, x.data(),- x.size() * 4)),+ x.size() * 4).wait()),"c rmsx");/*DPCT1114:718: cudaMemcpy is migrated to asynchronization memcpy,@@ -353,7 +353,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_w, w.data(),- w.size() * 4)),+ w.size() * 4).wait()),"c rmsw");strata::kernels::rms_norm_weighted(d_x, d_w, rows, cols, eps, nullptr);std::vector<float> got((size_t) (rows * cols));@@ -392,7 +392,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_x, x.data(),- x.size() * 4)),+ x.size() * 4).wait()),"c rmsx2");strata::kernels::rms_norm_weighted(d_x, nullptr, rows, cols, eps, nullptr);check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()diff --git a/sycl/src/kernels/gdn_parity.cpp b/sycl/src/kernels/gdn_parity.cppindex 06e15a0dd..5df2e2816 100644--- a/sycl/src/kernels/gdn_parity.cpp+++ b/sycl/src/kernels/gdn_parity.cpp@@ -189,7 +189,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_st, st_dev.data(), st_dev.size() * 4)),+ d_st, st_dev.data(), st_dev.size() * 4).wait()),"cst");/*DPCT1114:487: cudaMemcpy is migrated to asynchronization memcpy,@@ -198,7 +198,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_q, q.data(),- q.size() * 4)),+ q.size() * 4).wait()),"cq");/*DPCT1114:488: cudaMemcpy is migrated to asynchronization memcpy,@@ -207,7 +207,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_k, k.data(),- k.size() * 4)),+ k.size() * 4).wait()),"ck");/*DPCT1114:489: cudaMemcpy is migrated to asynchronization memcpy,@@ -216,7 +216,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_v, v.data(),- v.size() * 4)),+ v.size() * 4).wait()),"cv");/*DPCT1114:490: cudaMemcpy is migrated to asynchronization memcpy,@@ -225,7 +225,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_g, gate.data(), gate.size() * 4)),+ d_g, gate.data(), gate.size() * 4).wait()),"cg");/*DPCT1114:491: cudaMemcpy is migrated to asynchronization memcpy,@@ -234,7 +234,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_b, beta.data(), beta.size() * 4)),+ d_b, beta.data(), beta.size() * 4).wait()),"cb");strata::kernels::GdnShapes sh{S, h_k, h_v};@@ -281,7 +281,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_st, zero.data(), zero.size() * 4)),+ d_st, zero.data(), zero.size() * 4).wait()),"z0");/*DPCT1114:493: cudaMemcpy is migrated to asynchronization memcpy,@@ -290,7 +290,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_g, zg.data(), zg.size() * 4)),+ d_g, zg.data(), zg.size() * 4).wait()),"z1");/*DPCT1114:494: cudaMemcpy is migrated to asynchronization memcpy,@@ -299,7 +299,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_b, zb.data(), zb.size() * 4)),+ d_b, zb.data(), zb.size() * 4).wait()),"z2");strata::kernels::gdn_step(d_st, d_q, d_k, d_v, d_g, d_b, d_o, sh, nullptr);std::vector<float> zz(zero.size());@@ -402,7 +402,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_cs, cs.data(), cs.size() * 4)),+ d_cs, cs.data(), cs.size() * 4).wait()),"ccs");/*DPCT1114:496: cudaMemcpy is migrated to asynchronization memcpy,@@ -411,7 +411,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_x, x.data(),- x.size() * 4)),+ x.size() * 4).wait()),"ccx");/*DPCT1114:497: cudaMemcpy is migrated to asynchronization memcpy,@@ -420,7 +420,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_w, kW.data(), kW.size() * 4)),+ d_w, kW.data(), kW.size() * 4).wait()),"ccw");strata::kernels::gdn_conv_step(d_cs, d_x, d_w, d_o, C, dc, nullptr);std::vector<float> got((size_t) C), got_cs(cs.size());@@ -484,7 +484,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_x, x.data(),- x.size() * 4)),+ x.size() * 4).wait()),"lcx");strata::kernels::gdn_l2_norm(d_x, rows, cols, eps, nullptr);std::vector<float> got(x.size());@@ -535,7 +535,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_o, o.data(),- o.size() * 4)),+ o.size() * 4).wait()),"nco");/*DPCT1114:500: cudaMemcpy is migrated to asynchronization memcpy,@@ -544,7 +544,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_z, z.data(),- z.size() * 4)),+ z.size() * 4).wait()),"ncz");/*DPCT1114:501: cudaMemcpy is migrated to asynchronization memcpy,@@ -553,7 +553,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_sn, sn.data(), sn.size() * 4)),+ d_sn, sn.data(), sn.size() * 4).wait()),"ncs");strata::kernels::gdn_out_norm(d_o, d_z, d_sn, d_y, hv2, S2, eps, nullptr);std::vector<float> got(y_ref.size());diff --git a/sycl/src/kernels/gr_parity.cpp b/sycl/src/kernels/gr_parity.cppindex 742fdae71..86f6900c7 100644--- a/sycl/src/kernels/gr_parity.cpp+++ b/sycl/src/kernels/gr_parity.cpp@@ -202,7 +202,7 @@ int scalar_activation_contract() {synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_R, ones, sizeof(ones))),+ dpct::get_in_order_queue().memcpy(d_R, ones, sizeof(ones)).wait()),"scalar upload R");/*DPCT1114:967: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -211,7 +211,7 @@ int scalar_activation_contract() {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_weights, weights,- sizeof(weights))),+ sizeof(weights)).wait()),"scalar upload weights");dpct::queue_ptr stream;/*@@ -231,7 +231,7 @@ int scalar_activation_contract() {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_norm, gammas, sizeof(gammas))),+ d_norm, gammas, sizeof(gammas)).wait()),"scalar upload norm");float mixed_by_mode[3][2] = {}, inject_by_mode[3] = {};for (int mode = 0; mode < 3; ++mode) {@@ -428,7 +428,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_R, R.data(), R.size() * sizeof(float))),+ d_R, R.data(), R.size() * sizeof(float)).wait()),"c R");/*DPCT1114:971: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -437,7 +437,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_norm, w_norm.data(), w_norm.size() * sizeof(float))),+ d_norm, w_norm.data(), w_norm.size() * sizeof(float)).wait()),"c norm");/*DPCT1114:972: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -446,7 +446,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_down, q_down.data(), q_down.size() * sizeof(uint16_t))),+ d_down, q_down.data(), q_down.size() * sizeof(uint16_t)).wait()),"c down");/*DPCT1114:973: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -455,7 +455,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_up, q_up.data(), q_up.size() * sizeof(uint16_t))),+ d_up, q_up.data(), q_up.size() * sizeof(uint16_t)).wait()),"c up");/*DPCT1114:974: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -464,7 +464,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_inj, q_inject.data(), q_inject.size() * sizeof(uint16_t))),+ d_inj, q_inject.data(), q_inject.size() * sizeof(uint16_t)).wait()),"c inj");const strata::kernels::GrShapes sh{n_embd, hc, hc_lr};@@ -611,7 +611,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_down_bad, tr_down.data(), tr_down.size() * 2)),+ d_down_bad, tr_down.data(), tr_down.size() * 2).wait()),"cb d");/*DPCT1114:976: cudaMemcpy is migrated to asynchronization memcpy,@@ -620,7 +620,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_up_bad, tr_up.data(), tr_up.size() * 2)),+ d_up_bad, tr_up.data(), tr_up.size() * 2).wait()),"cb u");std::vector<float> bad_mixed((size_t) n_embd);float* d_bad = nullptr;@@ -685,7 +685,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_Rw, R.data(), R.size() * sizeof(float))),+ d_Rw, R.data(), R.size() * sizeof(float)).wait()),"c Rw");/*DPCT1114:978: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -694,7 +694,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_bo, block_out.data(), block_out.size() * sizeof(float))),+ d_bo, block_out.data(), block_out.size() * sizeof(float)).wait()),"c bo");/*DPCT1114:979: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -703,7 +703,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_zi, zero_inj.data(), zero_inj.size() * sizeof(float))),+ d_zi, zero_inj.data(), zero_inj.size() * sizeof(float)).wait()),"c zi");strata::kernels::gr_write(d_Rw, d_bo, d_zi, sh, d_outw, nullptr);@@ -760,7 +760,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_zi, inj.data(), inj.size() * sizeof(float))),+ d_zi, inj.data(), inj.size() * sizeof(float)).wait()),"c inj2");strata::kernels::gr_write(d_Rw, d_bo, d_zi, sh, d_outw, nullptr);check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()@@ -841,7 +841,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- dR, rR.data(), rR.size() * 4)),+ dR, rR.data(), rR.size() * 4).wait()),"crR");/*DPCT1114:982: cudaMemcpy is migrated to asynchronization memcpy,@@ -850,7 +850,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- dN, rnorm.data(), rnorm.size() * 4)),+ dN, rnorm.data(), rnorm.size() * 4).wait()),"crN");/*DPCT1114:983: cudaMemcpy is migrated to asynchronization memcpy,@@ -859,7 +859,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- dD, qd.data(), qd.size() * 2)),+ dD, qd.data(), qd.size() * 2).wait()),"crD");/*DPCT1114:984: cudaMemcpy is migrated to asynchronization memcpy,@@ -868,7 +868,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- dU, qu.data(), qu.size() * 2)),+ dU, qu.data(), qu.size() * 2).wait()),"crU");/*DPCT1114:985: cudaMemcpy is migrated to asynchronization memcpy,@@ -877,7 +877,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- dJ, qi.data(), qi.size() * 2)),+ dJ, qi.data(), qi.size() * 2).wait()),"crJ");const strata::kernels::GrShapes rsh{rn, rhc, rlr};diff --git a/sycl/src/kernels/iq_parity.cpp b/sycl/src/kernels/iq_parity.cppindex 0f957d55b..3311bacb8 100644--- a/sycl/src/kernels/iq_parity.cpp+++ b/sycl/src/kernels/iq_parity.cpp@@ -47,7 +47,7 @@ int main(int argc, char** argv) {If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.*/- dpct::get_in_order_queue().memcpy(dw, raw.data(), raw.size());+ dpct::get_in_order_queue().memcpy(dw, raw.data(), raw.size()).wait();double dq_err = 0.0;if (strata::kernels::iq_supported(type) && ((size_t) rows * cols) % 256 == 0) {strata::kernels::iq_dequant_f32(type, dw, (int64_t) rows * cols, dq, s);@@ -79,7 +79,7 @@ int main(int argc, char** argv) {If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.*/- dpct::get_in_order_queue().memcpy(dx, x.data(), x.size() * 4);+ dpct::get_in_order_queue().memcpy(dx, x.data(), x.size() * 4).wait();strata::kernels::quantize_q8_1_rows(dx, 2, cols, xq, s);try {strata::kernels::native_mmvq(type, dw, xq, dy, cols, rows, 2, s);diff --git a/sycl/src/kernels/kv_q4_parity.cpp b/sycl/src/kernels/kv_q4_parity.cppindex 854f89933..adb24e7de 100644--- a/sycl/src/kernels/kv_q4_parity.cpp+++ b/sycl/src/kernels/kv_q4_parity.cpp@@ -122,7 +122,7 @@ int main() {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_src, h_in.data(), h_in.size() * sizeof(float))),+ d_src, h_in.data(), h_in.size() * sizeof(float)).wait()),"memcpy H2D");k::fwht256_cuda(d_src, d_dst, n_vectors, nullptr);@@ -219,7 +219,7 @@ int main() {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_table, table.data(), pages * sizeof(int32_t))),+ d_table, table.data(), pages * sizeof(int32_t)).wait()),"memcpy table");const size_t pool_bytes = (size_t) pages * H * P * k::kv_q4_bytes_per_head(D);@@ -257,7 +257,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_step, hstep, sizeof(hstep))),+ dpct::get_in_order_queue().memcpy(d_step, hstep, sizeof(hstep)).wait()),"memcpy step");/*DPCT1114:784: cudaMemcpy is migrated to asynchronization memcpy,@@ -266,7 +266,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_kcur, kv.data(), kv.size() * sizeof(float))),+ d_kcur, kv.data(), kv.size() * sizeof(float)).wait()),"memcpy k");/*DPCT1114:785: cudaMemcpy is migrated to asynchronization memcpy,@@ -275,7 +275,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_vcur, vv.data(), vv.size() * sizeof(float))),+ d_vcur, vv.data(), vv.size() * sizeof(float)).wait()),"memcpy v");k::kv_append_q4_step(d_k_q4, d_v_q4, d_table, d_step, d_kcur, d_vcur, s, nullptr);@@ -357,7 +357,7 @@ int main() {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ids, ids.data(), max_ids * sizeof(int32_t))),+ d_ids, ids.data(), max_ids * sizeof(int32_t)).wait()),"memcpy ids");int32_t hstep[k::kStepCount] = {0, 0, 0, max_ids};@@ -368,7 +368,7 @@ int main() {synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_step, hstep, sizeof(hstep))),+ dpct::get_in_order_queue().memcpy(d_step, hstep, sizeof(hstep)).wait()),"memcpy step");k::kv_gather_q4_step(d_k_q4, d_v_q4, d_table, d_ids, d_step, max_ids, s, d_k_scratch, d_v_scratch, nullptr);diff --git a/sycl/src/kernels/kv_q8_parity.cpp b/sycl/src/kernels/kv_q8_parity.cppindex 4d6e11777..7865de8eb 100644--- a/sycl/src/kernels/kv_q8_parity.cpp+++ b/sycl/src/kernels/kv_q8_parity.cpp@@ -60,7 +60,7 @@ int main() {synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_table, table.data(), pages * 4)),+ dpct::get_in_order_queue().memcpy(d_table, table.data(), pages * 4).wait()),"table");int8_t *kq = dalloc<int8_t>((size_t) cells * H * D), *vq = dalloc<int8_t>((size_t) cells * H * D);uint16_t *ks = dalloc<uint16_t>((size_t) cells * H * G), *vs = dalloc<uint16_t>((size_t) cells * H * G);@@ -89,7 +89,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(step, hstep, sizeof hstep)),+ dpct::get_in_order_queue().memcpy(step, hstep, sizeof hstep).wait()),"step");/*DPCT1114:426: cudaMemcpy is migrated to asynchronization memcpy,@@ -98,7 +98,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(kcur, kv.data(),- kv.size() * 4)),+ kv.size() * 4).wait()),"k");/*DPCT1114:427: cudaMemcpy is migrated to asynchronization memcpy,@@ -107,7 +107,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(vcur, vv.data(),- vv.size() * 4)),+ vv.size() * 4).wait()),"v");k::kv_append_q8_step(kq, vq, ks, vs, d_table, step, kcur, vcur, s, nullptr);k::kv_append_step(kp, vp, d_table, step, kcur, vcur, s, nullptr);@@ -171,7 +171,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_ids, ids.data(), n_ids * 4)),+ dpct::get_in_order_queue().memcpy(d_ids, ids.data(), n_ids * 4).wait()),"ids");int32_t hstep[k::kStepCount] = {0, 0, 0, n_ids};/*@@ -181,7 +181,7 @@ int main() {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(step, hstep, sizeof hstep)),+ dpct::get_in_order_queue().memcpy(step, hstep, sizeof hstep).wait()),"step");k::kv_gather_q8_step(kq, vq, ks, vs, d_table, d_ids, step, max_ids, s, k8, v8, nullptr);k::kv_gather_step(kp, vp, d_table, d_ids, step, max_ids, s, k16, v16, nullptr);diff --git a/sycl/src/kernels/kv_stream_parity.cpp b/sycl/src/kernels/kv_stream_parity.cppindex 81c19f08a..8c178d437 100644--- a/sycl/src/kernels/kv_stream_parity.cpp+++ b/sycl/src/kernels/kv_stream_parity.cpp@@ -142,7 +142,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(ident, t.data(),- n_blocks * 4)),+ n_blocks * 4).wait()),"ident");}k::KvStreamMap m;@@ -178,7 +178,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(kc, hk.data(), hk.size() * 4)),+ dpct::get_in_order_queue().memcpy(kc, hk.data(), hk.size() * 4).wait()),"k");/*DPCT1114:889: cudaMemcpy is migrated to asynchronization memcpy,@@ -187,7 +187,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(vc, hv.data(), hv.size() * 4)),+ dpct::get_in_order_queue().memcpy(vc, hv.data(), hv.size() * 4).wait()),"v");/*DPCT1114:890: cudaMemcpy is migrated to asynchronization memcpy,@@ -196,7 +196,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(step, st, sizeof(st))),+ dpct::get_in_order_queue().memcpy(step, st, sizeof(st)).wait()),"step");append(ref, ident, step, kc, vc, s, fmt, nullptr);append(slots, m.page_table, step, kc, vc, s, fmt, &host.p);@@ -221,7 +221,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(ids, hids.data(),- hids.size() * 4)),+ hids.size() * 4).wait()),"ids");/*DPCT1114:892: cudaMemcpy is migrated to asynchronization memcpy,@@ -230,7 +230,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(steps, hst.data(),- hst.size() * 4)),+ hst.size() * 4).wait()),"steps");/*DPCT1114:893: cudaMemcpy is migrated to asynchronization memcpy,@@ -239,7 +239,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(q, hq.data(), hq.size() * 4)),+ dpct::get_in_order_queue().memcpy(q, hq.data(), hq.size() * 4).wait()),"q");k::qsa_decode_attn_batch(q, ref.attn(ident), ids, steps, cap, s, scratch, out_ref, n_q, nullptr);k::kv_stream_resolve(m, slots.attn(m.page_table), host.p, fmt, ids, steps, n_q, cap, s, nullptr);@@ -304,7 +304,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(ids, hids.data(),- hids.size() * 4)),+ hids.size() * 4).wait()),"ids");/*DPCT1114:895: cudaMemcpy is migrated to asynchronization memcpy,@@ -313,7 +313,7 @@ bool run(int fmt) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(steps, hst.data(), 16)),+ dpct::get_in_order_queue().memcpy(steps, hst.data(), 16).wait()),"steps");k::qsa_decode_attn_batch(q, ref.attn(ident), ids, steps, cap, s, scratch, out_ref, 1, nullptr);k::qsa_decode_attn_batch(q, ring.attn(rt), ids, steps, cap, s, scratch, out_str, 1, nullptr);diff --git a/sycl/src/kernels/native_expert_parity.cpp b/sycl/src/kernels/native_expert_parity.cppindex ac6b6f786..5552aceb0 100644--- a/sycl/src/kernels/native_expert_parity.cpp+++ b/sycl/src/kernels/native_expert_parity.cpp@@ -5,9 +5,6 @@// (a) float reference: ggml's own dequantizer (`to_float`) and a float SwiGLU expert, (b) the CPU path// (ggml-cpu vec_dot with its quantized activations), (c) the GPU path (`native_expert_grouped`, q8_1// activations). (b) and (c) each differ from (a) by their activation rounding only (a few 1e-3 relative).-#define DPCT_PROFILING_ENABLED-#include <sycl/sycl.hpp>-#include <dpct/dpct.hpp>#include "strata/artifact/gguf_reader.hpp"#include "strata/kernels/cpu/native_expert.hpp"#include "strata/kernels/cpu/expert.hpp"@@ -19,6 +16,9 @@#include "ggml.h"+#include <sycl/sycl.hpp>+#include <dpct/dpct.hpp> // SYCL port: hand-ported (dpct needs ggml-cpu.h to parse this file)+#include <chrono>#include <cmath>#include <cstdio>@@ -45,8 +45,7 @@ int main(int argc, char** argv) {const int NT = 3, E = 7;const int64_t H = 2560, FF = 640;int failures = 0;- dpct::queue_ptr s;- s = dpct::get_current_device().create_queue(true);+ sycl::queue* s = &dpct::get_in_order_queue();for (int l : layers) {const strata::TensorInfo* t[3] = {};const char* roles[3] = {"gate", "up", "down"};@@ -224,31 +223,31 @@ int main(int argc, char** argv) {float* dout;unsigned long long* dptr;int32_t *dstart, *dn, *ddst, *dtok;- cudaMalloc(&dblob, blob.size());- cudaMalloc(&dx, x.size() * 4);- cudaMalloc(&dxq, (size_t) NT * H / 32 * 36);- cudaMalloc(&dscr, strata::kernels::native_expert_scratch_bytes(NT, FF));- cudaMalloc((void**) &dout, (size_t) NT * H * 4);- cudaMalloc((void**) &dptr, 8);- cudaMalloc((void**) &dstart, 8);- cudaMalloc((void**) &dn, 4);- cudaMalloc((void**) &ddst, NT * 4);- cudaMalloc((void**) &dtok, NT * 4);- cudaMemcpy(dblob, blob.data(), blob.size(), cudaMemcpyHostToDevice);- cudaMemcpy(dx, x.data(), x.size() * 4, cudaMemcpyHostToDevice);+ dblob = (decltype(dblob)) sycl::malloc_device(blob.size(), *s);+ dx = (decltype(dx)) sycl::malloc_device(x.size() * 4, *s);+ dxq = (decltype(dxq)) sycl::malloc_device((size_t) NT * H / 32 * 36, *s);+ dscr = (decltype(dscr)) sycl::malloc_device(strata::kernels::native_expert_scratch_bytes(NT, FF), *s);+ dout = (decltype(dout)) sycl::malloc_device((size_t) NT * H * 4, *s);+ dptr = (decltype(dptr)) sycl::malloc_device(8, *s);+ dstart = (decltype(dstart)) sycl::malloc_device(8, *s);+ dn = (decltype(dn)) sycl::malloc_device(4, *s);+ ddst = (decltype(ddst)) sycl::malloc_device(NT * 4, *s);+ dtok = (decltype(dtok)) sycl::malloc_device(NT * 4, *s);+ s->memcpy(dblob, blob.data(), blob.size()).wait();+ s->memcpy(dx, x.data(), x.size() * 4).wait();const unsigned long long p = (unsigned long long) dblob;const int32_t st[2] = {0, NT}, one = 1, idx[NT] = {0, 1, 2};- cudaMemcpy(dptr, &p, 8, cudaMemcpyHostToDevice);- cudaMemcpy(dstart, st, 8, cudaMemcpyHostToDevice);- cudaMemcpy(dn, &one, 4, cudaMemcpyHostToDevice);- cudaMemcpy(ddst, idx, NT * 4, cudaMemcpyHostToDevice);- cudaMemcpy(dtok, idx, NT * 4, cudaMemcpyHostToDevice);+ s->memcpy(dptr, &p, 8).wait();+ s->memcpy(dstart, st, 8).wait();+ s->memcpy(dn, &one, 4).wait();+ s->memcpy(ddst, idx, NT * 4).wait();+ s->memcpy(dtok, idx, NT * 4).wait();strata::kernels::quantize_q8_1_rows((const float*) dx, NT, H, dxq, s);strata::kernels::native_expert_grouped(L, dptr, dstart, dn, ddst, dtok, 1, NT, dxq, dscr, dout, s);- cudaStreamSynchronize(s);- cudaMemcpy(got_g.data(), dout, got_g.size() * 4, cudaMemcpyDeviceToHost);- cudaFree(dblob); cudaFree(dx); cudaFree(dxq); cudaFree(dscr); cudaFree(dout); cudaFree(dptr);- cudaFree(dstart); cudaFree(dn); cudaFree(ddst); cudaFree(dtok);+ s->wait();+ s->memcpy(got_g.data(), dout, got_g.size() * 4).wait();+ sycl::free(dblob, *s); sycl::free(dx, *s); sycl::free(dxq, *s); sycl::free(dscr, *s); sycl::free(dout, *s); sycl::free(dptr, *s);+ sycl::free(dstart, *s); sycl::free(dn, *s); sycl::free(ddst, *s); sycl::free(dtok, *s);}const double ec = rel(got_c, ref), eg = rel(got_g, ref), ecg = rel(got_c, got_g);const bool ok = ec < 3e-2 && eg < 3e-2 && std::isfinite(ec) && std::isfinite(eg);diff --git a/sycl/src/kernels/ple_parity.cpp b/sycl/src/kernels/ple_parity.cppindex 4f0c3c21a..79aede9c1 100644--- a/sycl/src/kernels/ple_parity.cpp+++ b/sycl/src/kernels/ple_parity.cpp@@ -215,7 +215,7 @@ int history_advance_regression() {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- history, expected.data(), count * sizeof(float))),+ history, expected.data(), count * sizeof(float)).wait()),"history initial values");dpct::queue_ptr stream;dpct::experimental::command_graph_ptr graph;@@ -770,7 +770,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_nk, cap.w_nk.data(), hcd * 4)),+ dpct::get_in_order_queue().memcpy(d_nk, cap.w_nk.data(), hcd * 4).wait()),"cnk");/*DPCT1114:948: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -779,7 +779,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_nq, cap.w_nq.data(), hcd * 4)),+ dpct::get_in_order_queue().memcpy(d_nq, cap.w_nq.data(), hcd * 4).wait()),"cnq");/*DPCT1114:949: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -788,7 +788,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_nc, cap.w_nc.data(), hcd * 4)),+ dpct::get_in_order_queue().memcpy(d_nc, cap.w_nc.data(), hcd * 4).wait()),"cnc");/*DPCT1114:950: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -797,7 +797,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_kc, key_codes.data(), key_codes.size())),+ d_kc, key_codes.data(), key_codes.size()).wait()),"ckc");/*DPCT1114:951: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -806,7 +806,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_vb, value_bf16.data(), value_bf16.size() * 2)),+ d_vb, value_bf16.data(), value_bf16.size() * 2).wait()),"cvb");/*DPCT1114:952: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -815,7 +815,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_c1, conv1d_f16.data(), conv1d_f16.size() * 2)),+ d_c1, conv1d_f16.data(), conv1d_f16.size() * 2).wait()),"cc1");k::PleWeights w{};@@ -837,7 +837,7 @@ int main(int argc, char** argv) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ks, key_scales.data(), key_scales.size() * 4)),+ d_ks, key_scales.data(), key_scales.size() * 4).wait()),"cks");w.key_scales = d_ks;@@ -867,7 +867,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_emb, cap.emb.data() + (size_t)t * nd, nd * 4)),+ d_emb, cap.emb.data() + (size_t)t * nd, nd * 4).wait()),"cemb");/*DPCT1114:955: cudaMemcpy is migrated to asynchronization memcpy,@@ -876,7 +876,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_hid, cap.hidden.data() + (size_t)t * hcd, hcd * 4)),+ d_hid, cap.hidden.data() + (size_t)t * hcd, hcd * 4).wait()),"chid");/*DPCT1114:956: cudaMemcpy is migrated to asynchronization memcpy,@@ -885,7 +885,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_hist, hist_state.data(), (size_t)k::NG_HIST * hcd * 4)),+ d_hist, hist_state.data(), (size_t)k::NG_HIST * hcd * 4).wait()),"chist");k::PleOut out{};out.key = d_ck; out.value = d_cv; out.gate = d_g; out.gated = d_gd;@@ -1016,7 +1016,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_emb, witness.data(), nd * sizeof(float))),+ d_emb, witness.data(), nd * sizeof(float)).wait()),"native PLE witness");k::ple_block(d_emb, d_hid, d_hist, w, out, ple_ws, nullptr);ck(DPCT_CHECK_ERROR(@@ -1095,7 +1095,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_emb, cap.emb.data(), nd * sizeof(float))),+ d_emb, cap.emb.data(), nd * sizeof(float)).wait()),"restore PLE embedding");k::ple_block(d_emb, d_hid, d_hist, w, out, ple_ws, nullptr);ck(DPCT_CHECK_ERROR(@@ -1153,7 +1153,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- native_data, native_key.data(), native_bytes)),+ native_data, native_key.data(), native_bytes).wait()),"native PLE weights upload");k::PleWeights nw = w;nw.key_native_data = native_data; nw.key_native_type = 42; nw.key_native_q8_1 = native_q;@@ -1209,7 +1209,7 @@ int main(int argc, char** argv) {return by memcpy API to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_emb, cap.emb.data() + (size_t)p * nd, nd * 4)),+ d_emb, cap.emb.data() + (size_t)p * nd, nd * 4).wait()),"native PLE key input");k::native_q2_0_f32(native_data, d_emb, native_q, raw_projection, k::NG_N_EMBD, k::NG_HC_DIM, 1, stream);ck(DPCT_CHECK_ERROR(stream->wait()), "native PLE raw key sync");@@ -1306,7 +1306,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_emb, cap.emb.data(), nd * 4)),+ d_emb, cap.emb.data(), nd * 4).wait()),"native PLE restore input");k::ple_block(d_emb, d_hid, d_hist, w, out, ple_ws, nullptr);ck(DPCT_CHECK_ERROR(@@ -1360,7 +1360,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_hid, cap.hidden.data(), hcd * sizeof(float))),+ d_hid, cap.hidden.data(), hcd * sizeof(float)).wait()),"restore PLE hidden input");sycl::free(compact_workspace, dpct::get_in_order_queue());}diff --git a/sycl/src/kernels/qsa_parity.cpp b/sycl/src/kernels/qsa_parity.cppindex 920375099..e4c3df23b 100644--- a/sycl/src/kernels/qsa_parity.cpp+++ b/sycl/src/kernels/qsa_parity.cpp@@ -98,7 +98,7 @@ struct Dev {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- p, v.data(), v.size() * sizeof(T))),+ p, v.data(), v.size() * sizeof(T)).wait()),"H2D");}std::vector<T> get(size_t n) const {diff --git a/sycl/src/kernels/qsa_prompt_attn_parity.cpp b/sycl/src/kernels/qsa_prompt_attn_parity.cppindex c865ca196..5746b6c8a 100644--- a/sycl/src/kernels/qsa_prompt_attn_parity.cpp+++ b/sycl/src/kernels/qsa_prompt_attn_parity.cpp@@ -45,7 +45,7 @@ template <typename T> T* up(const std::vector<T>& h) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d, h.data(), h.size() * sizeof(T))),+ d, h.data(), h.size() * sizeof(T)).wait()),"upload");return d;}diff --git a/sycl/src/kernels/qsa_select_bench.cpp b/sycl/src/kernels/qsa_select_bench.cppindex b73912e45..6287a804b 100644--- a/sycl/src/kernels/qsa_select_bench.cpp+++ b/sycl/src/kernels/qsa_select_bench.cpp@@ -38,7 +38,7 @@ template <typename T> T* up(const std::vector<T>& h) {synchronization behavior.*/ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d, h.data(), h.size() * sizeof(T))),+ d, h.data(), h.size() * sizeof(T)).wait()),"upload");return d;}diff --git a/sycl/src/kernels/quantize_act_parity.cpp b/sycl/src/kernels/quantize_act_parity.cppindex a4a8222ef..8f3a15b17 100644--- a/sycl/src/kernels/quantize_act_parity.cpp+++ b/sycl/src/kernels/quantize_act_parity.cpp@@ -90,7 +90,7 @@ int run_case(const char* name, const std::vector<float>& x, bool check_bytes) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), (size_t)n * sizeof(float))),+ d_x, x.data(), (size_t)n * sizeof(float)).wait()),"copy x");// PROBE: does the DEVICE hold what the host thinks it sent? The scale byte differs with the SAME// exponent and a zeroed mantissa, which says the kernel's amax differs from the host's on identical@@ -222,7 +222,7 @@ int run_case_k(const char* name, const std::vector<float>& x, bool check_bytes,synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), (size_t)n * sizeof(float))),+ d_x, x.data(), (size_t)n * sizeof(float)).wait()),"copy x");strata::kernels::quantize_q8_K(d_x, d_b, n, nullptr);strata::kernels::dequant_q8_K(d_b, d_back, n, nullptr);diff --git a/sycl/src/kernels/rope_parity.cpp b/sycl/src/kernels/rope_parity.cppindex c0aea5dd5..0b7e5ad3b 100644--- a/sycl/src/kernels/rope_parity.cpp+++ b/sycl/src/kernels/rope_parity.cpp@@ -113,7 +113,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * sizeof(float))),+ d_x, x.data(), x.size() * sizeof(float)).wait()),"copy x");/*DPCT1114:310: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -122,7 +122,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_cos, hcos.data(), hcos.size() * sizeof(float))),+ d_cos, hcos.data(), hcos.size() * sizeof(float)).wait()),"copy cos");/*DPCT1114:311: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -131,7 +131,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_sin, hsin.data(), hsin.size() * sizeof(float))),+ d_sin, hsin.data(), hsin.size() * sizeof(float)).wait()),"copy sin");/*DPCT1114:312: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -140,7 +140,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_pos, pos.data(), pos.size() * sizeof(int))),+ d_pos, pos.data(), pos.size() * sizeof(int)).wait()),"copy pos");strata::kernels::rope_neox_apply(d_x, d_out, rows, head_dim, n_rot, d_cos, d_sin, d_pos, nullptr);std::vector<float> got(ref.size());@@ -195,7 +195,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, e.data(), e.size() * sizeof(float))),+ d_x, e.data(), e.size() * sizeof(float)).wait()),"copy e");// position 7, NOT position 0: at pos 0 sin is exactly 0, so dim half legitimately does not move and// the check would report the correct kernel as wrong. The first version made exactly that mistake.diff --git a/sycl/src/kernels/router_top10_parity.cpp b/sycl/src/kernels/router_top10_parity.cppindex 6fb0113c9..f492bd74d 100644--- a/sycl/src/kernels/router_top10_parity.cpp+++ b/sycl/src/kernels/router_top10_parity.cpp@@ -85,7 +85,7 @@ int run_case(const char* name, const std::vector<float>& logits, int n_tokens, isynchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_l, logits.data(), logits.size() * sizeof(float))),+ d_l, logits.data(), logits.size() * sizeof(float)).wait()),"copy");strata::kernels::router_top10(d_l, n_tokens, n_expert, k, d_ids, d_w, nullptr);check(DPCT_CHECK_ERROR(diff --git a/sycl/src/kernels/s2_gemv_parity.cpp b/sycl/src/kernels/s2_gemv_parity.cppindex 3c2b16377..1f4bd0c25 100644--- a/sycl/src/kernels/s2_gemv_parity.cpp+++ b/sycl/src/kernels/s2_gemv_parity.cpp@@ -131,7 +131,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * sizeof(uint16_t))),+ d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"copy x");/*DPCT1114:483: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -140,7 +140,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"copy codes");/*DPCT1114:484: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -149,7 +149,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * sizeof(float))),+ d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"copy scales");strata::kernels::s2_gemv(d_x, d_codes, d_scales, d_y, n_in, n_out);diff --git a/sycl/src/kernels/s2_gemv_q8_parity.cpp b/sycl/src/kernels/s2_gemv_q8_parity.cppindex 66fc2834a..53a5b0ad7 100644--- a/sycl/src/kernels/s2_gemv_q8_parity.cpp+++ b/sycl/src/kernels/s2_gemv_q8_parity.cpp@@ -80,7 +80,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * sizeof(float))),+ d_x, x.data(), x.size() * sizeof(float)).wait()),"c x");/*DPCT1114:932: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -89,7 +89,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"c codes");/*DPCT1114:933: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -98,7 +98,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * sizeof(float))),+ d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"c scales");strata::kernels::quantize_q8_0(d_x, d_act, n_in, nullptr);@@ -204,7 +204,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_hx, hx.data(), hx.size() * sizeof(uint16_t))),+ d_hx, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"c hx");strata::kernels::SForm form{2, -1, 64, strata::kernels::Codebook::Affine, false};strata::kernels::s_gemv_split(d_hx, d_codes, d_scales, nullptr, d_y_fp16, n_in, n_out, form, tpr);diff --git a/sycl/src/kernels/s_gemv_parity.cpp b/sycl/src/kernels/s_gemv_parity.cppindex cc0486139..9cd4972a0 100644--- a/sycl/src/kernels/s_gemv_parity.cpp+++ b/sycl/src/kernels/s_gemv_parity.cpp@@ -253,7 +253,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * sizeof(uint16_t))),+ d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"copy x");/*DPCT1114:394: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -262,7 +262,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"copy codes");/*DPCT1114:395: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -271,7 +271,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * sizeof(float))),+ d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"copy scales");/*DPCT1114:396: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -280,7 +280,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_offsets, offsets.data(), offsets.size() * sizeof(float))),+ d_offsets, offsets.data(), offsets.size() * sizeof(float)).wait()),"copy offsets");strata::kernels::s_gemv(d_x, d_codes, d_scales, d_offsets, d_y, n_in, n_out, form);std::vector<float> got((size_t) n_out);@@ -373,7 +373,7 @@ void bench_s2_gemv(long long n_in, long long n_out, int iters, int* split_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * sizeof(uint16_t))),+ d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"bench copy x");/*DPCT1114:398: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -382,7 +382,7 @@ void bench_s2_gemv(long long n_in, long long n_out, int iters, int* split_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"bench copy codes");/*DPCT1114:399: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -391,7 +391,7 @@ void bench_s2_gemv(long long n_in, long long n_out, int iters, int* split_bad) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * sizeof(float))),+ d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"bench copy scales");for (int i = 0; i < 3; ++i) strata::kernels::s_gemv(d_x, d_codes, d_scales, nullptr, d_y, n_in, n_out, form);@@ -670,7 +670,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, x.data(), x.size() * sizeof(uint16_t))),+ d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"copy x");/*DPCT1114:401: cudaMemcpy is migrated to asynchronization memcpy,@@ -679,7 +679,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"copy codes");/*DPCT1114:402: cudaMemcpy is migrated to asynchronization memcpy,@@ -688,7 +688,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * sizeof(float))),+ d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"copy scales");strata::kernels::s_gemv(d_x, d_codes, d_scales, nullptr, d_y, n_in, n_out, tc.form);std::vector<float> got((size_t) n_out);diff --git a/sycl/src/kernels/s_gemv_q8k_parity.cpp b/sycl/src/kernels/s_gemv_q8k_parity.cppindex 9fecea6c8..9f572cf90 100644--- a/sycl/src/kernels/s_gemv_q8k_parity.cpp+++ b/sycl/src/kernels/s_gemv_q8k_parity.cpp@@ -129,7 +129,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_xf, xf.data(), (size_t)n_in * 4)),+ d_xf, xf.data(), (size_t)n_in * 4).wait()),"cxf");strata::kernels::quantize_q8_K(d_xf, d_xq, n_in, nullptr);check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()@@ -171,7 +171,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_codes, codes.data(), codes.size())),+ d_codes, codes.data(), codes.size()).wait()),"cc");/*DPCT1114:849: cudaMemcpy is migrated to asynchronization memcpy,@@ -180,7 +180,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_scales, scales.data(), scales.size() * 4)),+ d_scales, scales.data(), scales.size() * 4).wait()),"cs");/*DPCT1114:850: cudaMemcpy is migrated to asynchronization memcpy,@@ -189,7 +189,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_offs, offs.data(), offs.size() * 4)),+ d_offs, offs.data(), offs.size() * 4).wait()),"co");std::vector<float> naive((size_t) n_out), warp((size_t) n_out);@@ -286,7 +286,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x16, x16.data(), (size_t)n_in * 2)),+ d_x16, x16.data(), (size_t)n_in * 2).wait()),"cx16");std::vector<float> fp16out((size_t) n_out);strata::kernels::s_gemv(d_x16, d_codes, d_scales, cs.has_offset ? d_offs : nullptr, d_y, n_in, n_out,diff --git a/sycl/src/kernels/sampler_parity.cpp b/sycl/src/kernels/sampler_parity.cppindex 4e0568f1f..46e140a5b 100644--- a/sycl/src/kernels/sampler_parity.cpp+++ b/sycl/src/kernels/sampler_parity.cpp@@ -114,7 +114,7 @@ int run(const char* name, const std::vector<float>& logits, int n_tokens, constsynchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_l, logits.data(), logits.size() * sizeof(float))),+ d_l, logits.data(), logits.size() * sizeof(float)).wait()),"copy");// -1 in every output slot first: a row the kernel leaves unwritten can never match (a verify window reads// every row, so "no output" is a wrong answer, not a skipped one)@@ -135,7 +135,7 @@ int run(const char* name, const std::vector<float>& logits, int n_tokens, constto ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_h, hist.data(), hist.size() * sizeof(int))),+ d_h, hist.data(), hist.size() * sizeof(int)).wait()),"copy hist");}strata::kernels::sample_tokens(d_l, n_tokens, (int) (logits.size() / n_tokens), d_h, hist_len, p, d_o,@@ -378,7 +378,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_l, l.data(), l.size() * sizeof(float))),+ d_l, l.data(), l.size() * sizeof(float)).wait()),"c1");strata::kernels::sample_tokens(d_l, NT, NV, nullptr, 0, a, d_a, nullptr);strata::kernels::sample_tokens(d_l, NT, NV, nullptr, 0, b, d_b, nullptr);@@ -887,7 +887,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- input, uniform.data(), uniform.size() * sizeof(float))),+ input, uniform.data(), uniform.size() * sizeof(float)).wait()),"counter upload");strata::kernels::SamplerParams p;p.top_k = vocab; p.top_p = 1.0f; p.seed = 123; p.counter = (uint64_t(1) << 32) + 7;diff --git a/sycl/src/kernels/shared_expert_parity.cpp b/sycl/src/kernels/shared_expert_parity.cppindex 45aeeb8fa..e6bd26546 100644--- a/sycl/src/kernels/shared_expert_parity.cpp+++ b/sycl/src/kernels/shared_expert_parity.cpp@@ -233,7 +233,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_x, hx.data(), hx.size() * sizeof(uint16_t))),+ d_x, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"c x");/*DPCT1114:335: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -242,7 +242,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_gc, gc.data(), gc.size())),+ dpct::get_in_order_queue().memcpy(d_gc, gc.data(), gc.size()).wait()),"c gc");/*DPCT1114:336: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -251,7 +251,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_uc, uc.data(), uc.size())),+ dpct::get_in_order_queue().memcpy(d_uc, uc.data(), uc.size()).wait()),"c uc");/*DPCT1114:337: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -260,7 +260,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(- dpct::get_in_order_queue().memcpy(d_dc, dc.data(), dc.size())),+ dpct::get_in_order_queue().memcpy(d_dc, dc.data(), dc.size()).wait()),"c dc");/*DPCT1114:338: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -269,7 +269,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_gs, gs.data(), gs.size() * sizeof(float))),+ d_gs, gs.data(), gs.size() * sizeof(float)).wait()),"c gs");/*DPCT1114:339: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -278,7 +278,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_us, us.data(), us.size() * sizeof(float))),+ d_us, us.data(), us.size() * sizeof(float)).wait()),"c us");/*DPCT1114:340: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -287,7 +287,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ds, ds.data(), ds.size() * sizeof(float))),+ d_ds, ds.data(), ds.size() * sizeof(float)).wait()),"c ds");/*DPCT1114:341: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -296,7 +296,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ginp, ginp.data(), ginp.size() * sizeof(float))),+ d_ginp, ginp.data(), ginp.size() * sizeof(float)).wait()),"c ginp");/*DPCT1114:342: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -305,7 +305,7 @@ int main(int argc, char** argv) {synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_xb, hx_bf16.data(), hx_bf16.size() * sizeof(uint16_t))),+ d_xb, hx_bf16.data(), hx_bf16.size() * sizeof(uint16_t)).wait()),"c xb");/*DPCT1114:343: cudaMemcpy is migrated to asynchronization memcpy, assuming in@@ -315,7 +315,7 @@ int main(int argc, char** argv) {*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ginpb, hginp_bf16.data(), hginp_bf16.size() * sizeof(uint16_t))),+ d_ginpb, hginp_bf16.data(), hginp_bf16.size() * sizeof(uint16_t)).wait()),"c ginpb");const strata::kernels::SForm f{2, -1, 64, strata::kernels::Codebook::Affine, false, /*act_kind=*/0};@@ -341,7 +341,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_xf, fx.data(), (size_t)n_embd * 4)),+ d_xf, fx.data(), (size_t)n_embd * 4).wait()),"cxf");strata::kernels::quantize_q8_0(d_xf, d_x0, n_embd, nullptr);check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()@@ -473,7 +473,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_witness, witness.data(), witness.size() * sizeof(float))),+ d_witness, witness.data(), witness.size() * sizeof(float)).wait()),"native shared upload x");auto run = [&](void* stream, const float* x_float = nullptr) {shared_expert(d_x_used, nullptr, d_xb, f, d_gc, d_gs, nullptr, f, d_uc, d_us, nullptr, f,@@ -486,7 +486,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ginpb, zeros.data(), zeros.size() * sizeof(uint16_t))),+ d_ginpb, zeros.data(), zeros.size() * sizeof(uint16_t)).wait()),"zero shared gate");run(nullptr);std::vector<float> half_output((size_t) n_embd), legacy((size_t) n_embd), native((size_t) n_embd), replay((size_t) n_embd);@@ -502,7 +502,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_ginpb, basis.data(), basis.size() * sizeof(uint16_t))),+ d_ginpb, basis.data(), basis.size() * sizeof(uint16_t)).wait()),"basis shared gate");/*DPCT1114:348: cudaMemcpy is migrated to asynchronization memcpy,@@ -512,7 +512,7 @@ int main(int argc, char** argv) {*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_xb, witness_bf16.data(),- witness_bf16.size() * sizeof(uint16_t))),+ witness_bf16.size() * sizeof(uint16_t)).wait()),"witness shared bf16");run(nullptr);check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()@@ -592,7 +592,7 @@ int main(int argc, char** argv) {*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_ginpb, hginp_bf16.data(),- hginp_bf16.size() * sizeof(uint16_t))),+ hginp_bf16.size() * sizeof(uint16_t)).wait()),"restore shared gate");/*DPCT1114:351: cudaMemcpy is migrated to asynchronization memcpy,@@ -601,7 +601,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_xb, hx_bf16.data(), hx_bf16.size() * sizeof(uint16_t))),+ d_xb, hx_bf16.data(), hx_bf16.size() * sizeof(uint16_t)).wait()),"restore shared bf16");run(nullptr);check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()@@ -674,7 +674,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_p, parts.data(), parts.size() * 4)),+ d_p, parts.data(), parts.size() * 4).wait()),"mc cp");/*DPCT1114:353: cudaMemcpy is migrated to asynchronization memcpy,@@ -683,7 +683,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_w, w.data(),- w.size() * 4)),+ w.size() * 4).wait()),"mc cw");/*DPCT1114:354: cudaMemcpy is migrated to asynchronization memcpy,@@ -692,7 +692,7 @@ int main(int argc, char** argv) {to ensure synchronization behavior.*/check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_s, shared.data(), shared.size() * 4)),+ d_s, shared.data(), shared.size() * 4).wait()),"mc cs");strata::kernels::moe_combine(d_p, d_w, d_s, d_y, n_embd2, k2, nullptr);std::vector<float> got((size_t) n_embd2);diff --git a/sycl/src/prefill/prefill.cpp b/sycl/src/prefill/prefill.cppindex 01d601fe2..aee620fe7 100644--- a/sycl/src/prefill/prefill.cpp+++ b/sycl/src/prefill/prefill.cpp@@ -577,7 +577,7 @@ bool Prefill::init(const core::WeightTable &wt, const core::ModelGeometry &g,by memcpy API to ensure synchronization behavior.*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- m.ident_table, ident.data(), ident.size() * 4)) != 0)+ m.ident_table, ident.data(), ident.size() * 4).wait()) != 0)ok = false;elsem.owned.push_back(m.ident_table);diff --git a/sycl/src/program/generate.cpp b/sycl/src/program/generate.cppindex 01844c998..49f7d05db 100644--- a/sycl/src/program/generate.cpp+++ b/sycl/src/program/generate.cpp@@ -20,6 +20,7 @@#include "strata/sycl_queue.hpp"#include "strata/core/expert_cache.hpp"#include "strata/core/expert_source.hpp"+#include "strata/core/gguf_expert_source.hpp"#include "strata/core/remote_experts.hpp"#include "strata/core/on_device.hpp"#include "strata/core/layer.hpp"@@ -182,6 +183,7 @@ struct Options {/// is reserved for a host thread that has nothing to do while the drain runs.bool no_host_worker = false;bool mmap_experts = false; ///< R2.1: opt OUT of the resident arena, back to MapViewOfFile+ bool stream_experts = false; ///< SYCL port: no host arena; blobs read from the GGUF on demand (all experts in VRAM)/// R4: slots of VRAM-resident experts. **0 = off, and off is the default.**/// **THE COMMENT THAT USED TO BE HERE WAS FALSE AND ROUND 328 MEASURED IT.** It said "the cache has no/// consumer yet - `moe_hit_grouped_s2` does not exist - so switching it on costs the fill traffic and@@ -430,6 +432,8 @@ void usage() {" except the one the host loop spins on. A sweep is how the pool's\n"" deviation from `cpu_s2` is attributed.\n"" --mmap-experts R2.1: opt OUT of the resident expert arena, back to MapViewOfFile.\n"+ " --stream-experts no host arena: experts read from the GGUF on demand (needs a native pack and\n"+ " a VRAM cache that holds every expert; for machines with less RAM than experts)\n"" The A/B arm: the mmap's rate depends on the OS page cache holding\n"" 34 GB, and measured 71.97 vs 34.78 ms/token cold vs warm.\n");}@@ -782,7 +786,7 @@ bool checkpoint_restore(const ConvCheckpoint &c, strata::core::SessionState &ss,synchronization behavior.*/if (DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- ss.gdn_state, c.gdn.data(), z.gdn)) != 0) return false;+ ss.gdn_state, c.gdn.data(), z.gdn).wait()) != 0) return false;/*DPCT1114:668: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memory@@ -790,7 +794,7 @@ bool checkpoint_restore(const ConvCheckpoint &c, strata::core::SessionState &ss,synchronization behavior.*/if (!c.ple.empty() && DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- ss.ple_hist, c.ple.data(), z.ple)) != 0)+ ss.ple_hist, c.ple.data(), z.ple).wait()) != 0)return false;for (int64_t i = 0; i < g.n_qsa_layers(); ++i)/*@@ -801,7 +805,7 @@ bool checkpoint_restore(const ConvCheckpoint &c, strata::core::SessionState &ss,*/if (DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(ss.qsa_states[i].idx_tail, c.tails.data() + (size_t)i * z.tail,- z.tail)) != 0)+ z.tail).wait()) != 0)return false;// the PLE's token window is the last two tokens, OLDEST FIRST, -1 where there is none (as session_zero leaves it)const size_t L = c.ids.size();@@ -916,7 +920,7 @@ double probe_pcie_h2d_gbps() try {ensure synchronization behavior.*/dpct::get_in_order_queue().memcpy(- d, h, kBytes); // warmup: context up, copy engine primed+ d, h, kBytes).wait(); // warmup: context up, copy engine primeddpct::sync_barrier(ev0);/*DPCT1124:671: cudaMemcpyAsync is migrated to asynchronous memcpy API. While@@ -925,7 +929,7 @@ double probe_pcie_h2d_gbps() try {ensure synchronization behavior.*/for (int i = 0; i < kIters; ++i) dpct::get_in_order_queue().memcpy(d, h,- kBytes);+ kBytes).wait();dpct::sync_barrier(ev1);const bool ok = DPCT_CHECK_ERROR(ev1->wait_and_throw()) == 0;float ms = 0.f;@@ -1140,6 +1144,7 @@ int main(int argc, char** argv) {else if (a == "--expert-profile") o.expert_profile = next("--expert-profile");else if (a == "--gpu-stages") o.gpu_stages = true;else if (a == "--mmap-experts") o.mmap_experts = true;+ else if (a == "--stream-experts") o.stream_experts = true;else if (a == "--stats") o.stats = true;else if (a == "--shared-late") o.shared_late = true;else if (a == "--keep-canonical") o.keep_canonical = true;@@ -1528,7 +1533,7 @@ int main(int argc, char** argv) {*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_mrope, mrope_host.data(),- mrope_host.size() * sizeof(int32_t))) != 0) {+ mrope_host.size() * sizeof(int32_t)).wait()) != 0) {std::fprintf(stderr, "strata generate: cannot allocate the image position table\n");return 1;}@@ -1812,7 +1817,7 @@ int main(int argc, char** argv) {*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(st.mrope, mrope_host.data(),- mrope_host.size() * sizeof(int32_t))) != 0) {+ mrope_host.size() * sizeof(int32_t)).wait()) != 0) {std::fprintf(stderr, "strata generate: layer split, CUDA%d: the image position table failed\n", st.dev);return 1;}@@ -1888,6 +1893,7 @@ int main(int argc, char** argv) {// note in `pinned.cu`.strata::core::FileExpertSource src;strata::core::ArenaExpertSource arena_src;+ strata::core::GgufExpertSource gguf_src;strata::core::ExpertSource* srcp = nullptr;if (o.mmap_experts) {if (native_pack) { // FileExpertSource maps the canonical pack's experts.bin; a native pack has none@@ -1901,6 +1907,21 @@ int main(int argc, char** argv) {}std::fprintf(stderr, "strata generate: experts via mmap (--mmap-experts; the A/B arm of R2.1)\n");srcp = &src;+ } else if (o.stream_experts) {+ // the SYCL port: a card that holds every expert needs no host copy of them, and a 23 GiB machine cannot+ // hold one. The profile fill reads each blob once from the shard; nothing reads from here afterwards+ // unless a slot is lent to the prefill and refilled.+ if (!native_pack || o.native_preset.empty()) {+ std::fprintf(stderr, "strata generate: --stream-experts needs a native (IQ) pack and --native SHARD1\n");+ return 2;+ }+ if (!gguf_src.open(o.native_preset, g.n_layers, g.n_expert, err)) {+ std::fprintf(stderr, "strata generate: %s\n", err.c_str());+ return 1;+ }+ std::fprintf(stderr, "strata generate: experts streamed from the GGUF on demand (--stream-experts): no host "+ "arena; every expert must fit the VRAM cache\n");+ srcp = &gguf_src;} else {arena_src.set_gguf(o.native_preset); // plan v0.3 P6: a native pack may take its experts from shard 1// On the multi-GPU Windows experiment, start with at most 8 GiB of mapped host pages.@@ -3142,7 +3163,7 @@ int main(int argc, char** argv) {by memcpy API to ensure synchronization behavior.*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(- d_res, host_res.data(), host_res.size() * sizeof(int32_t))) !=+ d_res, host_res.data(), host_res.size() * sizeof(int32_t)).wait()) !=0) {std::fprintf(stderr, "strata generate: the device residency table could not be staged\n");return 1;@@ -3162,7 +3183,7 @@ int main(int argc, char** argv) {*/DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(st->d_res, host_res.data(),- host_res.size() * sizeof(int32_t))) != 0) {+ host_res.size() * sizeof(int32_t)).wait()) != 0) {std::fprintf(stderr, "strata generate: layer split: CUDA%d residency table failed\n", st->dev);return 1;}@@ -3621,7 +3642,7 @@ int main(int argc, char** argv) {return by memcpy API to ensure synchronization behavior.*/dpct::get_in_order_queue().memcpy(- d_res, host_res.data(), host_res.size() * sizeof(int32_t));+ d_res, host_res.data(), host_res.size() * sizeof(int32_t)).wait();for (auto& st : stages) {const strata::core::OnDevice on(st->dev);dpct::get_in_order_queue()@@ -5135,7 +5156,7 @@ int main(int argc, char** argv) {return by memcpy API to ensure synchronization behavior.*/dpct::get_in_order_queue().memcpy(- d_res, host_res.data(), host_res.size() * sizeof(int32_t));+ d_res, host_res.data(), host_res.size() * sizeof(int32_t)).wait();}catch (sycl::exception const &exc) {std::cerr << exc.what() << "Exception caught at file:" << __FILE__diff --git a/sycl/tools/build.sh b/sycl/tools/build.shindex 5afd559fd..1858bd51b 100644--- a/sycl/tools/build.sh+++ b/sycl/tools/build.sh@@ -6,7 +6,7 @@ repo=${REPO:-/work/Strata_B70}b=$repo/build-sycl[ -f $b/build.ninja ] || cmake -S $repo/sycl -B $b -G Ninja -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx \-DSTRATA_SYCL_AOT="${AOT:-}" 2>&1 | tail -15-cmake --build $b -j ${JOBS:-12} "$@" -- -k 0 2>&1 | tee $b/build.log | grep -E '^FAILED|error:|^ninja: build stopped|Linking|^\[[0-9]+/[0-9]+\] Linking' | tail -40+cmake --build $b -j ${JOBS:-12} ${1:+--target "$@"} -- -k 0 2>&1 | tee $b/build.log | grep -E '^FAILED|error:|^ninja: build stopped|Linking|^\[[0-9]+/[0-9]+\] Linking' | tail -40echo "BUILD EXIT ${PIPESTATUS[0]}"grep -c 'error:' $b/build.log | sed 's/^/errors: /'grep -E '^FAILED' $b/build.log | sed 's#.*/##' | sort | uniq | head -60diff --git a/sycl/tools/fixups.py b/sycl/tools/fixups.pyindex 6b09af3ae..96a5300ea 100644--- a/sycl/tools/fixups.py+++ b/sycl/tools/fixups.py@@ -69,6 +69,55 @@ for rel in all_sources():edit("src/kernels/cuda/s_gemv.dp.cpp", lambda s: s.replace("const float d = *blk;", "const float d = *(const float*) blk;").replace("Q8K ? *xb", "Q8K ? *(const float*) xb"))+# 7c. the doorbell: `volatile` device loads/stores of host-mapped flags do not bypass the GPU caches on Intel+# (the spin never saw the host's write). System-scope atomic load/store do (include/strata/sycl_doorbell.hpp).+def doorbell(s):+ if "sycl_doorbell.hpp" not in s:+ s = s.replace('#include "strata/sycl_queue.hpp"\n', '#include "strata/sycl_queue.hpp"\n#include "strata/sycl_doorbell.hpp"\n', 1)+ s = s.replace(" *seq = *seq + 1u;", " strata::sys_store(seq, strata::sys_load(seq) + 1u);")+ s = s.replace(" const uint32_t want = *seq;\n", " const uint32_t want = strata::sys_load(seq);\n")+ s = s.replace(" while (*flag != want) /* spin (no __nanosleep on SYCL) */;", " while (strata::sys_load(flag) != want) /* spin (no __nanosleep on SYCL) */;")+ s = s.replace(" while (*flag < value) /* spin (no __nanosleep on SYCL) */;", " while (strata::sys_load(flag) < value) /* spin (no __nanosleep on SYCL) */;")+ s = s.replace(" if (*skip == value) return;", " if (strata::sys_load(skip) == value) return;")+ s = s.replace(" *skip = ring;\n}", " strata::sys_store(skip, ring);\n}")+ s = s.replace(" *(volatile uint32_t*) seq = *(volatile uint32_t*) seq + 1u;", " strata::sys_store(seq, strata::sys_load(seq) + 1u);")+ # bounded spins (see kSpinMax in sycl_doorbell.hpp)+ s = s.replace(" while (strata::sys_load(flag) != want) /* spin (no __nanosleep on SYCL) */;",+ " for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) != want; ++spin) {}")+ s = s.replace(" while (strata::sys_load(flag) < value) /* spin (no __nanosleep on SYCL) */;",+ " for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) < value; ++spin) {}")+ return s+edit("src/kernels/cuda/elementwise.dp.cpp", doorbell)+edit("src/kernels/cuda/verify_kernels.dp.cpp", doorbell)++# 7d. cudaMemcpy / cudaMemset are synchronous; dpct emitted `get_in_order_queue().memcpy(...)` with no wait where+# the source was pageable ("call wait() if needed"). The streaming expert source hands out ring-buffer blobs,+# so an unwaited fill copies from a buffer that has already been reused (measured: non-deterministic experts).+# Every default-queue memcpy/memset that is not already waited on gets its .wait() back.+def wait_default_queue_copies(s):+ out = []; i = 0; n = 0+ key = "dpct::get_in_order_queue()."+ while True:+ j = s.find(key, i)+ if j < 0: out.append(s[i:]); break+ k = j + len(key)+ if not (s.startswith("memcpy(", k) or s.startswith("memset(", k)):+ out.append(s[i:k]); i = k; continue+ p0 = s.find("(", k); depth = 0; q = p0+ while q < len(s):+ if s[q] == "(": depth += 1+ elif s[q] == ")":+ depth -= 1+ if depth == 0: break+ q += 1+ tail = s[q + 1:q + 8]+ if tail.startswith(".wait()"):+ out.append(s[i:q + 1]); i = q + 1; continue+ out.append(s[i:q + 1]); out.append(".wait()"); i = q + 1; n += 1+ return "".join(out)+for rel in all_sources():+ edit(str(rel), wait_default_queue_copies)+# 8. ggml-common.h has a SYCL declaration mode (sycl::half instead of cuda_fp16.h).edit("src/kernels/cuda/iq_kernels.dp.cpp", lambda s: s.replace("#define GGML_COMMON_DECL_CUDA", "#define GGML_COMMON_DECL_SYCL").replace("#define GGML_COMMON_IMPL_CUDA", "#define GGML_COMMON_IMPL_SYCL"))