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: refresh the port for upstream 0.1.25-0.1.27 (re-migration merge), AOT divide rounding, hybrid K8V4 KV
maxfridbeb88eff688b53
diff --git a/docs/INTEL.md b/docs/INTEL.mdindex c8e3e8ffa..6d5e7e037 100644--- a/docs/INTEL.md+++ b/docs/INTEL.md@@ -151,6 +151,7 @@ need model fixtures (`iq_parity`, `ple_parity`) or the tensor-core kernel below| bf16_gemv, cvec, dequant_s2, elementwise, gdn, gr, kv_q4, kv_q8, kv_stream, qsa, quantize_act, rope, router_top10, s2_gemv, s2_gemv_q8, s_gemv, s_gemv_q8k, sampler, shared_expert | pass || iq_parity, ple_parity | need fixtures (a `logs/iq_fixture` directory, a Q2_0 shard) || qsa_prompt_attn_parity | needs the tensor-core kernel (below) |+| kv_hybrid_parity (0.1.27, hybrid K8V4 KV) | appends, gathers and attention pass; its last step is that same tensor-core kernel |**The engine end to end (2026-09-29, later the same day).** It generates. Prompt "Write a Python functionthat returns the n-th Fibonacci number", greedy, 64 tokens:@@ -223,6 +224,23 @@ the engine plus `sycl/rank_kernels.py` gives device time per kernel. `mmvq_benchNATIVE_BENCH=1` time the two hot kernel families in isolation (warm the clocks first: a 5 ms run measuresthe ramp, not the kernel).+**Keeping up with upstream.** A merge of upstream `main` into `b70` leaves the copies in `sycl/` behind+wherever upstream touched a file they mirror. They are refreshed by re-migration, not by hand (done for+0.1.25-0.1.27, 2026-09-30):++1. Merge upstream into `b70` and resolve `setup.py` (the Intel path lives beside upstream's AMD one).+2. Migrate the *old* upstream tree (a `git archive` of the pre-merge commit) with `migrate.sh` into+ `sycl-base`, and the merged tree into `sycl-new`; about 3 minutes each in the dev image.+3. `sycl/tools/normalize.sh <dir> <commit>` on both: dpct's file names, the unchanged files, the+ message serials, then `fixups.py`. Two runs of dpct on the same source now differ only in the kernel+ name hashes it generates.+4. For every file present in both: `git merge-file sycl/F sycl-base/F sycl-new/F`. Files upstream did not+ change are left alone. Copies dpct never produced (`verify.cpp`, `mtp.cpp`, `remote_experts.cpp`+ include no CUDA header directly) take upstream's diff by hand; new parity tests are copied in and+ listed in `sycl/CMakeLists.txt`.+5. A fixup whose pattern upstream changed shows up as a compile error (the PTX gate became an `#elif`+ under upstream's `__HIPCC__` guard); extend the fixup, re-run it, rebuild.+**Not ported yet.**- Three kernels carry inline PTX (`mma.sync` tensor-core matrix ops, `ldmatrix`, `cp.async`):diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txtindex 5b260f1e9..2ab04dda0 100644--- a/sycl/CMakeLists.txt+++ b/sycl/CMakeLists.txt@@ -24,15 +24,20 @@ set(STRATA_SYCL_AOT "" CACHE STRING "AOT device for the GPU code, e.g. bmg-g31 (set(_sycl_flags -fsycl)if(STRATA_SYCL_AOT)list(APPEND _sycl_flags -fsycl-targets=spir64_gen)- set(_sycl_link -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device ${STRATA_SYCL_AOT}")+ # the divide/sqrt rounding option (below) must reach ocloc here: an AOT build has no spir64 backend to take it+ set(_sycl_link -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen+ "-device ${STRATA_SYCL_AOT} -options -cl-fp32-correctly-rounded-divide-sqrt")else()set(_sycl_link -fsycl)endif()# The Intel GPU's fp32 divide is not correctly rounded by default (OpenCL allows 2.5 ulp). Strata's quantizers# are byte-exact against ggml through `amax / 127`, so the device compiler is told to round divides and sqrt# properly; measured: quantize_act_parity goes from 303k mismatches to byte-exact. (Same as-# SYCL_PROGRAM_COMPILE_OPTIONS=-cl-fp32-correctly-rounded-divide-sqrt at run time.)-list(APPEND _sycl_link "-Xsycl-target-backend=spir64" "-cl-fp32-correctly-rounded-divide-sqrt")+# SYCL_PROGRAM_COMPILE_OPTIONS=-cl-fp32-correctly-rounded-divide-sqrt at run time.) The AOT build passes it to+# ocloc above; without that the 303k mismatches came back on 2026-09-30, unnoticed since the AOT switch.+if(NOT STRATA_SYCL_AOT)+ list(APPEND _sycl_link "-Xsycl-target-backend=spir64" "-cl-fp32-correctly-rounded-divide-sqrt")+endif()# 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.@@ -175,6 +180,12 @@ 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)+ # the hybrid K8V4 KV test (upstream 0.1.27) passes its appends, gathers and attention here and fails only its+ # last step, the same tensor-core prompt kernel. Built, not registered, until that kernel is ported.+ strata_resolve(_src src/kernels/kv_hybrid_parity.cpp)+ add_executable(kv_hybrid_parity ${_src})+ target_include_directories(kv_hybrid_parity PRIVATE ${STRATA_ROOT}/src/kernels)+ target_link_libraries(kv_hybrid_parity PRIVATE strata_kernels)add_executable(mmvq_bench ${CMAKE_CURRENT_SOURCE_DIR}/src/kernels/mmvq_bench.cpp) # dense mmvq timingtarget_link_libraries(mmvq_bench PRIVATE strata_kernels)# one native expert three ways on real GGUF rows (ggml reference, CPU path, GPU native_expert_grouped):diff --git a/sycl/include/strata/core/mtp.hpp b/sycl/include/strata/core/mtp.hppindex 6469dbb52..52847e1d8 100644--- a/sycl/include/strata/core/mtp.hpp+++ b/sycl/include/strata/core/mtp.hpp@@ -73,6 +73,26 @@ public:double ms_draft = 0, ms_prefill = 0;int64_t rounds = 0;+ /// E-9: the prompt path computes this layer's prompt K/V in batches (Prefill::draft_kv): its tensors, its K/V+ /// state, the first cell a round can still read, its device, and a wait for its own stream.+ const float* tensor_f32(const char* name) const { return f32(name); }+ const uint16_t* tensor_bf16(const char* name) const { return bf16(name); }+ const void* tensor_q8(const char* name) const { return q8(name); }+ QsaState& kv_state_rw() { return st_; }+ int64_t first_needed() const { return (window_ > 0 && prompt_len_ > 0) ? prompt_len_ - window_ - 64 : 0; }+ int device() const { return device_; }+ bool idle(std::string &err) try {+ if (cs_ && DPCT_CHECK_ERROR(cs_->wait()) != 0) {+ err = "mtp: its stream failed"; return false;+ }+ return true;+ }+ catch (sycl::exception const &exc) {+ std::cerr << exc.what() << "Exception caught at file:" << __FILE__+ << ", line:" << __LINE__ << std::endl;+ std::exit(1);+ }+private:bool record_forward(int T, int step_row0, dpct::queue_ptr cs,std::string &err);diff --git a/sycl/include/strata/core/on_device.hpp b/sycl/include/strata/core/on_device.hppindex b6c620bb8..ee2d7b3b3 100644--- a/sycl/include/strata/core/on_device.hpp+++ b/sycl/include/strata/core/on_device.hpp@@ -13,7 +13,7 @@ struct OnDevice {explicit OnDevice(int device) try {int cur = 0;/*- DPCT1093:7: The "device" device may be not the one intended for use.+ DPCT1093: The "device" device may be not the one intended for use.Adjust the selected device if needed.*/if (device >= 0 &&@@ -27,7 +27,7 @@ struct OnDevice {std::exit(1);}/*- DPCT1093:8: The "previous" device may be not the one intended for use.+ DPCT1093: The "previous" device may be not the one intended for use.Adjust the selected device if needed.*/~OnDevice() { if (previous >= 0) dpct::select_device(previous); }diff --git a/sycl/include/strata/kernels/bf16_bits.hpp b/sycl/include/strata/kernels/bf16_bits.hppindex 11a85f28b..a315a8343 100644--- a/sycl/include/strata/kernels/bf16_bits.hpp+++ b/sycl/include/strata/kernels/bf16_bits.hpp@@ -22,7 +22,7 @@#include <cstdint>#include <cstring>-#if defined(SYCL_LANGUAGE_VERSION)+#if defined(SYCL_LANGUAGE_VERSION) || defined(__HIPCC__)#define STRATA_BF16_HD#else#define STRATA_BF16_HD@@ -33,7 +33,11 @@ namespace strata::kernels {/// Round-to-nearest-even f32 -> bf16, returned as raw bits in the LOW half of the uint16.STRATA_BF16_HD inline uint16_t bf16_from_f32(float f) {uint32_t i;+#if defined(__HIP_DEVICE_COMPILE__)+ __builtin_memcpy(&i, &f, 4);+#elsestd::memcpy(&i, &f, 4);+#endifi = (i + ((i >> 16) & 1u) + 0x7FFFu) & 0xFFFF0000u;return (uint16_t) (i >> 16);}@@ -42,7 +46,11 @@ STRATA_BF16_HD inline uint16_t bf16_from_f32(float f) {STRATA_BF16_HD inline float f32_from_bf16(uint16_t h) {const uint32_t i = (uint32_t) h << 16;float f;+#if defined(__HIP_DEVICE_COMPILE__)+ __builtin_memcpy(&f, &i, 4);+#elsestd::memcpy(&f, &i, 4);+#endifreturn f;}diff --git a/sycl/include/strata/kernels/f16_bits.hpp b/sycl/include/strata/kernels/f16_bits.hppindex 3ac2a5245..cd5625f69 100644--- a/sycl/include/strata/kernels/f16_bits.hpp+++ b/sycl/include/strata/kernels/f16_bits.hpp@@ -28,7 +28,7 @@#include <cstdint>#include <cstring>-#if defined(SYCL_LANGUAGE_VERSION)+#if defined(SYCL_LANGUAGE_VERSION) || defined(__HIPCC__)#define STRATA_HD#else#define STRATA_HD@@ -39,7 +39,11 @@ namespace strata::kernels {/// Round-to-nearest-even f32 -> fp16, returned as raw bits.STRATA_HD inline uint16_t f16_from_f32(float f) {uint32_t x;+#if defined(__HIP_DEVICE_COMPILE__)+ __builtin_memcpy(&x, &f, 4);+#elsestd::memcpy(&x, &f, 4);+#endifconst uint32_t sign = (x >> 16) & 0x8000u;const uint32_t rawexp = (x >> 23) & 0xFFu;int exp = (int) rawexp - 127 + 15;@@ -92,7 +96,11 @@ STRATA_HD inline float f32_from_f16(uint16_t h) {out = sign | ((ex - 15 + 127) << 23) | (man << 13);}float f;+#if defined(__HIP_DEVICE_COMPILE__)+ __builtin_memcpy(&f, &out, 4);+#elsestd::memcpy(&f, &out, 4);+#endifreturn f;}diff --git a/sycl/include/strata/kernels/mrope.hpp b/sycl/include/strata/kernels/mrope.hppindex 11fcfe1e0..fecd37378 100644--- a/sycl/include/strata/kernels/mrope.hpp+++ b/sycl/include/strata/kernels/mrope.hpp@@ -25,12 +25,12 @@ namespace strata::kernels {void mrope_table_set(const int32_t* device_table);const int32_t* mrope_table();-#if defined(SYCL_LANGUAGE_VERSION)+#if defined(SYCL_LANGUAGE_VERSION) || defined(__HIPCC__)/// ggml rope_multi, is_imrope, sections {11, 11, 10, 0}: sector = pair % 32; sector % 3 == 1 -> h (sector < 33),/// == 2 -> w (sector < 30), == 0 -> t (sector < 33). For pairs 0..31 all three bounds hold, so it is pair % 3.__dpct_inline__ int mrope_pos(const int32_t *tab, int pos, int pair) {/*- DPCT1098:387: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/diff --git a/sycl/include/strata/kernels/rope.hpp b/sycl/include/strata/kernels/rope.hppindex 5b2627487..be6a53bdc 100644--- a/sycl/include/strata/kernels/rope.hpp+++ b/sycl/include/strata/kernels/rope.hpp@@ -13,7 +13,7 @@#include <dpct/dpct.hpp>#include <cstdint>-#if defined(SYCL_LANGUAGE_VERSION)+#if defined(SYCL_LANGUAGE_VERSION) || defined(__HIPCC__)#define STRATA_ROPE_HD#else#define STRATA_ROPE_HDdiff --git a/sycl/src/core/concurrent_main.cpp b/sycl/src/core/concurrent_main.cppindex 599e98be1..8fb792b07 100644--- a/sycl/src/core/concurrent_main.cpp+++ b/sycl/src/core/concurrent_main.cpp@@ -111,7 +111,7 @@ int main(int argc, char** argv) {std::vector<uint16_t> hx((size_t) n_in, 0x3C00);std::vector<float> hs((size_t) n_out * (size_t) (n_in / 64), 0.001f);/*- DPCT1114:922: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -120,7 +120,7 @@ int main(int argc, char** argv) {d_x, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"copy x");/*- DPCT1114:923: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -158,7 +158,7 @@ int main(int argc, char** argv) {check(DPCT_CHECK_ERROR(ev[b] = new sycl::event()), "event");uint8_t* buf[2] = {d_codes, d_codes}; // one buffer is enough: the timing is what is measured/*- DPCT1124:924: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -167,7 +167,7 @@ int main(int argc, char** argv) {DPCT_CHECK_ERROR(s_copy->memcpy(buf[0], arena.data(), role_codes)),"prologue");/*- DPCT1024:925: The original code returned the error code that was further+ DPCT1024: The original code returned the error code that was furtherconsumed by the program logic. This original code was replaced with 0.You may need to rewrite the program logic consuming the error code.*/@@ -177,7 +177,7 @@ int main(int argc, char** argv) {const int cur = i & 1, nxt = (i + 1) & 1;if (i + 1 < roles) {/*- DPCT1124:926: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends onthe type of operand memory, so you may need to call wait() onevent return by memcpy API to ensure synchronization behavior.@@ -189,7 +189,7 @@ int main(int argc, char** argv) {role_codes)),"copy");/*- DPCT1024:927: The original code returned the error code that was+ DPCT1024: The original code returned the error code that wasfurther consumed by the program logic. This original code wasreplaced with 0. You may need to rewrite the program logicconsuming the error code.diff --git a/sycl/src/core/device.dp.cpp b/sycl/src/core/device.dp.cppindex ce679dd6c..d72b556a5 100644--- a/sycl/src/core/device.dp.cpp+++ b/sycl/src/core/device.dp.cpp@@ -13,17 +13,17 @@ namespace {void check(dpct::err0 e, const char *what) {/*- DPCT1000:1125: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:1126: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:1124: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw CudaError(std::string(what) + ": " + dpct::get_error_string_dummy(e), (int)e);@@ -47,7 +47,11 @@ DeviceInfo device_info(int ordinal) {int count = 0;check(DPCT_CHECK_ERROR(count = dpct::device_count()), "cudaGetDeviceCount");if (count == 0) {- throw CudaError("no CUDA device is present; Strata needs an NVIDIA GPU of compute capability 8.0 or newer", -1);+#if defined(STRATA_USE_HIP)+ throw CudaError("no HIP device is present; this backend targets gfx1100 wave32", -1);+#else+ throw CudaError("no CUDA device is present; Strata needs an NVIDIA GPU (RTX 20 series or newer)", -1);+#endif}if (ordinal < 0 || ordinal >= count) {throw CudaError("device ordinal " + std::to_string(ordinal) + " is out of range (have " +@@ -57,7 +61,7 @@ DeviceInfo device_info(int ordinal) {DeviceInfo d;d.ordinal = ordinal;/*- DPCT1093:1127: The "ordinal" device may be not the one intended for use.+ DPCT1093: The "ordinal" device may be not the one intended for use.Adjust the selected device if needed.*/check(DPCT_CHECK_ERROR(dpct::select_device(ordinal)), "cudaSetDevice");@@ -67,12 +71,12 @@ DeviceInfo device_info(int ordinal) {"cudaGetDeviceProperties");d.name = p.get_name();/*- DPCT1005:1128: The SYCL device version is different from CUDA Compute+ DPCT1005: The SYCL device version is different from CUDA ComputeCompatibility. You may need to rewrite this code.*/d.cc_major = p.get_major_version();/*- DPCT1005:1129: The SYCL device version is different from CUDA Compute+ DPCT1005: The SYCL device version is different from CUDA ComputeCompatibility. You may need to rewrite this code.*/d.cc_minor = p.get_minor_version();@@ -80,7 +84,7 @@ DeviceInfo device_info(int ordinal) {size_t free_b = 0, total_b = 0;/*- DPCT1106:1130: 'cudaMemGetInfo' was migrated with the Intel extensions for+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensions fordevice information which may not be supported by all compilers or runtimes.You may need to adjust the code.*/@@ -91,30 +95,37 @@ DeviceInfo device_info(int ordinal) {d.total_bytes = total_b;/*- DPCT1043:1131: The version-related API is different in SYCL. An initial code+ DPCT1043: The version-related API is different in SYCL. An initial codewas generated, but you need to adjust it.*/check(DPCT_CHECK_ERROR(d.driver_version = dpct::get_major_version(dpct::get_current_device())),"cudaDriverGetVersion");/*- DPCT1043:1132: The version-related API is different in SYCL. An initial code+ DPCT1043: The version-related API is different in SYCL. An initial codewas generated, but you need to adjust it.*/check(DPCT_CHECK_ERROR(d.runtime_version = dpct::get_major_version(dpct::get_current_device())),"cudaRuntimeGetVersion");- // The kernels need sm_80 or newer (tf32 mma in the attention scorer, bf16 math) - the same floor the- // arch guard in CMakeLists enforces at build time (RTX 30 / 40 / 50). Anything older is caught here,- // because a binary can be carried to a machine with an older card and would otherwise silently take- // whatever path the driver chose. Pre-Blackwell is untested by the author; trust, then verify.- if (d.cc_major < 8) {+ // The engine supports compute capability 7.5 and newer (Turing: the QSA scorer's tf32 mma has a portable+ // fp32-FMA fallback below sm_80, the tensor-core prompt kernels refuse and fall back). Compiling for a+ // supported arch is enforced by CMake; RUNNING on an older card is caught here, because a binary can be carried+ // to a machine with an older card and would otherwise silently take whatever path the driver chose. The HIP+ // backend is validated on gfx1100 (wave32) only.+#if defined(STRATA_USE_HIP)+ if (std::strncmp(p.gcnArchName, "gfx1100", 7) != 0 || p.warpSize != 32) {+ throw CudaError("HIP backend requires validated gfx1100 wave32 hardware", -1);+ }+#else+ if (d.cc_major * 10 + d.cc_minor < 75) {throw CudaError("device " + d.name + " reports compute capability " + std::to_string(d.cc_major) +"." + std::to_string(d.cc_minor) +- "; Strata needs an NVIDIA GPU of compute capability 8.0 or newer (RTX 30 / 40 / 50)",+ "; Strata needs compute capability 7.5 or newer (RTX 20 / 30 / 40 / 50 series)",-1);}+#endifreturn d;}@@ -122,7 +133,7 @@ DeviceArena::DeviceArena(uint64_t bytes, int ordinal, bool poison): capacity_(bytes), ordinal_(ordinal), poison_(poison) {if (bytes == 0) throw CudaError("DeviceArena of 0 bytes", -1);/*- DPCT1093:1133: The "ordinal" device may be not the one intended for use.+ DPCT1093: The "ordinal" device may be not the one intended for use.Adjust the selected device if needed.*/check(DPCT_CHECK_ERROR(dpct::select_device(ordinal)), "cudaSetDevice");@@ -150,7 +161,7 @@ DeviceArena::DeviceArena(uint64_t bytes, int ordinal, bool poison)auto n_b_threads_ct1 = n - b * threads;cgh.parallel_for<- dpct_kernel_name<class poison_kernel_cca729>>(+ dpct_kernel_name<class poison_kernel_58fc0a>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)chunk) *sycl::range(1, 1, threads),sycl::range(1, 1, threads)),@@ -161,7 +172,7 @@ DeviceArena::DeviceArena(uint64_t bytes, int ordinal, bool poison)});}/*- DPCT1010:1134: SYCL uses exceptions to report errors and does not+ DPCT1010: SYCL uses exceptions to report errors and does notuse the error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/diff --git a/sycl/src/core/expert_cache.cpp b/sycl/src/core/expert_cache.cppindex 752bebab2..32e167307 100644--- a/sycl/src/core/expert_cache.cpp+++ b/sycl/src/core/expert_cache.cpp@@ -71,6 +71,22 @@ bool read_expert_profile(const std::string& path, int64_t n_layers, int64_t n_exExpertCache::~ExpertCache() { close(); }+#if defined(STRATA_USE_HIP)+bool ExpertCache::ensure_blocking_staging(std::size_t bytes, std::string& err) {+ if (bytes <= blocking_staging_bytes_) return true;+ void* next = nullptr;+ const cudaError_t status = cudaHostAlloc(&next, bytes, cudaHostAllocDefault);+ if (status != cudaSuccess) {+ err = std::string("ExpertCache: HIP blocking staging allocation: ") + cudaGetErrorString(status);+ return false;+ }+ if (blocking_staging_) (void) cudaFreeHost(blocking_staging_);+ blocking_staging_ = static_cast<uint8_t*>(next);+ blocking_staging_bytes_ = bytes;+ return true;+}+#endif+bool ExpertCache::open(int64_t n_slots, int64_t n_layers, int64_t n_expert,int64_t blob_bytes, std::string &err) try {close();@@ -93,7 +109,7 @@ bool ExpertCache::open(int64_t n_slots, int64_t n_layers, int64_t n_expert,// and the two numbers are named in the refusal.size_t free_b = 0, total_b = 0;/*- DPCT1106:759: 'cudaMemGetInfo' was migrated with the Intel extensions for+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensions fordevice information which may not be supported by all compilers or runtimes.You may need to adjust the code.*/@@ -119,12 +135,12 @@ bool ExpertCache::open(int64_t n_slots, int64_t n_layers, int64_t n_expert,std::snprintf(buf, sizeof buf, "ExpertCache: cudaMalloc(%.2f GiB) failed: %s",/*- DPCT1009:760: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1010:761: SYCL uses exceptions to report errors and does not use+ DPCT1010: SYCL uses exceptions to report errors and does not usethe error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/@@ -147,6 +163,12 @@ bool ExpertCache::open(int64_t n_slots, int64_t n_layers, int64_t n_expert,n_layers_ = n_layers;n_expert_ = n_expert;blob_ = blob_bytes;+#if defined(STRATA_USE_HIP)+ if (!ensure_blocking_staging((std::size_t) blob_, err)) {+ close();+ return false;+ }+#endifnext_free_ = 0;fills_ = 0;admitted_ = 0;@@ -181,11 +203,22 @@ bool ExpertCache::open_sized(const std::vector<int64_t>& slot_bytes, int64_t n_lslots_ = (int64_t) slot_bytes.size();blob_ = mx;off_ = std::move(off);+#if defined(STRATA_USE_HIP)+ if (!ensure_blocking_staging((std::size_t) blob_, err)) {+ close();+ return false;+ }+#endiflayer_next_.assign((size_t) (n_layers > 0 ? n_layers : 0), 0);return true;}void ExpertCache::close() {+#if defined(STRATA_USE_HIP)+ if (blocking_staging_) (void) cudaFreeHost(blocking_staging_);+ blocking_staging_ = nullptr;+ blocking_staging_bytes_ = 0;+#endifoff_.clear();if (base_ != nullptr) {sycl::free(base_, dpct::get_in_order_queue());@@ -264,7 +297,7 @@ bool ExpertCache::fill_slot(int32_t slot, const uint8_t *host_blob,return false;}/*- DPCT1124:764: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -272,17 +305,17 @@ bool ExpertCache::fill_slot(int32_t slot, const uint8_t *host_blob,const dpct::err0 e =DPCT_CHECK_ERROR(strata::q_of(stream)->memcpy(dst, host_blob, n));/*- DPCT1000:763: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:765: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:762: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("ExpertCache::fill_slot: ") +dpct::get_error_string_dummy(e);@@ -309,26 +342,37 @@ bool ExpertCache::fill_slot_blocking(int32_t slot, const uint8_t *host_blob,err = "ExpertCache::fill_slot_blocking: the host blob is null";return false;}+#if defined(STRATA_USE_HIP)+ // Bound HIP's pageable-source staging to one expert instead of repeatedly+ // registering regions of the mmap. The blocking copy completes before reuse.+ if (!blocking_staging_ || n > blocking_staging_bytes_) {+ err = "ExpertCache::fill_slot_blocking: HIP staging buffer is too small";+ return false;+ }+ std::memcpy(blocking_staging_, host_blob, n);+ const cudaError_t e = cudaMemcpy(dst, blocking_staging_, n, cudaMemcpyHostToDevice);+#else/*- DPCT1114:768: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.*/const dpct::err0 e =DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(dst, host_blob, n).wait());+#endif/*- DPCT1000:767: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:769: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:766: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("ExpertCache::fill_slot_blocking: ") +dpct::get_error_string_dummy(e);@@ -353,7 +397,7 @@ bool ExpertCache::fill_slot_queued(int32_t slot, const uint8_t *host_blob,return false;}/*- DPCT1124:772: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -361,17 +405,17 @@ bool ExpertCache::fill_slot_queued(int32_t slot, const uint8_t *host_blob,const dpct::err0 e =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 be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:773: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:770: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("ExpertCache::fill_slot_queued: ") +dpct::get_error_string_dummy(e);@@ -389,17 +433,17 @@ catch (sycl::exception const &exc) {bool ExpertCache::sync_queued(std::string &err) try {const dpct::err0 e = DPCT_CHECK_ERROR(dpct::get_in_order_queue().wait());/*- DPCT1000:775: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:776: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:774: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("ExpertCache::sync_queued: ") +dpct::get_error_string_dummy(e);@@ -428,17 +472,17 @@ bool ExpertCache::verify_slot(int32_t slot, const uint8_t *host_blob,const dpct::err0 e = DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(got.data(), src, (size_t)nb).wait());/*- DPCT1000:778: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:779: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:777: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("ExpertCache::verify_slot: ") +dpct::get_error_string_dummy(e);diff --git a/sycl/src/core/expert_source.cpp b/sycl/src/core/expert_source.cppindex 8beed71d6..c61737024 100644--- a/sycl/src/core/expert_source.cpp+++ b/sycl/src/core/expert_source.cpp@@ -19,11 +19,18 @@#include <cstdlib>#include <cstring>#include <fstream>+#include <filesystem>+#include <sstream>+#include <limits>#include <thread>+#include <utility>#include <vector>#if defined(_WIN32)#define WIN32_LEAN_AND_MEAN+#ifndef NOMINMAX+#define NOMINMAX // std::numeric_limits<T>::max() below+#endif#include <windows.h>#else#include <fcntl.h>@@ -34,6 +41,213 @@namespace strata::core {+namespace detail {++bool cgroup_available_bytes(uint64_t limit, const CgroupMemoryStat& stat, uint64_t& bytes) {+ bytes = 0;+ if (!stat.valid) return false;++ // memory.stat's inactive_file can race memory.current, so bound it to charged usage first.+ uint64_t reclaimable = std::min(stat.inactive_file, stat.current);+ reclaimable = stat.file_dirty >= reclaimable ? 0 : reclaimable - stat.file_dirty;+ reclaimable = stat.file_writeback >= reclaimable ? 0 : reclaimable - stat.file_writeback;++ // Reclaiming clean file pages reduces usage; saturating subtraction also handles a transient over-limit read.+ const uint64_t usage_after_reclaim = stat.current - reclaimable;+ bytes = usage_after_reclaim < limit ? limit - usage_after_reclaim : 0;+ return true;+}++bool make_cache_complement_plan(+ int64_t n_layers, int64_t n_expert, const std::vector<uint64_t>& layer_blob_bytes,+ const std::vector<std::pair<int32_t, int32_t>>& primary_gpu_pairs,+ const std::vector<std::pair<int32_t, int32_t>>& additional_gpu_pairs,+ std::vector<uint64_t>& offsets, uint64_t& bytes, std::string& err) {+ offsets.clear();+ bytes = 0;+ err.clear();+ if (n_layers <= 0 || n_expert <= 0 || layer_blob_bytes.size() != (size_t) n_layers) {+ err = "FileExpertSource: invalid geometry for the cache complement plan";+ return false;+ }+ if ((uint64_t) n_layers > (uint64_t) std::numeric_limits<size_t>::max() / (uint64_t) n_expert) {+ err = "FileExpertSource: cache complement index table is too large";+ return false;+ }+ const size_t count = (size_t) n_layers * (size_t) n_expert;+ std::vector<uint8_t> omitted(count, 0);+ auto mark_pairs = [&](const std::vector<std::pair<int32_t, int32_t>>& pairs, uint8_t bit,+ const char* label) -> bool {+ for (const auto& pair : pairs) {+ if (pair.first < 0 || pair.second < 0 || pair.first >= n_layers || pair.second >= n_expert) {+ err = std::string("FileExpertSource: ") + label + " pair is outside the expert geometry";+ return false;+ }+ const size_t index = (size_t) pair.first * (size_t) n_expert + (size_t) pair.second;+ if ((omitted[index] & bit) != 0) {+ err = std::string("FileExpertSource: duplicate ") + label + " pair in the cache complement plan";+ return false;+ }+ if (bit == 2 && (omitted[index] & 1) != 0) {+ err = "FileExpertSource: the primary and additional GPU expert tiers overlap";+ return false;+ }+ omitted[index] |= bit;+ }+ return true;+ };+ if (!mark_pairs(primary_gpu_pairs, 1, "primary GPU") ||+ !mark_pairs(additional_gpu_pairs, 2, "additional GPU")) return false;+ for (uint64_t blob_bytes : layer_blob_bytes) {+ if (blob_bytes == 0) {+ err = "FileExpertSource: cache complement layer has zero-sized expert blobs";+ return false;+ }+ }++ offsets.assign(count, kNoCacheComplement);+ for (int64_t layer = 0; layer < n_layers; ++layer) {+ const uint64_t blob_bytes = layer_blob_bytes[(size_t) layer];+ for (int64_t expert = 0; expert < n_expert; ++expert) {+ const size_t index = (size_t) layer * (size_t) n_expert + (size_t) expert;+ if (omitted[index] != 0) continue;+ if (bytes > std::numeric_limits<uint64_t>::max() - blob_bytes) {+ offsets.clear();+ bytes = 0;+ err = "FileExpertSource: cache complement size overflows";+ return false;+ }+ offsets[index] = bytes;+ bytes += blob_bytes;+ }+ }+ if (bytes > (uint64_t) std::numeric_limits<size_t>::max()) {+ offsets.clear();+ bytes = 0;+ err = "FileExpertSource: cache complement exceeds the host address space";+ return false;+ }+ return true;+}++const uint8_t* cache_complement_blob_or_fallback(+ size_t index, const std::vector<uint64_t>& offsets, const uint8_t* complement_host,+ const uint8_t* mapped_fallback) {+ if (complement_host != nullptr && index < offsets.size() && offsets[index] != kNoCacheComplement)+ return complement_host + (size_t) offsets[index];+ return mapped_fallback;+}++} // namespace detail++namespace {+constexpr uint64_t kPinnedMemoryHeadroom = 8ull << 30;++#if defined(__linux__)+bool read_cgroup_memory_stat(const std::filesystem::path& path, uint64_t current,+ detail::CgroupMemoryStat& stat) {+ std::ifstream input(path / "memory.stat");+ if (!input) return false;++ bool inactive_file = false, file_dirty = false, file_writeback = false;+ std::string line;+ while (std::getline(input, line)) {+ std::istringstream fields(line);+ std::string key;+ uint64_t value = 0;+ if (!(fields >> key >> value)) return false;+ fields >> std::ws;+ if (!fields.eof()) return false;++ if (key == "inactive_file") {+ if (inactive_file) return false;+ inactive_file = true;+ stat.inactive_file = value;+ } else if (key == "file_dirty") {+ if (file_dirty) return false;+ file_dirty = true;+ stat.file_dirty = value;+ } else if (key == "file_writeback") {+ if (file_writeback) return false;+ file_writeback = true;+ stat.file_writeback = value;+ }+ }+ if (!input.eof() || !inactive_file || !file_dirty || !file_writeback) return false;+ stat.current = current;+ stat.valid = true;+ return true;+}+#endif++bool available_memory_bytes(uint64_t& bytes) {+#if defined(_WIN32)+ MEMORYSTATUSEX status{};+ status.dwLength = sizeof(status);+ if (!GlobalMemoryStatusEx(&status)) return false;+ bytes = (uint64_t) status.ullAvailPhys;+ return bytes > 0;+#elif defined(__linux__)+ // MemAvailable includes reclaimable page cache, unlike _SC_AVPHYS_PAGES.+ std::ifstream info("/proc/meminfo");+ std::string line;+ bytes = 0;+ while (std::getline(info, line)) {+ std::istringstream fields(line);+ std::string key, unit;+ uint64_t value = 0;+ if (fields >> key >> value >> unit && key == "MemAvailable:" && unit == "kB" &&+ value <= std::numeric_limits<uint64_t>::max() / 1024) bytes = value * 1024;+ }+ if (bytes == 0) return false;+ // Account for the tightest cgroup-v2 ancestor limit when its normal mount is visible.+ // This is a point-in-time guard, not a reservation against concurrent allocations.+ std::ifstream groups("/proc/self/cgroup");+ if (!groups) return false;+ bool resolved_v2 = false;+ while (std::getline(groups, line)) {+ if (line.rfind("0::/", 0) != 0) continue;+ const std::filesystem::path root("/sys/fs/cgroup");+ auto path = (root / line.substr(4)).lexically_normal();+ if (path.string().rfind(root.string(), 0) != 0 || !std::filesystem::is_directory(path)) return false;+ resolved_v2 = true;+ while (path.string().rfind(root.string(), 0) == 0) {+ std::ifstream limit_file(path / "memory.max"), current_file(path / "memory.current");+ std::string limit;+ uint64_t current = 0;+ const bool readable = bool(limit_file >> limit) && bool(current_file >> current);+ // The host's root cgroup has no memory.max; ordinary child groups must expose their limits.+ if (!readable && !(path == root && !std::filesystem::exists(path / "memory.max") &&+ std::filesystem::exists(path / "cgroup.controllers"))) return false;+ if (readable && limit != "max") {+ try {+ size_t consumed = 0;+ const uint64_t cap = std::stoull(limit, &consumed);+ if (consumed != limit.size()) return false;+ detail::CgroupMemoryStat stat;+ if (!read_cgroup_memory_stat(path, current, stat)) return false;+ uint64_t cgroup_available = 0;+ if (!detail::cgroup_available_bytes(cap, stat, cgroup_available)) return false;+ bytes = std::min(bytes, cgroup_available);+ } catch (...) { return false; }+ }+ if (path == root) break;+ path = path.parent_path();+ }+ }+ return resolved_v2;+#else+ const long pages = sysconf(_SC_AVPHYS_PAGES);+ const long page_bytes = sysconf(_SC_PAGESIZE);+ if (pages <= 0 || page_bytes <= 0 ||+ (uint64_t) pages > std::numeric_limits<uint64_t>::max() / (uint64_t) page_bytes) return false;+ bytes = (uint64_t) pages * (uint64_t) page_bytes;+ return bytes > 0;+#endif+}++} // namespace+// ================================ THE FILE-BACKED SOURCE ================================FileExpertSource::~FileExpertSource() { close(); }@@ -41,9 +255,74 @@ FileExpertSource::~FileExpertSource() { close(); }bool FileExpertSource::open(const std::string& pack_dir, int64_t n_layers, int64_t n_expert, std::string& err) {close();if (n_layers <= 0 || n_expert <= 0) { err = "FileExpertSource: the geometry is empty"; return false; }- n_expert_ = n_expert;- blobs_ = n_layers * n_expert;- const uint64_t want = (uint64_t) blobs_ * (uint64_t) strata::kernels::cpu::BLOB;+ const auto& layout = strata::kernels::cpu::expert_layout();+ if (layout.n_layers != n_layers || layout.n_expert != n_expert) {+ err = "FileExpertSource: the requested geometry does not match the loaded expert layout";+ return false;+ }+ if ((uint64_t) n_layers > (uint64_t) std::numeric_limits<int64_t>::max() / (uint64_t) n_expert) {+ err = "FileExpertSource: the expert count overflows";+ return false;+ }+ const uint64_t blob_count = (uint64_t) n_layers * (uint64_t) n_expert;+ if (blob_count > (uint64_t) std::numeric_limits<int64_t>::max() ||+ (uint64_t) n_layers > (uint64_t) std::numeric_limits<size_t>::max()) {+ err = "FileExpertSource: the expert count overflows";+ return false;+ }++ std::vector<uint64_t> layer_offsets((size_t) n_layers), layer_blob_bytes((size_t) n_layers);+ const uint64_t want = layout.total;+ if (want == 0 || want > (uint64_t) std::numeric_limits<size_t>::max()) {+ err = "FileExpertSource: the loaded expert layout has an invalid size";+ return false;+ }+ if (!layout.native) {+ if (blob_count > std::numeric_limits<uint64_t>::max() / (uint64_t) strata::kernels::cpu::BLOB) {+ err = "FileExpertSource: the canonical expert size overflows";+ return false;+ }+ const uint64_t canonical_size = blob_count * (uint64_t) strata::kernels::cpu::BLOB;+ if (want != canonical_size) {+ err = "FileExpertSource: the canonical expert layout has an inconsistent size";+ return false;+ }+ const uint64_t bytes = (uint64_t) strata::kernels::cpu::BLOB;+ const uint64_t layer_bytes = (uint64_t) n_expert * bytes;+ for (int64_t layer = 0; layer < n_layers; ++layer) {+ layer_offsets[(size_t) layer] = (uint64_t) layer * layer_bytes;+ layer_blob_bytes[(size_t) layer] = bytes;+ }+ } else {+ if (layout.offset.size() != (size_t) n_layers || layout.bytes.size() != (size_t) n_layers ||+ layout.fmt.size() != (size_t) n_layers) {+ err = "FileExpertSource: the native expert layout is incomplete";+ return false;+ }+ uint64_t at = 0;+ for (int64_t layer = 0; layer < n_layers; ++layer) {+ const size_t i = (size_t) layer;+ const uint64_t bytes = (uint64_t) layout.fmt[i].bytes;+ if (layout.offset[i] != at || bytes == 0 || layout.bytes[i] != bytes ||+ bytes > std::numeric_limits<uint64_t>::max() / (uint64_t) n_expert) {+ err = "FileExpertSource: the native expert layout is invalid at layer " + std::to_string(layer);+ return false;+ }+ const uint64_t layer_bytes = bytes * (uint64_t) n_expert;+ if (at > want || layer_bytes > want - at) {+ err = "FileExpertSource: the native expert layout exceeds its declared size at layer " ++ std::to_string(layer);+ return false;+ }+ layer_offsets[i] = layout.offset[i];+ layer_blob_bytes[i] = bytes;+ at += layer_bytes;+ }+ if (at != want) {+ err = "FileExpertSource: the native expert layout has an inconsistent size";+ return false;+ }+ }const std::string path = pack_dir + "/experts.bin";#if defined(_WIN32)@@ -78,10 +357,9 @@ bool FileExpertSource::open(const std::string& pack_dir, int64_t n_layers, int64if ((uint64_t) sz.QuadPart != want) {char buf[400];std::snprintf(buf, sizeof buf,- "FileExpertSource: %s is %llu B but %lld layers x %lld experts x %d B is %llu B - this "- "is not the pack this geometry came from",- path.c_str(), (unsigned long long) sz.QuadPart, (long long) n_layers,- (long long) n_expert, (int) strata::kernels::cpu::BLOB, (unsigned long long) want);+ "FileExpertSource: %s is %llu B but the loaded expert layout requires %llu B - this is not "+ "the pack this geometry came from",+ path.c_str(), (unsigned long long) sz.QuadPart, (unsigned long long) want);CloseHandle(f);err = buf;return false;@@ -107,13 +385,13 @@ bool FileExpertSource::open(const std::string& pack_dir, int64_t n_layers, int64if (fd < 0) { err = "FileExpertSource: cannot open " + path; return false; }struct stat st{};if (fstat(fd, &st) != 0) { ::close(fd); err = "FileExpertSource: cannot stat " + path; return false; }- if ((uint64_t) st.st_size != want) {+ if (st.st_size < 0 || (uint64_t) st.st_size != want) {char buf[400];std::snprintf(buf, sizeof buf,- "FileExpertSource: %s is %llu B but %lld layers x %lld experts x %d B is %llu B - this "- "is not the pack this geometry came from",- path.c_str(), (unsigned long long) st.st_size, (long long) n_layers, (long long) n_expert,- (int) strata::kernels::cpu::BLOB, (unsigned long long) want);+ "FileExpertSource: %s is %llu B but the loaded expert layout requires %llu B - this is not "+ "the pack this geometry came from",+ path.c_str(), (unsigned long long) (st.st_size < 0 ? 0 : st.st_size),+ (unsigned long long) want);::close(fd);err = buf;return false;@@ -123,10 +401,28 @@ bool FileExpertSource::open(const std::string& pack_dir, int64_t n_layers, int64fd_ = fd;base_ = (const uint8_t*) view;#endif+ blobs_ = (int64_t) blob_count;+ n_layers_ = n_layers;+ n_expert_ = n_expert;+ mapped_bytes_ = want;+ layer_offsets_ = std::move(layer_offsets);+ layer_blob_bytes_ = std::move(layer_blob_bytes);return true;}void FileExpertSource::close() {+ if (complement_arena_ != nullptr) {+ if (complement_pinned_)(void) DPCT_CHECK_ERROR(+ sycl::free(complement_arena_, dpct::get_in_order_queue()));+ else std::free(complement_arena_);+ }+ complement_arena_ = nullptr;+ complement_host_ = nullptr;+ complement_device_ = nullptr;+ complement_bytes_ = 0;+ complement_offsets_.clear();+ complement_pinned_ = false;+ complement_ready_ = false;#if defined(_WIN32)if (base_ != nullptr) UnmapViewOfFile((LPCVOID) base_);if (mapping_ != nullptr) CloseHandle((HANDLE) mapping_);@@ -134,27 +430,286 @@ void FileExpertSource::close() {mapping_ = nullptr;file_ = nullptr;#else- if (base_ != nullptr) munmap((void*) base_, (size_t) blobs_ * (size_t) strata::kernels::cpu::BLOB);+ if (base_ != nullptr) munmap((void*) base_, (size_t) mapped_bytes_);if (fd_ >= 0) ::close(fd_);fd_ = -1;#endifbase_ = nullptr;blobs_ = 0;+ n_layers_ = 0;+ n_expert_ = 0;+ mapped_bytes_ = 0;+ layer_offsets_.clear();+ layer_blob_bytes_.clear();reads_ = 0;}+const uint8_t* FileExpertSource::mapped_blob(int64_t layer, int64_t expert) const {+ if (base_ == nullptr || layer < 0 || expert < 0 || layer >= n_layers_ || expert >= n_expert_) return nullptr;+ const size_t i = (size_t) layer;+ if (i >= layer_offsets_.size() || i >= layer_blob_bytes_.size()) return nullptr;+ const uint64_t blob_bytes = layer_blob_bytes_[i];+ if (blob_bytes == 0 || (uint64_t) expert > std::numeric_limits<uint64_t>::max() / blob_bytes) return nullptr;+ const uint64_t expert_offset = (uint64_t) expert * blob_bytes;+ const uint64_t layer_offset = layer_offsets_[i];+ if (layer_offset > mapped_bytes_ || expert_offset > mapped_bytes_ - layer_offset) return nullptr;+ const uint64_t offset = layer_offset + expert_offset;+ if (blob_bytes > mapped_bytes_ - offset) return nullptr;+ return base_ + (size_t) offset;+}++bool FileExpertSource::pin_cache_complement(+ const ExpertCache &cache, std::string &err, bool pin,+ const std::vector<std::pair<int32_t, int32_t>> &additional_gpu_pairs) try {+ err.clear();+ if (base_ == nullptr) { err = "FileExpertSource: open the mapped experts before pinning a complement"; return false; }+ if (complement_ready_) { err = "FileExpertSource: the cache complement is already pinned"; return false; }+ if (!cache.valid()) { err = "FileExpertSource: the GPU expert cache is not open"; return false; }+ if (cache.fills() != cache.resident()) {+ err = "FileExpertSource: the GPU expert cache is not fully filled";+ return false;+ }+ const dpct::err0 sync =+ DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw());+ /*+ DPCT1000: Error handling if-stmt was detected but could not be+ rewritten.+ */+ if (sync != 0) {+ /*+ DPCT1009: SYCL reports errors using exceptions and does not use+ error codes. Please replace the "get_error_string_dummy(...)" with a+ real error-handling function.+ */+ /*+ DPCT1001: The statement could not be removed.+ */+ err = std::string("FileExpertSource: GPU expert cache is not ready: ") ++ dpct::get_error_string_dummy(sync);+ /*+ DPCT1010: SYCL uses exceptions to report errors and does not use the+ error codes. The cudaGetLastError function call was replaced with 0. You+ need to rewrite this code.+ */+ (void)0;+ return false;+ }++ std::vector<std::pair<int32_t, int32_t>> primary_gpu_pairs;+ primary_gpu_pairs.reserve((size_t) cache.resident());+ for (int64_t layer = 0; layer < n_layers_; ++layer) {+ for (int64_t expert = 0; expert < n_expert_; ++expert) {+ if (cache.slot_of(layer, expert) != kNotResident)+ primary_gpu_pairs.emplace_back((int32_t) layer, (int32_t) expert);+ }+ }+ std::vector<uint64_t> offsets;+ uint64_t bytes = 0;+ if (!detail::make_cache_complement_plan(n_layers_, n_expert_, layer_blob_bytes_, primary_gpu_pairs,+ additional_gpu_pairs, offsets, bytes, err)) return false;++ if (bytes > 0) {+ uint64_t physical = 0;+ if (!available_memory_bytes(physical)) {+ err = "FileExpertSource: cannot determine available RAM for the resident-memory safety check";+ return false;+ }+ if (physical <= kPinnedMemoryHeadroom || bytes > physical - kPinnedMemoryHeadroom) {+ char message[256];+ std::snprintf(message, sizeof message,+ "FileExpertSource: resident complement %.2f GiB exceeds available RAM minus the 8 GiB safety headroom",+ (double) bytes / 1073741824.0);+ err = message;+ return false;+ }+ }++ void* arena = nullptr;+ const uint8_t* host = nullptr;+ const uint8_t* device = nullptr;+ if (bytes > 0) {+ std::fprintf(stderr, "FileExpertSource: allocating %.2f GiB %s cache complement\n",+ (double) bytes / 1073741824.0, pin ? "mapped pinned" : "pageable resident");+ std::fflush(stderr);+ if (pin) {+ const dpct::err0 allocated = DPCT_CHECK_ERROR(+ arena = (void *)sycl::malloc_host((size_t)bytes,+ dpct::get_in_order_queue()));+ /*+ DPCT1000: Error handling if-stmt was detected but could not be+ rewritten.+ */+ if (allocated != 0) {+ /*+ DPCT1001: The statement could not be removed.+ */+ err = std::string("FileExpertSource: mapped pinned complement "+ "allocation failed: ") ++ /*+ DPCT1009: SYCL reports errors using exceptions and+ does not use error codes. Please replace the+ "get_error_string_dummy(...)" with a real error-handling+ function.+ */+ dpct::get_error_string_dummy(allocated);+ std::fprintf(stderr, "%s\n", err.c_str());+ std::fflush(stderr);+ /*+ DPCT1010: SYCL uses exceptions to report errors and does not+ use the error codes. The cudaGetLastError function call was+ replaced with 0. You need to rewrite this code.+ */+ (void)0;+ return false;+ }+ host = (const uint8_t*) arena;+ void* alias = nullptr;+ const dpct::err0 aliased = DPCT_CHECK_ERROR(alias = (void *)arena);+ if (aliased != 0 || alias == nullptr) {+ err = std::string("FileExpertSource: mapped pinned complement "+ "device alias failed: ") ++ /*+ DPCT1009: SYCL reports errors using exceptions and+ does not use error codes. Please replace the+ "get_error_string_dummy(...)" with a real error-handling+ function.+ */+ dpct::get_error_string_dummy(aliased);+ std::fprintf(stderr, "%s\n", err.c_str());+ std::fflush(stderr);+ /*+ DPCT1010: SYCL uses exceptions to report errors and does not+ use the error codes. The cudaGetLastError function call was+ replaced with 0. You need to rewrite this code.+ */+ (void)0;+ (void)DPCT_CHECK_ERROR(+ sycl::free(arena, dpct::get_in_order_queue()));+ return false;+ }+ device = (const uint8_t*) alias;+ } else {+ arena = std::malloc((size_t) bytes);+ if (arena == nullptr) {+ err = "FileExpertSource: pageable resident complement allocation failed";+ return false;+ }+ host = (const uint8_t*) arena;+ }+ }++ uint64_t copied = 0;+ for (int64_t layer = 0; layer < n_layers_; ++layer) {+ const uint64_t blob_bytes = layer_blob_bytes_[(size_t) layer];+ for (int64_t expert = 0; expert < n_expert_; ++expert) {+ const size_t index = (size_t) layer * (size_t) n_expert_ + (size_t) expert;+ const uint64_t offset = offsets[index];+ if (offset == kNoComplement) continue;+ const uint8_t* source = mapped_blob(layer, expert);+ if (source == nullptr || offset > bytes || blob_bytes > bytes - offset) {+ err = "FileExpertSource: invalid blob bounds while building the cache complement";+ if (arena != nullptr) {+ if (pin)(void) DPCT_CHECK_ERROR(+ sycl::free(arena, dpct::get_in_order_queue()));+ else std::free(arena);+ }+ return false;+ }+ std::memcpy((uint8_t*) host + (size_t) offset, source, (size_t) blob_bytes);+ copied += blob_bytes;+ }+#if !defined(_WIN32)+ const uint64_t layer_offset = layer_offsets_[(size_t) layer];+ const uint64_t layer_bytes = blob_bytes * (uint64_t) n_expert_;+ const uint64_t layer_end = layer_offset + layer_bytes;+ const long page_bytes = sysconf(_SC_PAGESIZE);+ if (page_bytes <= 0) {+ err = "FileExpertSource: cannot determine page size for mapped-page release";+ if (arena != nullptr) {+ if (pin)(void) DPCT_CHECK_ERROR(+ sycl::free(arena, dpct::get_in_order_queue()));+ else std::free(arena);+ }+ return false;+ }+ const uint64_t page = (uint64_t) page_bytes;+ const uint64_t advice_start = layer_offset - layer_offset % page;+ const uint64_t end_remainder = layer_end % page;+ const uint64_t extra = end_remainder == 0 ? 0 : page - end_remainder;+ const uint64_t advice_end = extra > mapped_bytes_ - layer_end ? mapped_bytes_ : layer_end + extra;+ if (advice_end > advice_start &&+ madvise((void*) (base_ + (size_t) advice_start), (size_t) (advice_end - advice_start), MADV_DONTNEED) != 0) {+ err = "FileExpertSource: madvise could not release mapped expert layer " + std::to_string(layer);+ if (arena != nullptr) {+ if (pin)(void) DPCT_CHECK_ERROR(+ sycl::free(arena, dpct::get_in_order_queue()));+ else std::free(arena);+ }+ return false;+ }+ const int advice = posix_fadvise(fd_, (off_t) layer_offset, (off_t) layer_bytes, POSIX_FADV_DONTNEED);+ if (advice != 0) {+ err = "FileExpertSource: posix_fadvise could not release expert layer " + std::to_string(layer);+ if (arena != nullptr) {+ if (pin)(void) DPCT_CHECK_ERROR(+ sycl::free(arena, dpct::get_in_order_queue()));+ else std::free(arena);+ }+ return false;+ }+#endif+ if ((layer + 1) % 8 == 0 || layer + 1 == n_layers_) {+ std::fprintf(stderr, "FileExpertSource: copied cache complement through layer %lld/%lld (%.2f GiB)\n",+ (long long) (layer + 1), (long long) n_layers_, (double) copied / 1073741824.0);+ std::fflush(stderr);+ }+ }++ complement_arena_ = arena;+ complement_host_ = host;+ complement_device_ = device;+ complement_bytes_ = bytes;+ complement_offsets_ = std::move(offsets);+ complement_pinned_ = pin && bytes > 0;+ complement_ready_ = true;+ std::fprintf(stderr, "FileExpertSource: %s cache complement ready: resident %.2f GiB, pinned %.2f GiB\n",+ complement_pinned_ ? "mapped pinned" : "pageable resident",+ (double) resident_bytes() / 1073741824.0, (double) pinned_bytes() / 1073741824.0);+ if (!additional_gpu_pairs.empty()) {+ std::fprintf(stderr, "FileExpertSource: %zu verified additional-GPU experts remain on the mmap fallback\n",+ additional_gpu_pairs.size());+ }+ std::fflush(stderr);+ return true;+}+catch (sycl::exception const &exc) {+ std::cerr << exc.what() << "Exception caught at file:" << __FILE__+ << ", line:" << __LINE__ << std::endl;+ std::exit(1);+}+const uint8_t* FileExpertSource::blob(int64_t layer, int64_t expert) {- if (base_ == nullptr) return nullptr;- if (layer < 0 || expert < 0) return nullptr;- // **`expert >= n_expert_` IS CHECKED SEPARATELY, AND THE FLAT INDEX ALONE DOES NOT CATCH IT.** The blob- // index is `layer * n_expert + expert`, so `blob(0, 512)` has flat index 512 - which is in range, and is- // `blob(1, 0)`. A router id one past the end of a layer would then read the NEXT LAYER's first expert:- // finite, correctly sized, and wrong. Layer and expert are separate axes and are validated as such.- if (expert >= n_expert_) return nullptr;- const int64_t i = layer * n_expert_ + expert;- if (i >= blobs_) return nullptr;- ++reads_;- return base_ + (size_t) i * strata::kernels::cpu::BLOB;+ if (base_ == nullptr || layer < 0 || expert < 0 || layer >= n_layers_ || expert >= n_expert_) return nullptr;+ const size_t index = (size_t) layer * (size_t) n_expert_ + (size_t) expert;+ const uint8_t* mapped_fallback = mapped_blob(layer, expert);+ const uint8_t* result = complement_ready_+ ? detail::cache_complement_blob_or_fallback(index, complement_offsets_, complement_host_, mapped_fallback)+ : mapped_fallback;+ if (result != nullptr) ++reads_;+ return result;+}++bool FileExpertSource::pinned(int64_t layer, int64_t expert) const {+ if (!complement_ready_ || !complement_pinned_ || complement_host_ == nullptr || layer < 0 || expert < 0 ||+ layer >= n_layers_ || expert >= n_expert_) return false;+ const size_t index = (size_t) layer * (size_t) n_expert_ + (size_t) expert;+ return index < complement_offsets_.size() && complement_offsets_[index] != kNoComplement;+}++const uint8_t* FileExpertSource::device_alias(int64_t layer, int64_t expert) const {+ if (!pinned(layer, expert) || complement_device_ == nullptr) return nullptr;+ const size_t index = (size_t) layer * (size_t) n_expert_ + (size_t) expert;+ return complement_device_ + (size_t) complement_offsets_[index];}// ================================ THE ADAPTER ================================@@ -546,7 +1101,7 @@ void expert_hit_run(void *user, void *stream, HitPhase phase,if (DPCT_CHECK_ERROR(cs->memset(d.hit_out, 0, (size_t)d.parts_elems * sizeof(float))) != 0 ||/*- DPCT1124:653: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -554,7 +1109,7 @@ void expert_hit_run(void *user, void *stream, HitPhase phase,DPCT_CHECK_ERROR(cs->memcpy(d.d_slot, d.h_slot.data(), list_bytes)) != 0 ||/*- DPCT1124:654: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -764,7 +1319,7 @@ bool ArenaExpertSource::open(const std::string &pack_dir, int64_t n_layers,void* d = nullptr;if (DPCT_CHECK_ERROR(d = (void *)(void *)(base_ + off)) != 0) {/*- DPCT1010:655: SYCL uses exceptions to report errors and does not+ DPCT1010: SYCL uses exceptions to report errors and does notuse the error codes. The cudaGetLastError function call wasreplaced with 0. You need to rewrite this code.*/diff --git a/sycl/src/core/graph.cpp b/sycl/src/core/graph.cppindex eab5afa0e..5d4550224 100644--- a/sycl/src/core/graph.cpp+++ b/sycl/src/core/graph.cpp@@ -17,7 +17,7 @@ namespace {/// site is the least useful error this API can produce and the easiest to avoid.bool fail(std::string &err, const char *what, dpct::err0 e) {/*- DPCT1009:68: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -58,10 +58,10 @@ bool CapturedGraph::begin(void *stream, std::string &err) try {const dpct::err0 e = DPCT_CHECK_ERROR(dpct::experimental::begin_recording(strata::q_of(stream)));/*- DPCT1001:69: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:70: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) return fail(err, "cudaStreamBeginCapture", e);return true;@@ -76,10 +76,10 @@ bool CapturedGraph::end(void *stream, std::string &err) try {dpct::err0 e = DPCT_CHECK_ERROR(dpct::experimental::end_recording(strata::q_of(stream), &graph_));/*- DPCT1001:71: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:72: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) {graph_ = nullptr; return fail(err, "cudaStreamEndCapture", e);@@ -89,10 +89,10 @@ bool CapturedGraph::end(void *stream, std::string &err) try {e = DPCT_CHECK_ERROR(dpct::experimental::get_nodes(graph_, nullptr, &nodes_));/*- DPCT1001:73: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:74: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) return fail(err, "cudaGraphGetNodes", e);// A capture that recorded NOTHING is a wiring mistake, and a graph that replays nothing produces no error@@ -104,10 +104,10 @@ bool CapturedGraph::end(void *stream, std::string &err) try {sycl::ext::oneapi::experimental::graph_state::executable>((graph_)->finalize()));/*- DPCT1001:75: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:76: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) return fail(err, "cudaGraphInstantiate", e);@@ -115,10 +115,10 @@ bool CapturedGraph::end(void *stream, std::string &err) try {// what makes `wait_ms` a query rather than a sync.e = DPCT_CHECK_ERROR(done_ = new sycl::event());/*- DPCT1001:77: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:78: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) return fail(err, "cudaEventCreateWithFlags", e);return true;@@ -134,19 +134,19 @@ bool CapturedGraph::launch(void *stream, std::string &err) const try {dpct::err0 e =DPCT_CHECK_ERROR(strata::q_of(stream)->ext_oneapi_graph(*exec_));/*- DPCT1001:79: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:80: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) return fail(err, "cudaGraphLaunch", e);/*- DPCT1012:83: Detected kernel execution time measurement pattern and+ DPCT1012: Detected kernel execution time measurement pattern andgenerated an initial code for time measurements in SYCL. You can change theway time is measured depending on your goals.*//*- DPCT1024:84: The original code returned the error code that was further+ DPCT1024: The original code returned the error code that was furtherconsumed by the program logic. This original code was replaced with 0. Youmay need to rewrite the program logic consuming the error code.*/@@ -154,10 +154,10 @@ bool CapturedGraph::launch(void *stream, std::string &err) const try {e = DPCT_CHECK_ERROR(*done_ = strata::q_of(stream)->ext_oneapi_submit_barrier());/*- DPCT1001:81: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:82: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (e != 0) return fail(err, "cudaEventRecord", e);return true;@@ -203,19 +203,19 @@ bool GraphRegistry::record(LayerType type, int n_tokens, const std::function<voi// The body must not have failed silently. An error state left on the stream would make EndCapture// succeed with a broken graph, so it is checked and cleared first./*- DPCT1010:87: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 body_err = 0;/*- DPCT1000:86: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (body_err != 0) {// Abandon the capture without instantiating anything.dpct::experimental::command_graph_ptr junk = nullptr;/*- DPCT1001:85: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/dpct::experimental::end_recording(strata::q_of(stream_), &junk);if (junk) delete (junk);diff --git a/sycl/src/core/layer.cpp b/sycl/src/core/layer.cppindex 15fabdb00..f80a85737 100644--- a/sycl/src/core/layer.cpp+++ b/sycl/src/core/layer.cpp@@ -175,11 +175,13 @@ if (!w.wants_q8k()) { s_gemv_q8_0_split(x80, p.codes, p.scales, p.offset,// namespacevoid layer_set_native_bf16(bool enabled) { native_bf16_projections = enabled; }void layer_set_native_flash_attn_short(bool enabled) { native_flash_attn_short = enabled; }-namespace { bool g_kv_int8 = false, g_kv_q4 = false; }+namespace { bool g_kv_int8 = false, g_kv_q4 = false, g_kv_hybrid = false; }void qsa_set_kv_int8(bool enabled) { g_kv_int8 = enabled; }bool qsa_kv_int8() { return g_kv_int8; }void qsa_set_kv_q4(bool enabled) { g_kv_q4 = enabled; }bool qsa_kv_q4() { return g_kv_q4; }+void qsa_set_kv_hybrid(bool enabled) { g_kv_hybrid = enabled; }+bool qsa_kv_hybrid() { return g_kv_hybrid; }uint64_t gdn_buffers_bytes(const ModelGeometry& g) { const int64_t C = g.ssm_conv_channels; const int64_t V = g.ssm_value_dim; const uint64_t parts[] = { q8k_bytes(g.n_embd),// x_q8k(uint64_t) (g.n_embd / 32) * 34,@@ -277,7 +279,7 @@ try {else {gdn_conv_step(b.conv_state, b.qkv, conv_kernel, b.conv_out, C, g.ssm_d_conv, stream);/*- DPCT1124:794: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -418,7 +420,7 @@ if (db != nullptr && g_publish_kernel) {strata::kernels::doorbell_publish(x, b.ids, b.weights, g.n_embd, k, db->d_x_f, db->d_ids, db->d_weights, db->d_seq,stream);/*-DPCT1124:795: cudaMemcpyAsync is migrated to asynchronous memcpy API. While the+DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. While theorigin API might be synchronous, it depends on the type of operand memory, soyou may need to call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -568,10 +570,15 @@ KvPlan kv_plan(const QsaShapes& s, int64_t max_cells, int64_t ring_cells) {}return p;}-uint64_t kv_pool_bytes(const QsaShapes& s, int64_t pages) {+uint64_t kv_pool_bytes(const QsaShapes& s, int64_t pages, bool hybrid, bool int8) {+ if (hybrid) { // K8V4: the INT8 K half (codes + scales) plus the Q4_0 V half (kv_q4.hpp's rotation)+ const uint64_t rows = (uint64_t) pages * s.page_size * s.n_head_kv;+ return rows * (uint64_t) s.head_dim + rows * (uint64_t) (s.head_dim / strata::kernels::KV_Q8_GROUP) * 2 ++ rows * strata::kernels::kv_q4_bytes_per_head((int) s.head_dim) + 64;+ }if (g_kv_q4) return (uint64_t) pages * s.page_size * strata::kernels::kv_q4_bytes_per_cell(s) + 64;- return g_kv_int8 ? (uint64_t) pages * s.page_size * strata::kernels::kv_q8_bytes_per_cell(s) + 64- : (uint64_t) pages * s.n_head_kv * s.page_size * s.head_dim * 2 * 2;+ return int8 ? (uint64_t) pages * s.page_size * strata::kernels::kv_q8_bytes_per_cell(s) + 64+ : (uint64_t) pages * s.n_head_kv * s.page_size * s.head_dim * 2 * 2;}} // namespace@@ -584,7 +591,8 @@ uint64_t qsa_state_bytes(const ModelGeometry& g, int64_t max_cells, bool with_roconst QsaShapes s = qsa_shapes(g);const KvPlan p = kv_plan(s, max_cells, ring_cells);uint64_t n = 0;- n += kv_pool_bytes(s, p.slots) + 4 * 16; // K/V pools (the VRAM slots)+ n += kv_pool_bytes(s, p.slots, g_kv_hybrid && ring_cells <= 0,+ g_kv_int8 || g_kv_hybrid) + 4 * 16; // K/V pools (the VRAM slots)n += (uint64_t) p.pages * 4; // page_tableif (p.mode == 1) n += strata::kernels::kv_stream_map_bytes(p.slots) + 6 * 16; // the residency mapn += (uint64_t) (s.idx_block - 1) * s.idx_dim * 4; // tail@@ -606,14 +614,29 @@ uint64_t qsa_state_init(const ModelGeometry &g, int64_t max_cells, void *base,Cursor c{(uint8_t*) base};st.kv_int8 = g_kv_int8 && !g_kv_q4;st.kv_q4 = g_kv_q4;+ // Hybrid K8V4, main layers only (the drafter's state is created with the globals toggled to INT8 -+ // mtp.cpp). Streamed mode is refused outright; generate.cpp validates it too, this is the backstop.+ if (g_kv_hybrid && ring_cells <= 0) {+ if (p.mode == 1) {+ std::fprintf(stderr, "strata: hybrid K8V4 KV does not support --kv-resident streaming\n");+ return 0;+ }+ st.kv_hybrid = true;+ st.kv_int8 = false;+ st.kv_q4 = false;+ }st.kv_mode = p.mode;st.n_slots = p.slots;const uint64_t rows = (uint64_t) p.slots * s.n_head_kv * s.page_size; // VRAM rows: the slotsconst uint64_t q4_row = strata::kernels::kv_q4_bytes_per_head((int) s.head_dim);- if (st.kv_q4) {+ if (st.kv_hybrid) {+ st.k_q = c.take<int8_t>(rows * s.head_dim);+ st.k_scale = c.take<uint16_t>(rows * (s.head_dim / strata::kernels::KV_Q8_GROUP));+ st.v_q4 = c.take<uint8_t>(rows * q4_row);+ } else if (st.kv_q4) {st.k_q4 = c.take<uint8_t>(rows * q4_row);st.v_q4 = c.take<uint8_t>(rows * q4_row);- } else if (g_kv_int8) {+ } else if (st.kv_int8) { // st, not the global: the drafter's ring is INT8 under --kv k8v4 toost.k_q = c.take<int8_t>(rows * s.head_dim);st.v_q = c.take<int8_t>(rows * s.head_dim);st.k_scale = c.take<uint16_t>(rows * (s.head_dim / strata::kernels::KV_Q8_GROUP));@@ -658,12 +681,12 @@ uint64_t qsa_state_init(const ModelGeometry &g, int64_t max_cells, void *base,strata::kernels::qsa_step_bytes() + sizeof(int32_t),dpct::get_in_order_queue())) != 0 ||/*- DPCT1048:8: The original value cudaHostAllocMapped is not meaningful in+ DPCT1048: The original value cudaHostAllocMapped is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*//*- DPCT1048:9: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -681,12 +704,12 @@ uint64_t qsa_state_init(const ModelGeometry &g, int64_t max_cells, void *base,uint8_t* h = nullptr;uint8_t* d = nullptr;/*- DPCT1048:10: The original value cudaHostAllocMapped is not meaningful in+ DPCT1048: The original value cudaHostAllocMapped is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*//*- DPCT1048:11: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -705,7 +728,7 @@ uint64_t qsa_state_init(const ModelGeometry &g, int64_t max_cells, void *base,if (st.kv_q4) {st.host.k_q4 = hc.take<uint8_t>(hrows * q4_row);st.host.v_q4 = hc.take<uint8_t>(hrows * q4_row);- } else if (g_kv_int8) {+ } else if (st.kv_int8) {st.host.k_q = hc.take<int8_t>(hrows * s.head_dim);st.host.v_q = hc.take<int8_t>(hrows * s.head_dim);st.host.k_scale = hc.take<uint16_t>(hrows * (s.head_dim / strata::kernels::KV_Q8_GROUP));@@ -755,7 +778,14 @@ void qsa_state_zero(const QsaState& st, const ModelGeometry& g, void* stream) {const QsaShapes s = qsa_shapes(g);dpct::queue_ptr cs = strata::q_of(stream);const size_t rows = (size_t) st.n_slots * s.n_head_kv * s.page_size;- if (st.kv_q4) {+ if (st.kv_hybrid) {+ cs->memset(st.k_q, 0, rows * s.head_dim);+ cs->memset(st.k_scale, 0,+ rows * (s.head_dim / strata::kernels::KV_Q8_GROUP) * 2);+ cs->memset(st.v_q4, 0,+ rows *+ strata::kernels::kv_q4_bytes_per_head((int)s.head_dim));+ } else if (st.kv_q4) {cs->memset(st.k_q4, 0,rows *strata::kernels::kv_q4_bytes_per_head((int)s.head_dim));@@ -785,7 +815,8 @@ void qsa_state_zero(const QsaState& st, const ModelGeometry& g, void* stream) {strata::kernels::QsaAttnPools qsa_attn_pools(const QsaState& st) {strata::kernels::QsaAttnPools pools;pools.page_table = st.page_table;- if (st.kv_q4) { pools.k_q4 = st.k_q4; pools.v_q4 = st.v_q4; }+ if (st.kv_hybrid) { pools.k_q = st.k_q; pools.k_scale = st.k_scale; pools.v_q4 = st.v_q4; }+ else if (st.kv_q4) { pools.k_q4 = st.k_q4; pools.v_q4 = st.v_q4; }else if (st.kv_int8) { pools.k_q = st.k_q; pools.v_q = st.v_q; pools.k_scale = st.k_scale; pools.v_scale = st.v_scale; }else { pools.k_pool = st.k_pool; pools.v_pool = st.v_pool; }return pools;@@ -984,7 +1015,7 @@ if (!w_attnk->native_data || !w_attnv->native_data || !w_attnq->native_data) {strata::kernels::copy_i32_from_mapped(st.pos_dev, m_pos, g.n_head, stream);} else/*- DPCT1124:796: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -1002,11 +1033,18 @@ if (!gemv_quantized(*w_attnk, p_k, f_k, b.x_q8_0, b.x_q8k, b.kcur, g.n_embd, g.n// EVERY ENTRY POINT FROM HERE ON IS THE CAPTURABLE ONE: the per-token counts come from `st.step` and every// launch is sized from a capacity in `st`/`b`, so this sequence can be captured and replayed. The// host-scalar wrappers would be correct here today and silently wrong in a graph.-if (st.kv_q4) {+if (st.kv_hybrid) {+ // K8V4: only V is rotated (kv_q4.hpp's H); the scores pair unrotated q with unrotated INT8 K, and the+ // output - a mix of rotated values - is rotated back after attention. Each append/gather call folds the+ // unused half's lanes onto the used pool (a bit-identical duplicate write), so no kernel variants exist.+ strata::kernels::fwht256_inplace_cuda(b.vcur, g.n_head_kv, stream);+ kv_append_q8_step(st.k_q, st.k_q, st.k_scale, st.k_scale, st.page_table, st.step, b.kcur, b.kcur, s, stream, nullptr); // mode 0: no host mirror+ strata::kernels::kv_append_q4_step(st.v_q4, st.v_q4, st.page_table, st.step, b.vcur, b.vcur, s, stream, nullptr);+} else if (st.kv_q4) {strata::kernels::fwht256_inplace_cuda(b.kcur, g.n_head_kv, stream); // Q4_0: rotated K and V (kv_q4.hpp)strata::kernels::fwht256_inplace_cuda(b.vcur, g.n_head_kv, stream);strata::kernels::kv_append_q4_step(st.k_q4, st.v_q4, st.page_table, st.step, b.kcur, b.vcur, s, stream, &st.host);-} else if (st.kv_int8) kv_append_q8_step(st.k_q, st.v_q, st.k_scale, st.v_scale, st.page_table, st.step, b.kcur, b.vcur, s, stream, &st.host); else kv_append_step(st.k_pool, st.v_pool, st.page_table, st.step, b.kcur, b.vcur, s, stream, &st.host); { const uint64_t nvk = (uint64_t) g.n_head_kv * g.head_dim; const uint64_t base = (uint64_t) 2 * g.n_embd + 2 * g.hc + (uint64_t) g.n_head * g.head_dim + 2 * nvk + 8; if (!st.kv_int8) dump_slot(dump, g, layer, (const float*) st.k_pool, base, nvk / 2, stream); if (!st.kv_int8) dump_slot(dump, g, layer, (const float*) st.v_pool, base + nvk / 2, nvk / 2, stream); dump_slot(dump, g, layer, b.vcur, base + nvk, nvk, stream); dump_slot(dump, g, layer, b.kcur, base + 2 * nvk, nvk, stream); } { const QsaIndexerBuffers ib{st.idx_tail, st.idx_dead, st.idx_pooled, st.idx_block_pos}; if (native_qsa_indexer_enabled()) {+} else if (st.kv_int8) kv_append_q8_step(st.k_q, st.v_q, st.k_scale, st.v_scale, st.page_table, st.step, b.kcur, b.vcur, s, stream, &st.host); else kv_append_step(st.k_pool, st.v_pool, st.page_table, st.step, b.kcur, b.vcur, s, stream, &st.host); { const uint64_t nvk = (uint64_t) g.n_head_kv * g.head_dim; const uint64_t base = (uint64_t) 2 * g.n_embd + 2 * g.hc + (uint64_t) g.n_head * g.head_dim + 2 * nvk + 8; if (!st.kv_int8 && !st.kv_hybrid) dump_slot(dump, g, layer, (const float*) st.k_pool, base, nvk / 2, stream); if (!st.kv_int8 && !st.kv_hybrid) dump_slot(dump, g, layer, (const float*) st.v_pool, base + nvk / 2, nvk / 2, stream); dump_slot(dump, g, layer, b.vcur, base + nvk, nvk, stream); dump_slot(dump, g, layer, b.kcur, base + 2 * nvk, nvk, stream); } { const QsaIndexerBuffers ib{st.idx_tail, st.idx_dead, st.idx_pooled, st.idx_block_pos}; if (native_qsa_indexer_enabled()) {try {native_qsa_indexer_append(b.idx_raw, st.step + kStepPos, pos_base,(const float*) w_ikn->data, RMS_EPS, ib, s, st.max_cells, (float) qsa_freq_base(), stream);@@ -1024,7 +1062,7 @@ if (!gemv_quantized(*w_attnq, p_q, f_q, b.x_q8_0, b.x_q8k, b.q_full, g.n_embd, g// the norm and the rotation see whole rows. A 2-D copy is a memcpy node, which captures (`pinned_capture`// case A) and needs no kernel./*-DPCT1124:797: cudaMemcpy2DAsync is migrated to asynchronous memcpy API. While+DPCT1124: cudaMemcpy2DAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operand memory,so you may need to call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -1057,7 +1095,13 @@ int64_t max_blocks = (st.max_cells / s.idx_block) + 2;const strata::kernels::QsaAttnPools pools = qsa_attn_pools(st);strata::kernels::qsa_decode_attn_step(b.qcur, pools, b.ids, st.step, cap, s, b.attn_scratch, b.attn, stream);} else {- if (st.kv_q4) strata::kernels::kv_gather_q4_step(st.k_q4, st.v_q4, st.page_table, b.ids, st.step, cap, s, b.k_scratch, b.v_scratch, stream);+ if (st.kv_hybrid) {+ kv_gather_q8_step(st.k_q, st.k_q, st.k_scale, st.k_scale, st.page_table, b.ids, st.step, cap, s,+ b.k_scratch, b.k_scratch, stream);+ strata::kernels::kv_gather_q4_step(st.v_q4, st.v_q4, st.page_table, b.ids, st.step, cap, s,+ b.v_scratch, b.v_scratch, stream);+ }+ else if (st.kv_q4) strata::kernels::kv_gather_q4_step(st.k_q4, st.v_q4, st.page_table, b.ids, st.step, cap, s, b.k_scratch, b.v_scratch, stream);else if (st.kv_int8) kv_gather_q8_step(st.k_q, st.v_q, st.k_scale, st.v_scale, st.page_table, b.ids, st.step, cap, s, b.k_scratch, b.v_scratch, stream); else kv_gather_step(st.k_pool, st.v_pool, st.page_table, b.ids, st.step, cap, s, b.k_scratch, b.v_scratch, stream); if (native_flash_attn_short) {if (st.max_cells < 1 || st.max_cells > 256 || !st.attention_status || !st.host_step) {err = v.name("native_flash_attn") + ": short adapter requires context <=256 and persistent status storage";@@ -1068,7 +1112,7 @@ int64_t max_blocks = (st.max_cells / s.idx_block) + 2;(int) st.max_cells, s, b.attn, st.attention_status, nullptr, stream);} catch (const std::exception& error) { err = v.name("native_flash_attn") + ": " + error.what(); return false; }/*- DPCT1124:798: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -1080,7 +1124,7 @@ int64_t max_blocks = (st.max_cells / s.idx_block) + 2;}} else qsa_attend_step(b.qcur, b.k_scratch, b.v_scratch, st.step, cap, s, b.attn, nullptr, stream);}- if (st.kv_q4) strata::kernels::fwht256_inplace_cuda(b.attn, g.n_head, stream); // the output back: H is self-inverse+ if (st.kv_q4 || st.kv_hybrid) strata::kernels::fwht256_inplace_cuda(b.attn, g.n_head, stream); // the output back: H is self-inversedump_slot(dump, g, layer, b.attn, (uint64_t) 2 * g.n_embd + 2 * g.hc, (uint64_t) g.n_head * g.head_dim, stream); { const uint64_t vs = (uint64_t) 2 * g.n_embd + 2 * g.hc + (uint64_t) g.n_head * g.head_dim + (uint64_t) 2 * g.n_head_kv * g.head_dim; dump_slot(dump, g, layer, (const float*) b.v_scratch, vs, (uint64_t) g.n_head_kv * g.head_dim / 2, stream); dump_slot(dump, g, layer, (const float*) b.ids, vs + (uint64_t) g.n_head_kv * g.head_dim / 2, 4, stream); dump_slot(dump, g, layer, (const float*) st.step, vs + (uint64_t) g.n_head_kv * g.head_dim / 2 + 4, 4, stream); }// ---- 9. Gate the attention output before its projection. Native CUDA keeps F32// sigmoid/multiply arithmetic and uses Q8_1 for the native quantized projection.@@ -1103,7 +1147,7 @@ uint64_t doorbell_init(const ModelGeometry& g, int64_t k, Doorbell& db) { db.// ONE region per field, each MAPPED PINNED, so the device and the host have different pointers to the same// bytes and no copy is needed to publish them./*-DPCT1048:12: The original value cudaHostAllocMapped is not meaningful in the+DPCT1048: The original value cudaHostAllocMapped is not meaningful in themigrated code and was removed or replaced with 0. You may need to check themigrated code.*/@@ -1260,7 +1304,7 @@ static void dump_slot(float* dump, const ModelGeometry& g, int64_t layer, constuint64_t n, void* stream) {if (dump == nullptr || src == nullptr || n == 0) return;/*- DPCT1124:799: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -1332,7 +1376,7 @@ bool block_layer_pre(const WeightTable &tables, const ModelGeometry &g,// would be the natural reading and would scramble the channels.strata::kernels::ple_history_advance(ple->hist, po.normalized, stream);/*- DPCT1010:800: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaPeekAtLastError function call was replaced with 0.You need to rewrite this code.*/@@ -1420,7 +1464,7 @@ bool ple_finish_token(const PleRun &p, void *stream, std::string &err) try {if (!p.ready()) { err = "ple_finish_token: the PLE run is not ready"; return false; }if (!p.table->collect(p.emb_host, err)) { err = "ple_finish_token: " + err; return false; }/*- DPCT1124:801: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.diff --git a/sycl/src/core/mtp.cpp b/sycl/src/core/mtp.cppindex ec52da5b0..6f0f9eee7 100644--- a/sycl/src/core/mtp.cpp+++ b/sycl/src/core/mtp.cpp@@ -57,7 +57,7 @@ struct Bump {bool mapped(size_t bytes, void **h, void **d) try {/*- DPCT1048:0: The original value cudaHostAllocMapped is not meaningful in the+ DPCT1048: The original value cudaHostAllocMapped is not meaningful in themigrated code and was removed or replaced with 0. You may need to check themigrated code.*/@@ -177,13 +177,13 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,DPCT_CHECK_ERROR(dense_ = (uint8_t *)sycl::malloc_device(blob.size(), dpct::get_in_order_queue()));/*- DPCT1000:10: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (alloc != 0) {size_t free_bytes = 0, total_bytes = 0;/*- DPCT1106:12: 'cudaMemGetInfo' was migrated with the Intel extensions+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensionsfor device information which may not be supported by all compilersor runtimes. You may need to adjust the code.*/@@ -191,12 +191,12 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,DPCT_CHECK_ERROR(dpct::get_current_device().get_memory_info(free_bytes, total_bytes));/*- DPCT1009:13: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:9: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "mtp: dense weights allocation failed (" +std::string(dpct::get_error_string_dummy(alloc)) +@@ -207,7 +207,7 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,return false;}/*- DPCT1114:11: cudaMemcpy is migrated to asynchronization memcpy, assuming+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assumingin the original code the source host memory is pageable memory. If thememory is not pageable, call wait() on event return by memcpy API toensure synchronization behavior.@@ -253,6 +253,12 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,// window (plus the cells a round writes ahead of its queries) over a host copy, refilled on a resume. The host copy// is pinned after the expert arena has pinned what it could: if it does not fit, the K/V stays whole in VRAM.int64_t ring = (window > 0 && window < max_cells) ? window + 4 * (int64_t) max_t + 64 : 0;+ // K8V4 never applies to the drafter: its own attention paths (below, and verify.cpp) handle whole formats+ // only, whatever ring shape it takes (0, a window, or the -1 fully-resident fallback).+ const bool kv_hybrid_was = qsa_kv_hybrid();+ const bool kv_int8_was = qsa_kv_int8();+ qsa_set_kv_hybrid(false);+ if (kv_hybrid_was) qsa_set_kv_int8(true); // the drafter under --kv k8v4: plain INT8uint64_t sb = qsa_state_bytes(g, max_cells, false, ring);if (DPCT_CHECK_ERROR(state_arena_ = (void *)sycl::malloc_device(sb, dpct::get_in_order_queue())) != 0) {@@ -262,7 +268,7 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,if (st_.kv_mode == 0) { err = "mtp: state init failed"; return false; }std::fprintf(stderr, "strata mtp: no pinned RAM left for the draft layer's K/V copy; keeping it in VRAM\n");/*- DPCT1026:14: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/sycl::free(state_arena_, dpct::get_in_order_queue());@@ -275,6 +281,8 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,}if (qsa_state_init(g, max_cells, state_arena_, st_, &ss.qsa_states[0], ring) == 0) { err = "mtp: state init failed"; return false; }}+ qsa_set_kv_int8(kv_int8_was);+ qsa_set_kv_hybrid(kv_hybrid_was);qsa_state_zero(st_, g, nullptr);dpct::get_current_device().queues_wait_and_throw();vram_ += sb;@@ -337,7 +345,7 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,for (uint64_t t = 0; t < T; ++t)for (int64_t i = 0; i < cap_; ++i) id[(size_t) (t * (uint64_t) cap_ + (uint64_t) i)] = (int32_t) i;/*- DPCT1114:15: cudaMemcpy is migrated to asynchronization memcpy, assuming+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assumingin the original code the source host memory is pageable memory. If thememory is not pageable, call wait() on event return by memcpy API toensure synchronization behavior.@@ -345,7 +353,7 @@ bool MtpDrafter::load(const std::string &rt_dir, const ModelGeometry &g,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+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (DPCT_CHECK_ERROR(cs_ = dpct::get_current_device().create_queue(true)) !=@@ -496,7 +504,7 @@ bool MtpDrafter::record_forward(int T, int step_row0, dpct::queue_ptr cs,for (int t = 0; t < T; ++t) {float* qc = qcur_ + t * NH * HD;/*- DPCT1124:17: cudaMemcpy2DAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpy2DAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -603,7 +611,7 @@ bool finish_capture(dpct::queue_ptr cs, bool ok,graph->finalize())) != 0) {if (graph) delete (graph);/*- DPCT1009:19: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -614,7 +622,7 @@ bool finish_capture(dpct::queue_ptr cs, bool ok,delete (graph);// an explicit upload: the first launch's implicit one blocked behind a device-side spin (verify.cpp)/*- DPCT1007:18: Migration of cudaGraphUpload is not supported.+ DPCT1007: Migration of cudaGraphUpload is not supported.*/// no cudaGraphUpload on SYCL: a finalized command_graph is already residentcs->wait();@@ -764,7 +772,7 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,for (int64_t h = 0; h < NHp; ++h) ps[i * NHp + h] = (int32_t) cell;}/*- DPCT1124:20: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -782,7 +790,7 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,if (cell0 + c + T <= first_needed) continue;if (!capture_prefill_dev(T, err)) return false;/*- DPCT1124:21: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return bymemcpy API to ensure synchronization behavior.@@ -790,7 +798,7 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,if (DPCT_CHECK_ERROR(cs_->memcpy(tok_, d_tk + c, (size_t)T * 4)) !=0 ||/*- DPCT1124:22: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends onthe type of operand memory, so you may need to call wait() onevent return by memcpy API to ensure synchronization behavior.@@ -798,7 +806,7 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,DPCT_CHECK_ERROR(cs_->memcpy(step_, d_stp + c * 4, (size_t)T * 16)) != 0 ||/*- DPCT1124:23: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends onthe type of operand memory, so you may need to call wait() onevent return by memcpy API to ensure synchronization behavior.@@ -806,7 +814,7 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,DPCT_CHECK_ERROR(cs_->memcpy(pos_, d_ps + c * NHp,(size_t)(T * NHp) * 4)) != 0 ||/*- DPCT1124:24: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends onthe type of operand memory, so you may need to call wait() onevent return by memcpy API to ensure synchronization behavior.@@ -817,13 +825,13 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,DPCT_CHECK_ERROR((cs_)->ext_oneapi_graph(*prefill_dev_exec_[T])) != 0) {/*- DPCT1009:25: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:26: SYCL uses exceptions to report errors and does not+ DPCT1010: SYCL uses exceptions to report errors and does notuse the error codes. The cudaGetLastError function call wasreplaced with 0. You need to rewrite this code.*/@@ -834,12 +842,12 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,}if (DPCT_CHECK_ERROR(cs_->wait()) != 0) {/*- DPCT1009:27: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1010:28: SYCL uses exceptions to report errors and does not use+ DPCT1010: SYCL uses exceptions to report errors and does not usethe error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/@@ -864,7 +872,7 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,for (int64_t h = 0; h < g_->n_head; ++h) h_pos_[t * g_->n_head + h] = (int32_t) cell;}/*- DPCT1124:29: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -875,12 +883,12 @@ bool MtpDrafter::prefill(const float *R_rows, const int32_t *next_tokens,DPCT_CHECK_ERROR((cs_)->ext_oneapi_graph(*prefill_exec_[T])) != 0 ||DPCT_CHECK_ERROR(cs_->wait()) != 0) {/*- DPCT1009:30: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1010:31: SYCL uses exceptions to report errors and does not use+ DPCT1010: SYCL uses exceptions to report errors and does not usethe error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/@@ -923,12 +931,12 @@ bool MtpDrafter::draft(int T, const int32_t* tokens, int64_t p, int a, int32_t*if (DPCT_CHECK_ERROR((cs_)->ext_oneapi_graph(*round_exec_[T])) != 0 ||DPCT_CHECK_ERROR(cs_->wait()) != 0) {/*- DPCT1009:32: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1010:33: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -947,12 +955,12 @@ bool MtpDrafter::draft(int T, const int32_t* tokens, int64_t p, int a, int32_t*if (DPCT_CHECK_ERROR((cs_)->ext_oneapi_graph(*step_exec_[j])) != 0 ||DPCT_CHECK_ERROR(cs_->wait()) != 0) {/*- DPCT1009:34: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1010:35: SYCL uses exceptions to report errors and does not use+ DPCT1010: SYCL uses exceptions to report errors and does not usethe error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/diff --git a/sycl/src/core/native_dense.cpp b/sycl/src/core/native_dense.cppindex 51c2ca970..1d7da7142 100644--- a/sycl/src/core/native_dense.cpp+++ b/sycl/src/core/native_dense.cpp@@ -18,9 +18,9 @@ namespace {bool eligible(const strata::TensorInfo& tensor, bool include_ple_key) {const auto& name = tensor.name;if (name.rfind("blk.", 0) != 0) return false;- // The native PLE kernel accepts Q2_0. Other quantized keys can be converted to BF16 by iq_pack;- // keep their packed bytes resident instead of overriding them with an unsupported native key.- if (name == "blk.1.ple_key.weight") return include_ple_key && tensor.type == 42; // 42 = Q2_0+ // Match the native PLE kernel: Q2_0, IQ3_XXS and IQ4_XS. Other keys retain the packed BF16 fallback.+ if (name == "blk.1.ple_key.weight")+ return include_ple_key && (tensor.type == 42 || tensor.type == 18 || tensor.type == 23);static const char* suffixes[] = {".attn_qkv.weight", ".attn_gate.weight", ".ssm_out.weight",".attn_q.weight", ".attn_k.weight", ".attn_v.weight", ".attn_output.weight",".ffn_gate_shexp.weight", ".ffn_up_shexp.weight", ".ffn_down_shexp.weight"};@@ -165,18 +165,18 @@ bool NativeDense::load(const std::vector<std::string> &shards,.memcpy(data.get(), gguf.tensor_data(tensor), bytes).wait());/*- DPCT1000:420: Error handling if-stmt was detected but could not+ DPCT1000: Error handling if-stmt was detected but could notbe rewritten.*/if (status != 0) {/*- DPCT1009:421: SYCL reports errors using exceptions and does+ DPCT1009: SYCL reports errors using exceptions and doesnot use error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1001:419: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "native dense upload " + tensor.name + ": " +dpct::get_error_string_dummy(status);@@ -195,15 +195,15 @@ bool NativeDense::load(const std::vector<std::string> &shards,dpct::get_in_order_queue()));DevicePtr scratch(allocation);/*- DPCT1009:422: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:417: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:418: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (status != 0) {diff --git a/sycl/src/core/native_head.cpp b/sycl/src/core/native_head.cppindex 5c8566a80..a3924b65c 100644--- a/sycl/src/core/native_head.cpp+++ b/sycl/src/core/native_head.cpp@@ -61,19 +61,19 @@ bool NativeHead::load(const std::string &path, int64_t n_in, int64_t n_out,.memcpy(weights, gguf.tensor_data(*tensor), bytes).wait());/*- DPCT1000:1107: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (status != 0) {if (scratch) sycl::free(scratch, dpct::get_in_order_queue());if (weights) sycl::free(weights, dpct::get_in_order_queue());/*- DPCT1009:1108: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:1106: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("native head upload: ") +dpct::get_error_string_dummy(status);@@ -115,23 +115,23 @@ bool NativeHead::run(const float *mixed, float *logits, void *stream,return false;}/*- DPCT1010:1111: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaPeekAtLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 status = 0;/*- DPCT1000:1110: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (status != 0) {/*- DPCT1009:1112: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:1109: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("native head launch: ") +dpct::get_error_string_dummy(status);@@ -173,12 +173,12 @@ bool NativeEmbed::load(const std::string &path, int64_t n_embd, int64_t n_vocab,row_ = strata::kernels::iq_row_bytes((int) t->type, n_embd);bytes_ = (uint64_t) row_ * (uint64_t) n_vocab;/*- DPCT1048:19: The original value cudaHostAllocMapped is not meaningful in+ DPCT1048: The original value cudaHostAllocMapped is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*//*- DPCT1048:20: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/diff --git a/sycl/src/core/overlap_main.cpp b/sycl/src/core/overlap_main.cppindex 3297a2e5f..31d0a88ed 100644--- a/sycl/src/core/overlap_main.cpp+++ b/sycl/src/core/overlap_main.cpp@@ -104,7 +104,7 @@ int main(int argc, char** argv) {std::vector<uint16_t> hx((size_t) n_in, 0x3C00);std::vector<float> hs((size_t) n_out * (size_t) (n_in / 64), 0.001f);/*- DPCT1114:657: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -113,7 +113,7 @@ int main(int argc, char** argv) {d_x, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"copy x");/*- DPCT1114:658: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -142,7 +142,7 @@ int main(int argc, char** argv) {auto t0 = std::chrono::steady_clock::now();for (int i = 0; i < experts; ++i) {/*- DPCT1124:659: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -167,7 +167,7 @@ int main(int argc, char** argv) {check(DPCT_CHECK_ERROR(ev[b] = new sycl::event()), "event");t0 = std::chrono::steady_clock::now();/*- DPCT1124:660: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -176,7 +176,7 @@ int main(int argc, char** argv) {DPCT_CHECK_ERROR(s_copy->memcpy(d_codes[0], arena.data(), role_codes)),"prologue");/*- DPCT1024:661: The original code returned the error code that was further+ DPCT1024: The original code returned the error code that was furtherconsumed by the program logic. This original code was replaced with 0. Youmay need to rewrite the program logic consuming the error code.*/@@ -186,7 +186,7 @@ int main(int argc, char** argv) {const int cur = i & 1, nxt = (i + 1) & 1;if (i + 1 < experts) {/*- DPCT1124:662: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -197,7 +197,7 @@ int main(int argc, char** argv) {role_codes)),"overlap copy");/*- DPCT1024:663: The original code returned the error code that was+ DPCT1024: The original code returned the error code that wasfurther consumed by the program logic. This original code wasreplaced with 0. You may need to rewrite the program logic consumingthe error code.diff --git a/sycl/src/core/pinned.dp.cpp b/sycl/src/core/pinned.dp.cppindex 86c84dbb5..5b5d33da1 100644--- a/sycl/src/core/pinned.dp.cpp+++ b/sycl/src/core/pinned.dp.cpp@@ -122,7 +122,7 @@ uint64_t fnv1a64(const uint8_t* p, uint64_t n, uint64_t seed) {namespace {/*-DPCT1010:1113: SYCL uses exceptions to report errors and does not use the error+DPCT1010: SYCL uses exceptions to report errors and does not use the errorcodes. The cudaGetLastError function call was replaced with 0. You need torewrite this code.*/@@ -156,7 +156,7 @@ PinnedArena::PinnedArena(uint64_t bytes, const std::vector<uint64_t> &bounds,const dpct::err0 e =capped ? 0 :/*- DPCT1027:1114: The call to cudaHostRegister was replaced with+ DPCT1027: The call to cudaHostRegister was replaced with0 because SYCL currently does not support registering ofexisting host memory for use by device. Use USM to allocatememory for use by host and device.@@ -173,14 +173,14 @@ PinnedArena::PinnedArena(uint64_t bytes, const std::vector<uint64_t> &bounds,const uint64_t off = bounds[i], n = bounds[i + 1] - bounds[i];if (capped && (off > max_pinned_bytes || n > max_pinned_bytes - off)) break;/*- DPCT1027:1115: The call to cudaHostRegister was replaced with 0+ DPCT1027: The call to cudaHostRegister was replaced with 0because SYCL currently does not support registering of existinghost memory for use by device. Use USM to allocate memory foruse by host and device.*/if (0 != 0) {/*- DPCT1010:1116: SYCL uses exceptions to report errors and+ DPCT1010: SYCL uses exceptions to report errors anddoes not use the error codes. The cudaGetLastError functioncall was replaced with 0. You need to rewrite this code.*/@@ -197,7 +197,7 @@ PinnedArena::PinnedArena(uint64_t bytes, const std::vector<uint64_t> &bounds," GiB for CUDA1; ":/*- DPCT1009:1117: SYCL reports errors using exceptions and+ DPCT1009: SYCL reports errors using exceptions anddoes not use error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.@@ -217,7 +217,7 @@ PinnedArena::PinnedArena(uint64_t bytes, const std::vector<uint64_t> &bounds,}} else {/*- DPCT1009:1118: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*/@@ -237,7 +237,7 @@ PinnedArena::PinnedArena(uint64_t bytes, const std::vector<uint64_t> &bounds,// It is the same trap `gr.cu` warns about for ASYNC faults, in the other direction: a synchronous// failure is sticky too, and it lies about where it happened just as convincingly./*- DPCT1010:1119: SYCL uses exceptions to report errors and does not+ DPCT1010: SYCL uses exceptions to report errors and does notuse the error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/@@ -267,7 +267,7 @@ PinnedArena::~PinnedArena() {if (locked_bytes) strata::platform::unlock_resident((uint8_t*) base + (slice_bytes ? registered_bytes : 0), locked_bytes);if (slice_bytes) {/*- DPCT1027:1120: The call to cudaHostUnregister was replaced with 0+ DPCT1027: The call to cudaHostUnregister was replaced with 0because SYCL currently does not support registering of existing hostmemory for use by device. Use USM to allocate memory for use by hostand device.@@ -275,7 +275,7 @@ PinnedArena::~PinnedArena() {for (uint64_t off : slice_starts) 0;} else {/*- DPCT1026:1121: The call to cudaHostUnregister was removed because+ DPCT1026: The call to cudaHostUnregister was removed becauseSYCL currently does not support registering of existing host memoryfor use by device. Use USM to allocate memory for use by host anddevice.@@ -411,7 +411,7 @@ StreamStats stream_bandwidth(const uint8_t *src, uint64_t bytes, uint64_t chunk,// one untimed pass so the first transfer's page-fault and setup cost is not in the measurementfor (uint64_t off = 0; off + chunk <= bytes; off += chunk) {/*- DPCT1124:1122: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -424,7 +424,7 @@ StreamStats stream_bandwidth(const uint8_t *src, uint64_t bytes, uint64_t chunk,for (int it = 0; it < iters; ++it) {for (uint64_t off = 0; off + chunk <= bytes; off += chunk) {/*- DPCT1124:1123: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.diff --git a/sycl/src/core/remote_experts.cpp b/sycl/src/core/remote_experts.cppindex 2cec2f1be..5d198b0fb 100644--- a/sycl/src/core/remote_experts.cpp+++ b/sycl/src/core/remote_experts.cpp@@ -41,7 +41,7 @@ struct DeviceScope {return;}/*- DPCT1093:88: The "device" device may be not the one intended for use.+ DPCT1093: The "device" device may be not the one intended for use.Adjust the selected device if needed.*/status = DPCT_CHECK_ERROR(dpct::select_device(device));@@ -52,7 +52,7 @@ struct DeviceScope {ok = true;}/*- DPCT1093:89: The "previous" device may be not the one intended for use.+ DPCT1093: The "previous" device may be not the one intended for use.Adjust the selected device if needed.*/~DeviceScope() { if (previous >= 0) dpct::select_device(previous); }@@ -60,7 +60,7 @@ struct DeviceScope {return std::string("CUDA") + std::to_string(device) +" experts: " + (failed_step ? failed_step : "device switch") +/*- DPCT1009:90: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the "get_error_string_dummy(...)"with a real error-handling function.*/@@ -74,7 +74,7 @@ struct DeviceScope {bool check(dpct::err0 result, const char *what, std::string &err, int device) {if (result == 0) return true;/*- DPCT1009:91: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -100,18 +100,18 @@ bool RemoteExperts::preflight(int device, double &free_gib,// before the device's context exists, so first thing; STRATA_REMOTE_SPIN=0 keeps the driver's default.const char* spin = std::getenv("STRATA_REMOTE_SPIN");/*- DPCT1007:93: Migration of cudaInitDevice is not supported.+ DPCT1007: Migration of cudaInitDevice is not supported.*/(void) spin; // SYCL: no cudaInitDevice scheduling flags; the runtime picks its own wait policy/*- DPCT1026:92: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/DeviceScope scope(device);if (!scope.ok) { err = scope.error(device); return false; }size_t free_bytes = 0, total_bytes = 0;/*- DPCT1106:94: 'cudaMemGetInfo' was migrated with the Intel extensions for+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensions fordevice information which may not be supported by all compilers or runtimes.You may need to adjust the code.*/@@ -195,7 +195,7 @@ bool RemoteExperts::open(int device, int slots, int64_t layers, int64_t experts,}size_t free_bytes = 0, total_bytes = 0;/*- DPCT1106:96: 'cudaMemGetInfo' was migrated with the Intel extensions for+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensions fordevice information which may not be supported by all compilers or runtimes.You may need to adjust the code.*/@@ -237,19 +237,19 @@ bool RemoteExperts::open(int device, int slots, int64_t layers, int64_t experts,strata::kernels::native_expert_scratch_bytes(CAP, FF));const bool allocated =/*- DPCT1025:97: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/check(DPCT_CHECK_ERROR(stream_ = dpct::get_current_device().create_queue(true)),"stream", err, device) &&/*- DPCT1048:2: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*//*- DPCT1048:3: The original value cudaHostAllocMapped is not meaningful in+ DPCT1048: The original value cudaHostAllocMapped is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -258,12 +258,12 @@ bool RemoteExperts::open(int device, int slots, int64_t layers, int64_t experts,(size_t)CAP * H, dpct::get_in_order_queue())),"input staging", err, device) &&/*- DPCT1048:4: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*//*- DPCT1048:5: The original value cudaHostAllocMapped is not meaningful in+ DPCT1048: The original value cudaHostAllocMapped is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -272,7 +272,7 @@ bool RemoteExperts::open(int device, int slots, int64_t layers, int64_t experts,(size_t)CAP * H, dpct::get_in_order_queue())),"result staging", err, device) &&/*- DPCT1048:6: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -311,7 +311,7 @@ bool RemoteExperts::open(int device, int slots, int64_t layers, int64_t experts,DPCT_CHECK_ERROR(*(void **)&z_x_ = (float *)h_x_) == 0 &&DPCT_CHECK_ERROR(*(void **)&z_out_ = (float *)h_out_) == 0;/*- DPCT1026:95: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/auto *meta = (RemoteMeta *)d_meta_;@@ -405,7 +405,7 @@ bool RemoteExperts::begin(int64_t layer, const float *x, const int32_t *ids,const dpct::queue_ptr s = stream_;const bool staged =/*- DPCT1124:98: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -415,7 +415,7 @@ bool RemoteExperts::begin(int64_t layer, const float *x, const int32_t *ids,s->memcpy(d_x_, h_x_, (size_t)n_tok * H * sizeof(float))),"copy input", err, device_)) &&/*- DPCT1124:99: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -437,7 +437,7 @@ bool RemoteExperts::begin(int64_t layer, const float *x, const int32_t *ids,}const uint64_t compact_bytes = (uint64_t) dst_.size() * H * sizeof(float);/*- DPCT1124:100: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.diff --git a/sycl/src/core/session.cpp b/sycl/src/core/session.cppindex f23b4a0a3..1b3bd7405 100644--- a/sycl/src/core/session.cpp+++ b/sycl/src/core/session.cpp@@ -116,7 +116,7 @@ void session_zero(SessionState& s, const ModelGeometry& g, const float* R_init,if (R_init != nullptr) {for (int64_t c = 0; c < g.hc; ++c)/*- DPCT1124:538: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -234,17 +234,17 @@ bool session_capture(const WeightTable& tables, const ModelGeometry& g, SessionSDPCT_CHECK_ERROR(dpct::experimental::end_recording(cs, &graph));dpct::get_current_device().destroy_queue(cs);/*- DPCT1000:540: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (ce != 0) {/*- DPCT1001:539: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_capture: " + std::string(what) + " layer " +std::to_string(l) + ": " +/*- DPCT1009:541: SYCL reports errors using exceptions and+ DPCT1009: SYCL reports errors using exceptions anddoes not use error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.@@ -301,17 +301,17 @@ bool session_replay(const ModelGeometry &g, int64_t pos, int32_t pos_base,const dpct::err0 e =DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.execs[l]));/*- DPCT1000:543: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:544: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:542: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_replay: layer " + std::to_string(l) + ": " +dpct::get_error_string_dummy(e);@@ -340,17 +340,17 @@ bool session_replay_full(const ModelGeometry &g, int64_t pos, int32_t pos_base,// `post[l]` reads what `pre[l]` wrote, so they cannot be reordered or run concurrently.dpct::err0 e = DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.execs[l]));/*- DPCT1000:546: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:549: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:545: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_replay_full: pre[" + std::to_string(l) +"]: " + dpct::get_error_string_dummy(e);@@ -358,17 +358,17 @@ bool session_replay_full(const ModelGeometry &g, int64_t pos, int32_t pos_base,}e = DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.posts[l]));/*- DPCT1000:548: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:550: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:547: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_replay_full: post[" + std::to_string(l) +"]: " + dpct::get_error_string_dummy(e);@@ -491,17 +491,17 @@ bool session_replay_stage_sweep(const ModelGeometry &g, int64_t pos,const dpct::err0 e =DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.preP[k - 1][l]));/*- DPCT1000:552: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1001:551: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/dpct::destroy_event(a);dpct::destroy_event(b);/*- DPCT1009:553: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*/@@ -578,7 +578,7 @@ bool session_replay_stage_prefixes(const ModelGeometry &g, int64_t pos,for (int64_t l = 0; l < n; ++l) {// The residual as this layer receives it, before any prefix has advanced it./*- DPCT1124:554: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -586,7 +586,7 @@ bool session_replay_stage_prefixes(const ModelGeometry &g, int64_t pos,cs->memcpy(saved, s.block.R, r_floats * sizeof(float));for (int k = 1; k <= 5; ++k) {/*- DPCT1124:557: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -597,18 +597,18 @@ bool session_replay_stage_prefixes(const ModelGeometry &g, int64_t pos,(k == 5) ? gr.execs[l] : gr.preP[k - 1][l];const dpct::err0 e = DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*ge));/*- DPCT1000:556: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1001:555: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("session_replay_stage_prefixes: launch prefix ") +std::to_string(k) + ": " +/*- DPCT1009:558: SYCL reports errors using exceptions and+ DPCT1009: SYCL reports errors using exceptions anddoes not use error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.@@ -723,12 +723,12 @@ bool SessionLoopScratch::init(size_t parts_bytes_in, std::string &err) try {parts_bytes = parts_bytes_in;// MAPPED as well as pinned: the token graph's handoff kernel reads it through its device pointer./*- DPCT1048:0: The original value cudaHostAllocMapped is not meaningful in the+ DPCT1048: The original value cudaHostAllocMapped is not meaningful in themigrated code and was removed or replaced with 0. You may need to check themigrated code.*//*- DPCT1048:1: The original value cudaHostAllocPortable is not meaningful in+ DPCT1048: The original value cudaHostAllocPortable is not meaningful inthe migrated code and was removed or replaced with 0. You may need to checkthe migrated code.*/@@ -844,7 +844,7 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,// the first layer has no previous layer's experts: `y_miss` starts at zero, which is what "hits are empty// in this phase" means once every miss has been computed/*- DPCT1124:559: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -862,7 +862,7 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,if (dump_layers != nullptr) {const size_t n = (size_t) g.hc * (size_t) g.n_embd;/*- DPCT1124:562: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -870,17 +870,17 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,const dpct::err0 de =DPCT_CHECK_ERROR(cs->memcpy(dump_layers, s.R, n * sizeof(float)));/*- DPCT1000:561: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (de != 0) {/*- DPCT1009:563: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:560: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_loop: dump the input residual: " +std::string(dpct::get_error_string_dummy(de));@@ -892,17 +892,17 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,const dpct::err0 le =DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.execs[0]));/*- DPCT1000:565: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (le != 0) {/*- DPCT1009:566: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:564: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_loop: launch pre[0]: " +std::string(dpct::get_error_string_dummy(le));@@ -940,7 +940,7 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,if (q == 0) break; // the graph has endedif (q != 1) {/*- DPCT1009:568: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.@@ -980,7 +980,7 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,// the weights were current. It produced finite, fluent, deterministic tokens that were not the// model's, and no timing test could see it./*- DPCT1124:567: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -994,18 +994,18 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,const dpct::err0 pe =DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.posts[l]));/*- DPCT1000:570: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (pe != 0) {/*- DPCT1009:571: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1001:569: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_loop: launch post[" + std::to_string(l) +"]: " + dpct::get_error_string_dummy(pe);@@ -1019,7 +1019,7 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,if (dump_layers != nullptr) {const size_t n = (size_t) g.hc * (size_t) g.n_embd;/*- DPCT1124:574: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -1027,18 +1027,18 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,const dpct::err0 de = DPCT_CHECK_ERROR(cs->memcpy(dump_layers + (size_t)(l + 1) * n, s.R, n * sizeof(float)));/*- DPCT1000:573: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (de != 0) {/*- DPCT1009:575: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1001:572: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_loop: dump layer " + std::to_string(l) + ": " +dpct::get_error_string_dummy(de);@@ -1060,18 +1060,18 @@ bool session_loop(const ModelGeometry &g, int64_t pos, int32_t pos_base,const dpct::err0 ne =DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*gr.execs[l + 1]));/*- DPCT1000:577: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (ne != 0) {/*- DPCT1009:578: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1001:576: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "session_loop: launch pre[" + std::to_string(l + 1) +"]: " + dpct::get_error_string_dummy(ne);@@ -1138,18 +1138,18 @@ bool session_token(const WeightTable &tables, const ModelGeometry &g,// IT, instead of a wrong number 40 layers later or at the end of the token.const dpct::err0 e = DPCT_CHECK_ERROR(cs->wait());/*- DPCT1000:580: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) {/*- DPCT1009:581: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1001:579: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = "layer " + std::to_string(l) + ": " +dpct::get_error_string_dummy(e);@@ -1235,17 +1235,17 @@ bool session_capture_token(const WeightTable &tables, const ModelGeometry &g,dpct::get_current_device().destroy_queue(cs);if (!ok) { if (graph) delete (graph); return false; }/*- DPCT1000:583: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (ce != 0) {/*- DPCT1009:586: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:582: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("session_capture_token: end capture: ") +dpct::get_error_string_dummy(ce);@@ -1257,17 +1257,17 @@ bool session_capture_token(const WeightTable &tables, const ModelGeometry &g,graph->finalize()));delete (graph);/*- DPCT1000:585: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (ie != 0) {/*- DPCT1009:587: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:584: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("session_capture_token: instantiate: ") +dpct::get_error_string_dummy(ie);@@ -1296,15 +1296,15 @@ bool session_run_token(const ModelGeometry &g, int64_t pos, int32_t pos_base,doorbell_reset(*s.db);const dpct::err0 le = DPCT_CHECK_ERROR(cs->ext_oneapi_graph(*tg.exec));/*- DPCT1009:592: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:588: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:589: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (le != 0) {@@ -1340,7 +1340,7 @@ bool session_run_token(const ModelGeometry &g, int64_t pos, int32_t pos_base,err = "session_run_token: layer " + std::to_string(l) +" never rang (" +/*- DPCT1009:593: SYCL reports errors using exceptions and+ DPCT1009: SYCL reports errors using exceptions anddoes not use error codes. Please replace the"get_error_string_dummy(...)" with a realerror-handling function.@@ -1370,15 +1370,15 @@ bool session_run_token(const ModelGeometry &g, int64_t pos, int32_t pos_base,progress_at("token: waiting for the GPU to finish the token");const dpct::err0 se = DPCT_CHECK_ERROR(cs->wait());/*- DPCT1009:594: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:590: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:591: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (se != 0) {diff --git a/sycl/src/core/verify.cpp b/sycl/src/core/verify.cppindex 02d2af224..ba0c9ca42 100644--- a/sycl/src/core/verify.cpp+++ b/sycl/src/core/verify.cpp@@ -71,7 +71,7 @@ struct Bump {bool mapped(size_t bytes, void **h, void **d) try {/*- DPCT1048:1: The original value cudaHostAllocMapped is not meaningful in the+ DPCT1048: The original value cudaHostAllocMapped is not meaningful in themigrated code and was removed or replaced with 0. You may need to check themigrated code.*/@@ -290,7 +290,7 @@ bool Verifier::init(const WeightTable &wt, const ModelGeometry &g,if (prof_on_) {const size_t np = (size_t) g.n_layers * kProfPer + 4;/*- DPCT1026:36: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/if (DPCT_CHECK_ERROR(prof_ = (unsigned long long *)sycl::malloc_device(@@ -308,7 +308,7 @@ bool Verifier::init(const WeightTable &wt, const ModelGeometry &g,sink_.staging_cap = kStagingBlobs;(void) TS;/*- DPCT1025:37: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (DPCT_CHECK_ERROR(@@ -317,7 +317,7 @@ bool Verifier::init(const WeightTable &wt, const ModelGeometry &g,return false;}/*- DPCT1025:38: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (DPCT_CHECK_ERROR(cs_ = dpct::get_current_device().create_queue(true)) !=@@ -349,7 +349,7 @@ bool Verifier::init(const WeightTable &wt, const ModelGeometry &g,.wait()) == 0;}/*- DPCT1026:39: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/if (!ok2) {; device_plan_ = false; }@@ -579,12 +579,19 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {if (st.kv_q4) { // Q4_0 KV (kv_q4.hpp): K and V rotated before they are storedfwht256_inplace_cuda(kcur_ + tb * NKV * HD, (int64_t) n * NKV, cs);fwht256_inplace_cuda(vcur_ + tb * NKV * HD, (int64_t) n * NKV, cs);+ } else if (st.kv_hybrid) { // K8V4: only V is rotated+ fwht256_inplace_cuda(vcur_ + tb * NKV * HD, (int64_t) n * NKV, cs);}stamp(l, 8, grp);if (grp == 0) copy_from_mapped(tail_snap_ + (size_t) qi * TS, st.idx_tail, TS, cs);for (int t = tb; t < te; ++t) {const int32_t* step_t = step_ + t * kStepCount;- if (st.kv_q4)+ if (st.kv_hybrid) { // K8V4: the unused half's lanes folded onto the used pool (layer.cpp)+ kv_append_q8_step(st.k_q, st.k_q, st.k_scale, st.k_scale, st.page_table, step_t,+ kcur_ + t * NKV * HD, kcur_ + t * NKV * HD, s, cs, nullptr);+ kv_append_q4_step(st.v_q4, st.v_q4, st.page_table, step_t, vcur_ + t * NKV * HD,+ vcur_ + t * NKV * HD, s, cs, nullptr);+ } else if (st.kv_q4)kv_append_q4_step(st.k_q4, st.v_q4, st.page_table, step_t, kcur_ + t * NKV * HD,vcur_ + t * NKV * HD, s, cs, &st.host);else if (st.kv_int8)@@ -604,7 +611,7 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {n, cs);if (qb) {/*- DPCT1124:40: cudaMemcpy2DAsync is migrated to asynchronous+ DPCT1124: cudaMemcpy2DAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -626,7 +633,7 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {for (int t = tb; t < te; ++t) {float* qc = qcur_ + t * NH * HD;/*- DPCT1124:41: cudaMemcpy2DAsync is migrated to asynchronous+ DPCT1124: cudaMemcpy2DAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -661,7 +668,7 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {qsa_decode_attn_batch(qcur_ + tb * NH * HD, pools, sel_ + (size_t) tb * cap_, step_ + tb * kStepCount, cap_,s, attn_scratch_ + (size_t) tb * attn_scratch_floats_, attn_ + tb * NH * HD, n, cs);stamp(l, 13, grp);- if (st.kv_q4) fwht256_inplace_cuda(attn_ + tb * NH * HD, (int64_t) n * NH, cs); // back: H^-1 = H+ if (st.kv_q4 || st.kv_hybrid) fwht256_inplace_cuda(attn_ + tb * NH * HD, (int64_t) n * NH, cs); // back: H^-1 = Hif (qb) native_qsa_gate_apply(attn_ + tb * NH * HD, qfull_ + tb * NH * 2 * HD, attn32_ + tb * NH * HD,(int) (n * NH), (int) HD, cs);else@@ -920,16 +927,16 @@ bool Verifier::capture(int T, std::string &err) try {return false;}/*- DPCT1000:43: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (ce != 0) {/*- DPCT1009:46: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:42: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("verify: end capture: ") +dpct::get_error_string_dummy(ce);@@ -966,23 +973,23 @@ bool Verifier::capture(int T, std::string &err) try {graph->finalize()));delete (graph);/*- DPCT1000:45: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (ie != 0) {/*- DPCT1009:50: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:44: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/err = std::string("verify: instantiate: ") +dpct::get_error_string_dummy(ie);return false;}/*- DPCT1007:51: Migration of cudaGraphUpload is not supported.+ DPCT1007: Migration of cudaGraphUpload is not supported.*/const dpct::err0 ue = 0; // no cudaGraphUpload on SYCL: a finalized command_graph is already residentconst dpct::err0 us = DPCT_CHECK_ERROR(cs_->wait());@@ -990,7 +997,7 @@ bool Verifier::capture(int T, std::string &err) try {stderr,"strata verify: captured the %d-token window (upload %s, sync %s)\n", T,/*- DPCT1009:52: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -1068,7 +1075,7 @@ bool Verifier::capture_commit(std::string &err) try {graph->finalize())) != 0) {if (graph) delete (graph);/*- DPCT1009:53: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -1132,15 +1139,15 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,? (record_window(T, cs_, err) ? 0 : 1) // SYCL port: eager replay of the window body: DPCT_CHECK_ERROR((cs_)->ext_oneapi_graph(*exec_[T]));/*- DPCT1009:58: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:54: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:55: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (le != 0) {err =@@ -1179,7 +1186,7 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,err = "verify: layer " + std::to_string(l) +" never rang (" +/*- DPCT1009:59: SYCL reports errors using exceptions and+ DPCT1009: SYCL reports errors using exceptions anddoes not use error codes. Please replace the"get_error_string_dummy(...)" with a realerror-handling function.@@ -1231,15 +1238,15 @@ bool Verifier::run(int T, const int32_t *tokens, int64_t pos0, PoolMultiFn pool,t_prev_end = t_done;}/*- DPCT1009:60: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:56: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:57: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (se != 0) {err = std::string("verify: ") + dpct::get_error_string_dummy(se);@@ -1426,7 +1433,7 @@ void Verifier::fetch_dma(void* ctx, const uint8_t* const* src, int n, size_t bytif (n <= 0) { raise_flag(v->h_flagB_, want); return; }uint8_t* stage = (uint8_t*) v->sink_.staging; // this group's half in a split window/*- DPCT1124:61: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -1459,15 +1466,15 @@ bool Verifier::commit(int n_keep, std::string &err) try {const dpct::err0 le =DPCT_CHECK_ERROR((cs_)->ext_oneapi_graph(*commit_exec_));/*- DPCT1009:66: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:62: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:63: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (le != 0) {err = std::string("verify: commit launch: ") +@@ -1476,15 +1483,15 @@ bool Verifier::commit(int n_keep, std::string &err) try {}const dpct::err0 se = DPCT_CHECK_ERROR(cs_->wait());/*- DPCT1009:67: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:64: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:65: Error handling if-stmt was detected but could not be rewritten.+ DPCT1000: Error handling if-stmt was detected but could not be rewritten.*/if (se != 0) {err =diff --git a/sycl/src/core/weights.cpp b/sycl/src/core/weights.cppindex e4119797b..e09aa13cf 100644--- a/sycl/src/core/weights.cpp+++ b/sycl/src/core/weights.cpp@@ -202,14 +202,14 @@ bool WeightTable::load(const std::string &pack_dir, void *arena_base,void* stage_in = nullptr;void* stage_out = nullptr;/*- DPCT1048:17: The original value cudaHostAllocDefault is not meaningful in+ DPCT1048: The original value cudaHostAllocDefault is not meaningful inthe migrated code and was removed or replaced with 0. You may need to checkthe migrated code.*/if (DPCT_CHECK_ERROR(stage_in = (void *)sycl::malloc_host(CHUNK, dpct::get_in_order_queue())) != 0 ||/*- DPCT1048:18: The original value cudaHostAllocDefault is not meaningful+ DPCT1048: The original value cudaHostAllocDefault is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -431,7 +431,7 @@ bool WeightTable::load(const std::string &pack_dir, void *arena_base,const double u0 = now_ms();/*- DPCT1114:1055: cudaMemcpy is migrated to asynchronization+ DPCT1114: cudaMemcpy is migrated to asynchronizationmemcpy, assuming in the original code the source host memory ispageable memory. If the memory is not pageable, call wait() onevent return by memcpy API to ensure synchronization behavior.diff --git a/sycl/src/kernels/bf16_gemv_parity.cpp b/sycl/src/kernels/bf16_gemv_parity.cppindex 18c579345..519c7618c 100644--- a/sycl/src/kernels/bf16_gemv_parity.cpp+++ b/sycl/src/kernels/bf16_gemv_parity.cpp@@ -103,7 +103,7 @@ int main(int argc, char** argv) {(size_t)s.n_out * 4, dpct::get_in_order_queue())),"y");/*- DPCT1114:1141: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -112,7 +112,7 @@ int main(int argc, char** argv) {x.size() * 2).wait()),"cx");/*- DPCT1114:1142: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -158,7 +158,7 @@ int main(int argc, char** argv) {// fp16. That is the whole difference between the two contracts at this call site.for (size_t i = 0; i < fp16_as_f32.size(); ++i) x[i] = bf16_from_f32(fp16_as_f32[i]);/*- DPCT1114:1143: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.diff --git a/sycl/src/kernels/cuda/bf16_gemv.dp.cpp b/sycl/src/kernels/cuda/bf16_gemv.dp.cppindex 9ed039587..42996b23f 100644--- a/sycl/src/kernels/cuda/bf16_gemv.dp.cpp+++ b/sycl/src/kernels/cuda/bf16_gemv.dp.cpp@@ -53,7 +53,7 @@ __dpct_inline__ void bf16_gemv_warp_kernel(const uint16_t *__restrict__ x,for (long long i = lane; i < n_in; i += 32)acc += f32_from_bf16(x[i]) * f32_from_bf16(row[i]);/*-DPCT1108:171: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -89,7 +89,7 @@ __dpct_inline__ void bf16_gemv_split_kernel(const uint16_t *__restrict__ x,for (int off = tpr >> 1; off > 0; off >>= 1) {if (t < off) scratch[t] += scratch[t + off];/*- DPCT1118:172: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -99,7 +99,7 @@ __dpct_inline__ void bf16_gemv_split_kernel(const uint16_t *__restrict__ x,inline void finish(void *stream, const char *what) try {/*- DPCT1010:839: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -213,7 +213,7 @@ void bf16_gemv_split(const uint16_t* x, const uint16_t* w, float* y, int64_t n_i}const unsigned grid = (unsigned) n_out;/*- DPCT1049:173: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -224,7 +224,7 @@ void bf16_gemv_split(const uint16_t* x, const uint16_t* w, float* y, int64_t n_istrata::q_of(stream)->submit([&](sycl::handler &cgh) {/*- DPCT1083:1164: The size of local memory in the migrated code may+ DPCT1083: The size of local memory in the migrated code maybe different from the original code. Check that the allocatedmemory size in the migrated code is correct.*/diff --git a/sycl/src/kernels/cuda/cvec.dp.cpp b/sycl/src/kernels/cuda/cvec.dp.cppindex 246fe5ca3..8d0a4be4a 100644--- a/sycl/src/kernels/cuda/cvec.dp.cpp+++ b/sycl/src/kernels/cuda/cvec.dp.cpp@@ -44,7 +44,7 @@ bool upload_here(std::string &err) try {DPCT_CHECK_ERROR(t.on = sycl::malloc_device<int>(1, dpct::get_in_order_queue())) != 0 ||/*- DPCT1114:507: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -53,7 +53,7 @@ bool upload_here(std::string &err) try {t.dir, g_dir_host.data(), g_dir_host.size() * sizeof(float)).wait()) !=0 ||/*- DPCT1114:508: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -82,7 +82,7 @@ __dpct_inline__ float sigmoidf_(float x) {// one block per (stream, token): the pending write, then h . v over the stream, then the update/*-DPCT1110:95: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functioncvec_kernel exceeds 128 bytes and may cause high register pressure. Consult withyour hardware vendor to find the total register size available and adjust thecode, or use smaller sub-group size to avoid high register pressure.@@ -121,7 +121,7 @@ cvec_kernel(float *__restrict__ R, const float *__restrict__ dir,sycl::ext::oneapi::this_work_item::get_work_group<3>());#pragma unroll/*- DPCT1108:98: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -132,11 +132,11 @@ cvec_kernel(float *__restrict__ R, const float *__restrict__ dir,if ((item_ct1.get_local_id(2) & 31) == 0)part[item_ct1.get_local_id(2) >> 5] = dot;/*- DPCT1118:96: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:509: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -147,7 +147,7 @@ cvec_kernel(float *__restrict__ R, const float *__restrict__ dir,: 0.0f;#pragma unroll/*- DPCT1108:99: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -158,11 +158,11 @@ cvec_kernel(float *__restrict__ R, const float *__restrict__ dir,if (item_ct1.get_local_id(2) == 0) part[0] = p;}/*- DPCT1118:97: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:510: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -194,7 +194,7 @@ bool cvec_upload(const std::vector<float>& dir, const std::vector<float>& s, intfor (int d = 0; d < kDevices; ++d) {if (g_dev[d].dir == nullptr) continue;/*- DPCT1093:512: The "d" device may be not the one intended for use. Adjust+ DPCT1093: The "d" device may be not the one intended for use. Adjustthe selected device if needed.*/dpct::select_device(d);@@ -205,7 +205,7 @@ bool cvec_upload(const std::vector<float>& dir, const std::vector<float>& s, intg_dev[d] = DevTables{};}/*- DPCT1093:511: The "prev" device may be not the one intended for use. Adjust+ DPCT1093: The "prev" device may be not the one intended for use. Adjustthe selected device if needed.*/dpct::select_device(prev);@@ -237,7 +237,7 @@ void cvec_set_enabled(bool on) {for (int d = 0; d < kDevices; ++d) {if (g_dev[d].on == nullptr) continue;/*- DPCT1093:514: The "d" device may be not the one intended for use. Adjust+ DPCT1093: The "d" device may be not the one intended for use. Adjustthe selected device if needed.*/dpct::select_device(d);@@ -247,7 +247,7 @@ void cvec_set_enabled(bool on) {dpct::get_in_order_queue().memcpy(g_dev[d].on, &v, sizeof(int)).wait();}/*- DPCT1093:513: The "prev" device may be not the one intended for use. Adjust+ DPCT1093: The "prev" device may be not the one intended for use. Adjustthe selected device if needed.*/dpct::select_device(prev);@@ -287,7 +287,7 @@ void cvec_apply(float *R, int64_t layer, int64_t T, int64_t r_ld,});}/*- DPCT1010:515: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaPeekAtLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/dequant_bf16.dp.cpp b/sycl/src/kernels/cuda/dequant_bf16.dp.cppindex bfdb54fc2..14da1e845 100644--- a/sycl/src/kernels/cuda/dequant_bf16.dp.cpp+++ b/sycl/src/kernels/cuda/dequant_bf16.dp.cpp@@ -45,7 +45,7 @@ __dpct_inline__ void scale_min_k4(int j, const uint8_t *q, int &d, int &m) {// One 32-element group `g` (row-major over the whole slice); `out` points at that group's 32 outputs.template <int TYPE, typename T>/*-DPCT1110:176: The total declared local variable size in device function group32+DPCT1110: The total declared local variable size in device function group32exceeds 128 bytes and may cause high register pressure. Consult with yourhardware vendor to find the total register size available and adjust the code,or use smaller sub-group size to avoid high register pressure.@@ -251,13 +251,13 @@ void launch(int type, const void* blocks, int64_t row0, int64_t rows, int64_t co}#undef STRATA_DQ/*- DPCT1010:854: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:855: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/diff --git a/sycl/src/kernels/cuda/elementwise.dp.cpp b/sycl/src/kernels/cuda/elementwise.dp.cppindex 377de2cbf..731c6fbd1 100644--- a/sycl/src/kernels/cuda/elementwise.dp.cpp+++ b/sycl/src/kernels/cuda/elementwise.dp.cpp@@ -35,14 +35,14 @@ __dpct_inline__ void embedding_gather_kernel(const uint8_t *__restrict__ codes,const int code = (codes[i / per_byte] >> ((i % per_byte) * code_bits)) & mask;const int64_t group = i / group_elems;/*- DPCT1013:1056: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/const float product = (float)(code + code_bias) * scales[group];/*- DPCT1013:1057: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -151,7 +151,7 @@ __dpct_inline__ void rms_norm_weighted_kernel(float *__restrict__ x,#pragma unrollfor (int64_t c = lane; c < cols; c += 32) acc += r[c] * r[c];/*-DPCT1108:275: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -166,7 +166,7 @@ runtimes. You may need to adjust the code.float inv = 0.0f;if (lane == 0) inv = sycl::rsqrt(acc / (float)cols + eps);/*- DPCT1108:276: '__shfl_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -191,7 +191,7 @@ catch (sycl::exception const &exc) {bool check_launch(const char* what) {/*- DPCT1010:1059: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -365,7 +365,7 @@ void silu_inplace(float* x, int64_t n, void* stream) {/// very expensive substitute for one fence instruction.__dpct_inline__ void doorbell_ring_kernel(uint32_t *seq) {/*- DPCT1078:277: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictionsare needed.*/@@ -377,13 +377,13 @@ __dpct_inline__ void doorbell_wait_kernel(const volatile uint32_t *flag,const volatile uint32_t *seq) {const uint32_t want = strata::sys_load(seq);/*- DPCT1008:1061: __nanosleep function is not defined in SYCL. This is a+ DPCT1008: __nanosleep function is not defined in SYCL. This is ahardware-specific feature. Consult with your hardware vendor to find areplacement.*/for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) != want; ++spin) {}/*- DPCT1078:278: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictionsare needed.*/@@ -407,7 +407,7 @@ void doorbell_wait(const uint32_t* d_flag, const uint32_t* d_seq, void* stream)}/*-DPCT1052:1062: SYCL does not support the member access for a volatile qualified+DPCT1052: SYCL does not support the member access for a volatile qualifiedvector type. The volatile qualifier was removed. You may need to rewrite thecode.*/@@ -428,7 +428,7 @@ __dpct_inline__ void copy_from_mapped_kernel(sycl::float4 *__restrict__ dst,// the CPU rows of a verify window, skipping the rows the GPU plan computes itself (the// pool writes +0.0 into those, so this writes +0.0 too): block = row, the plan's hit rows `dst[0, *count)`./*-DPCT1052:1063: SYCL does not support the member access for a volatile qualified+DPCT1052: SYCL does not support the member access for a volatile qualifiedvector type. The volatile qualifier was removed. You may need to rewrite thecode.*/@@ -455,7 +455,7 @@ __dpct_inline__ void copy_rows_from_mapped_kernel(d[i] = sycl::float4(0.0f, 0.0f, 0.0f, 0.0f);} else {/*- DPCT1052:1064: SYCL does not support the member access for a volatile+ DPCT1052: SYCL does not support the member access for a volatilequalified vector type. The volatile qualifier was removed. You may needto rewrite the code.*/@@ -537,20 +537,20 @@ __dpct_inline__ void doorbell_publish_kernel(const float *__restrict__ x,w_out[item_ct1.get_local_id(2)] = w[item_ct1.get_local_id(2)];}/*- DPCT1078:279: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictionsare needed.*/sycl::atomic_fence(sycl::memory_order::acq_rel, sycl::memory_scope::system);/*- DPCT1065:1065: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier();if (item_ct1.get_local_id(2) == 0) {/*- DPCT1078:280: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory orderrestrictions are needed.*/@@ -564,7 +564,7 @@ void doorbell_publish(const float* x, const int32_t* ids, const float* weights,int32_t* ids_out, float* weights_out, uint32_t* d_seq, void* stream) {if (k > 1024) { std::fprintf(stderr, "doorbell_publish: k too large\n"); std::exit(1); }/*- DPCT1049:281: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/fused_gdn.dp.cpp b/sycl/src/kernels/cuda/fused_gdn.dp.cppindex 0e587e88e..eca2bab0e 100644--- a/sycl/src/kernels/cuda/fused_gdn.dp.cpp+++ b/sycl/src/kernels/cuda/fused_gdn.dp.cpp@@ -16,7 +16,7 @@ constexpr int RG = 4; // row groupsconstexpr int RPG = S / RG; // 32 rows per thread/*-DPCT1110:292: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongdn_step_norm_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -50,7 +50,7 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(#pragma unrollfor (int r = 0; r < RPG; ++r) s[r] = base[r * row_stride];/*- DPCT1065:1151: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -61,7 +61,7 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(for (int r = 0; r < RPG; ++r) kv = sycl::fma(s[r], sk[rg * RPG + r], kv);red[rg][col] = kv;/*- DPCT1065:1152: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -76,14 +76,14 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(base[r * row_stride] = s[r];}/*- DPCT1065:1153: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier(); // every thread has read red[] for kv_colred[rg][col] = o;/*- DPCT1065:1154: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -96,7 +96,7 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(}// RMS over the head's 128 outputs: warps of row group 0 are threads 0..127./*-DPCT1108:293: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -107,7 +107,7 @@ runtimes. You may need to adjust the code.sq_part, o2);if ((tid & 31) == 0) wsum[tid >> 5] = sq_part;/*- DPCT1065:1155: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -140,7 +140,7 @@ auto &part =if ((int)item_ct1.get_group(2) < qk_heads) {float sq = y * y;/*-DPCT1108:295: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -152,11 +152,11 @@ runtimes. You may need to adjust the code.if ((item_ct1.get_local_id(2) & 31) == 0)part[item_ct1.get_local_id(2) >> 5] = sq;/*- DPCT1118:294: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:1156: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -183,7 +183,7 @@ gdn_ab_kernel(const float *__restrict__ x, const uint16_t *__restrict__ wa,float acc = 0.0f;for (int j = lane; j < n / 8; j += 32) {/*- DPCT1098:1157: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -210,7 +210,7 @@ gdn_ab_kernel(const float *__restrict__ x, const uint16_t *__restrict__ wa,(float)(xb.w()), acc);}/*-DPCT1108:296: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -254,13 +254,13 @@ void fused_gdn_conv_l2(float* history, const float* qkv, const float* conv_w, fl});}/*- DPCT1010:1158: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:1159: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -290,13 +290,13 @@ void fused_gdn_ab(const float* x, const uint16_t* w_alpha, const uint16_t* w_bet});}/*- DPCT1010:1160: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:1161: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -310,7 +310,7 @@ void fused_gdn_step_norm(float* state, const float* q, const float* k, const flostd::exit(1);}/*- DPCT1049:297: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -331,7 +331,7 @@ void fused_gdn_step_norm(float* state, const float* q, const float* k, const flo});}/*- DPCT1010:1162: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/fused_gr.dp.cpp b/sycl/src/kernels/cuda/fused_gr.dp.cppindex 431e90b5f..86375f1d5 100644--- a/sycl/src/kernels/cuda/fused_gr.dp.cpp+++ b/sycl/src/kernels/cuda/fused_gr.dp.cpp@@ -26,7 +26,7 @@ constexpr int UP_BLOCKS = N / UP_COLS; // 80__dpct_inline__ float warp_sum(float v) {#pragma unroll/*- DPCT1108:88: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -55,7 +55,7 @@ __dpct_inline__ float dot8(const sycl::uint4 w, const float *x) {}/*-DPCT1110:89: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongr_down_kernel exceeds 128 bytes and may cause high register pressure. Consultwith your hardware vendor to find the total register size available and adjustthe code, or use smaller sub-group size to avoid high register pressure.@@ -102,7 +102,7 @@ auto &xn = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[D]>(if (lane == 0) part[warp][c] = v;}/*- DPCT1065:457: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -115,7 +115,7 @@ auto &xn = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[D]>(if (item_ct1.get_group(2) == 0) a.rs[t] = s_rs[t];}/*- DPCT1065:458: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -123,7 +123,7 @@ auto &xn = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[D]>(#pragma unrollfor (int i = t; i < D; i += THREADS) xn[i] *= s_rs[i / N];/*- DPCT1065:459: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -137,7 +137,7 @@ auto &xn = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[D]>(float acc = 0.0f;#pragma unroll 4/*- DPCT1098:460: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -164,7 +164,7 @@ auto &lo = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[LR]>(#pragma unrollfor (int k = t; k < LR; k += THREADS) lo[k] = a.lo[k];/*- DPCT1065:461: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -175,13 +175,13 @@ auto &lo = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[LR]>(const sycl::uint4 *w4 =reinterpret_cast<const sycl::uint4 *>(a.w_up + (size_t)i * LR);/*- DPCT1098:463: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/float acc = dot8(*(w4 + lane), lo + lane * 8);/*- DPCT1098:464: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -200,7 +200,7 @@ auto &lo = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[LR]>(}}/*- DPCT1065:462: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -222,7 +222,7 @@ struct GrMulti {// Step 1 of `gr_down_kernel`, one block per token, same threads and reduction order: rs[t] and xn[t] to global./*-DPCT1110:90: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongr_norm_multi_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -268,7 +268,7 @@ auto &part =if (lane == 0) part[warp][c] = v;}/*- DPCT1065:465: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -281,7 +281,7 @@ auto &part =a.rs[t] = s_rs[t];}/*- DPCT1065:466: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -290,14 +290,18 @@ auto &part =for (int i = t; i < D; i += THREADS) xn[i] *= s_rs[i / N];}+#if defined(__HIPCC__)+constexpr int TILE = 1280; // eight-token tile fits gfx1100's 64 KiB LDS limit+#elseconstexpr int TILE = 2560; // xn floats per token staged at a time: 320 chunks of 8, 10 per lane+#endifconstexpr int TQ = TILE / 8 / 32; // uint4 weight chunks per lane per tile// Step 2 of `gr_down_kernel` for T tokens. One warp per row (so each lane accumulates the same chunks in the// same order as the single-token kernel); per tile the lane's 10 weight chunks are loaded BEFORE the activation// tile is staged, so the DRAM and L2 traffic are in flight together./*-DPCT1110:91: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongr_down_multi_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -320,7 +324,7 @@ __dpct_inline__ void gr_down_multi_kernel(GrMulti m, uint8_t *dpct_local) {if (active) {#pragma unroll/*- DPCT1098:469: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality.Check the generated code for potential precision and/or performanceissues.@@ -329,11 +333,11 @@ __dpct_inline__ void gr_down_multi_kernel(GrMulti m, uint8_t *dpct_local) {wv[q] = *(w4 + base / 8 + lane + 32 * q);}/*- DPCT1118:92: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:467: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -345,11 +349,11 @@ __dpct_inline__ void gr_down_multi_kernel(GrMulti m, uint8_t *dpct_local) {tile4[i] = src4[((size_t) k * D + base) / 4 + off];}/*- DPCT1118:93: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:468: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -386,7 +390,7 @@ constexpr int UPM_BLOCKS = N / UPM_COLS; // 160// `gr_up_kernel` for T tokens: each row of w_up read once; the T dots reduced by xor so every lane holds every// sum, and lane k runs token k's epilogue - the T epilogues in parallel instead of one after another./*-DPCT1110:94: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongr_up_multi_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -406,7 +410,7 @@ auto &lo = *sycl::ext::oneapi::group_local_memory_for_overwrite<for (int i = t; i < T * LR; i += THREADS)lo[i / LR][i % LR] = m.a[i / LR].lo[i % LR];/*- DPCT1065:470: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -416,13 +420,13 @@ auto &lo = *sycl::ext::oneapi::group_local_memory_for_overwrite<const sycl::uint4 *w4 =reinterpret_cast<const sycl::uint4 *>(m.a[0].w_up + (size_t)i * LR);/*- DPCT1098:472: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/const sycl::uint4 wa = *(w4 + lane);/*- DPCT1098:473: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -458,7 +462,7 @@ auto &lo = *sycl::ext::oneapi::group_local_memory_for_overwrite<}}/*- DPCT1065:471: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -498,7 +502,7 @@ void fused_gr_read_multi(const FusedGrArgs* a, int n_tok, float* xn_scratch, voiauto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class gr_norm_multi_kernel_bf1e13>>(+ st->parallel_for<dpct_kernel_name<class gr_norm_multi_kernel_2f4d92>>(sycl::nd_range<3>(sycl::range(1, 1, n_tok) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -511,13 +515,14 @@ void fused_gr_read_multi(const FusedGrArgs* a, int n_tok, float* xn_scratch, voi// the shared-memory opt-in is a per-DEVICE setting: once per device, not once per process (a layer split// runs this kernel on two cards)static bool attr[64] = {};+ static int chunk[64] = {}; // Turing port: tokens the down kernel may carry in one launch on this cardint dev = 0;dev = dpct::get_current_device_id();- if (dev < 0 || dev >= 64 || !attr[dev]) {+ if (dev >= 0 && dev < 64 && !attr[dev]) {// at most what the card allows (Turing: 64 KB - enough for windows of up to 6 tokens)int optin = 0;/*- DPCT1019:474: local_mem_size in SYCL is not a complete equivalent of+ DPCT1019: local_mem_size in SYCL is not a complete equivalent ofcudaDevAttrMaxSharedMemoryPerBlockOptin in CUDA. You may need to adjustthe code.*/@@ -525,30 +530,40 @@ void fused_gr_read_multi(const FusedGrArgs* a, int n_tok, float* xn_scratch, voiint want = (int) (kFusedGrMaxT * TILE * sizeof(float));if (optin > 0 && want > optin) want = optin;/*- DPCT1026:475: The call to cudaFuncSetAttribute was removed because SYCL+ DPCT1026: The call to cudaFuncSetAttribute was removed because SYCLcurrently does not support corresponding setting.*//*- DPCT1026:476: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/- if (dev >= 0 && dev < 64) attr[dev] = true;+; // drop any error the attempt left behind+ // Turing port: the down kernel stages n_tok*TILE floats of dynamic shared memory - 80 KB at the full+ // 8 tokens. A card whose opt-in is below that (Turing: 64 KB, so 7+ tokens fail to launch as+ // "invalid argument") processes the tokens in slices that fit; a card that reports no opt-in gets what+ // fits the 48 KB default (4 tokens of the CUDA tile; all 8 of HIP's smaller tile). The down kernel's+ // outputs (lo, inject_out) are strictly per-token, so the chunk boundaries are safe, and the up kernel+ // below still sees every token of the batch in one launch.+ const int capacity = (optin > 0 ? optin : 48 * 1024) / (int) (TILE * sizeof(float));+ chunk[dev] = capacity < 1 ? 1 : (capacity > kFusedGrMaxT ? kFusedGrMaxT : capacity);+ attr[dev] = true;}- {+ const int chunk_tok = (dev >= 0 && dev < 64 && chunk[dev]) ? chunk[dev] : kFusedGrMaxT;+ if (chunk_tok >= n_tok) {auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};st->submit([&](sycl::handler &cgh) {/*- DPCT1083:1166: The size of local memory in the migrated code may be- different from the original code. Check that the allocated memory- size in the migrated code is correct.+ DPCT1083: The size of local memory in the migrated code may+ be different from the original code. Check that the allocated+ memory size in the migrated code is correct.*/sycl::local_accessor<uint8_t, 1> dpct_local_acc_ct1(sycl::range((size_t)n_tok * TILE * sizeof(float)), cgh);cgh.parallel_for<- dpct_kernel_name<class gr_down_multi_kernel_e2a6b0>>(+ dpct_kernel_name<class gr_down_multi_kernel_7f5820>>(sycl::nd_range<3>(sycl::range(1, 1, DOWN_BLOCKS + 1) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -561,13 +576,50 @@ void fused_gr_read_multi(const FusedGrArgs* a, int n_tok, float* xn_scratch, voi.get());});});+ } else {+ for (int c0 = 0; c0 < n_tok; c0 += chunk_tok) {+ const int ct = n_tok - c0 < chunk_tok ? n_tok - c0 : chunk_tok;+ GrMulti c{};+ c.xn = xn_scratch + (size_t) c0 * D;+ c.T = ct;+ for (int k = 0; k < ct; ++k) c.a[k] = a[c0 + k];+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};++ st->submit([&](sycl::handler &cgh) {+ /*+ DPCT1083: The size of local memory in the migrated code+ may be different from the original code. Check that the+ allocated memory size in the migrated code is correct.+ */+ sycl::local_accessor<uint8_t, 1> dpct_local_acc_ct1(+ sycl::range((size_t)ct * TILE * sizeof(float)), cgh);++ cgh.parallel_for<+ dpct_kernel_name<class gr_down_multi_kernel_88cb86>>(+ sycl::nd_range<3>(sycl::range(1, 1, DOWN_BLOCKS + 1) *+ sycl::range(1, 1, THREADS),+ sycl::range(1, 1, THREADS)),+ exp_props,+ [=](sycl::nd_item<3> item_ct1)+ [[sycl::reqd_sub_group_size(32)]] {+ gr_down_multi_kernel(+ c, dpct_local_acc_ct1+ .get_multi_ptr<+ sycl::access::decorated::no>()+ .get());+ });+ });+ }+ }}if (stamp_buf) gpu_stamp(stamp_buf, stamp_i0 + 1, stream);{auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class gr_up_multi_kernel_e2528e>>(+ st->parallel_for<dpct_kernel_name<class gr_up_multi_kernel_1a727f>>(sycl::nd_range<3>(sycl::range(1, 1, UPM_BLOCKS) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -577,7 +629,7 @@ void fused_gr_read_multi(const FusedGrArgs* a, int n_tok, float* xn_scratch, voi});}/*- DPCT1010:477: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -600,7 +652,7 @@ void fused_gr_read(const FusedGrArgs& a, void* stream) {auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class gr_down_kernel_5d714c>>(+ st->parallel_for<dpct_kernel_name<class gr_down_kernel_a5fa71>>(sycl::nd_range<3>(sycl::range(1, 1, DOWN_BLOCKS + 1) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -613,7 +665,7 @@ void fused_gr_read(const FusedGrArgs& a, void* stream) {auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class gr_up_kernel_86511f>>(+ st->parallel_for<dpct_kernel_name<class gr_up_kernel_fe3258>>(sycl::nd_range<3>(sycl::range(1, 1, UP_BLOCKS) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -623,7 +675,7 @@ void fused_gr_read(const FusedGrArgs& a, void* stream) {});}/*- DPCT1010:479: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/gdn.dp.cpp b/sycl/src/kernels/cuda/gdn.dp.cppindex b56c96294..3373560ad 100644--- a/sycl/src/kernels/cuda/gdn.dp.cpp+++ b/sycl/src/kernels/cuda/gdn.dp.cpp@@ -84,7 +84,7 @@ auto &ks =}}/*- DPCT1065:326: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -155,7 +155,7 @@ __dpct_inline__ void gdn_l2_kernel(float *__restrict__ x, int cols, float eps) {i += item_ct1.get_local_range(2)) acc += (double)p[i] * (double)p[i];// warp reduction/*-DPCT1108:35: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -168,7 +168,7 @@ runtimes. You may need to adjust the code.sycl::ext::oneapi::this_work_item::get_work_group<3>());if (item_ct1.get_local_id(2) == 0) ssum = acc;/*- DPCT1065:327: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -195,7 +195,7 @@ __dpct_inline__ void gdn_out_norm_kernel(const float *__restrict__ o,for (int i = item_ct1.get_local_id(2); i < S;i += item_ct1.get_local_range(2)) acc += (double)po[i] * (double)po[i];/*-DPCT1108:36: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/diff --git a/sycl/src/kernels/cuda/gr.dp.cpp b/sycl/src/kernels/cuda/gr.dp.cppindex 4091f3f96..fd8f809b1 100644--- a/sycl/src/kernels/cuda/gr.dp.cpp+++ b/sycl/src/kernels/cuda/gr.dp.cpp@@ -76,12 +76,12 @@ __dpct_inline__ float sigmoid_f(float x) {__dpct_inline__ double warp_sum(double v) {/*-DPCT1108:37: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*-DPCT1121:38: Make sure that the "v" which is used in the SYCL group+DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/#pragma unroll@@ -90,12 +90,12 @@ function/algorithm is initialized.0xFFFFFFFFu, sycl::ext::oneapi::this_work_item::get_sub_group(), v,off);/*- DPCT1108:39: '__shfl_sync' was migrated with the experimental feature masked+ DPCT1108: '__shfl_sync' was migrated with the experimental feature maskedsub_group function which may not be supported by all compilers or runtimes.You may need to adjust the code.*//*- DPCT1121:40: Make sure that the "v" which is used in the SYCL group+ DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/return dpct::experimental::select_from_sub_group(@@ -104,12 +104,12 @@ function/algorithm is initialized.__dpct_inline__ float warp_sumf(float v) {/*-DPCT1108:41: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*-DPCT1121:42: Make sure that the "v" which is used in the SYCL group+DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/#pragma unroll@@ -118,12 +118,12 @@ function/algorithm is initialized.0xFFFFFFFFu, sycl::ext::oneapi::this_work_item::get_sub_group(), v,off);/*- DPCT1108:43: '__shfl_sync' was migrated with the experimental feature masked+ DPCT1108: '__shfl_sync' was migrated with the experimental feature maskedsub_group function which may not be supported by all compilers or runtimes.You may need to adjust the code.*//*- DPCT1121:44: Make sure that the "v" which is used in the SYCL group+ DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/return dpct::experimental::select_from_sub_group(@@ -143,7 +143,7 @@ inline float block_sumf(float v, double *scratch_raw) {// of `scratch[0]` by every thread and a later call reuses the array, so without it a fast thread can// overwrite `scratch[0]` before a slow one has read the previous result./*- DPCT1065:355: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -153,7 +153,7 @@ inline float block_sumf(float v, double *scratch_raw) {v = warp_sumf(v);if (lane == 0) scratch[warp] = v;/*- DPCT1065:356: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -164,7 +164,7 @@ inline float block_sumf(float v, double *scratch_raw) {if (warp == 0) v = warp_sumf(v);if (item_ct1.get_local_id(2) == 0) scratch[0] = v;/*- DPCT1065:357: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -183,7 +183,7 @@ inline float block_sumf(float v, double *scratch_raw) {/// `scratch[0]` before a slow one has read the previous result - a race that is invisible in most runs.double block_sum(double v, double* scratch) {/*- DPCT1065:358: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -194,7 +194,7 @@ double block_sum(double v, double* scratch) {v = warp_sum(v);if (lane == 0) scratch[warp] = v;/*- DPCT1065:359: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -205,7 +205,7 @@ double block_sum(double v, double* scratch) {if (warp == 0) v = warp_sum(v);if (item_ct1.get_local_id(2) == 0) scratch[0] = v;/*- DPCT1065:360: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -624,7 +624,7 @@ void gr_read(const float *R, const float *w_norm, const uint16_t *w_down,bf16_gemv_fp32_mmvf(ws.xn, w_inject, inject, hc_dim, hc, stream);else if (use_fp32)/*- DPCT1049:45: The work-group size passed to the SYCL kernel may+ DPCT1049: The work-group size passed to the SYCL kernel mayexceed the limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size ifneeded.@@ -645,7 +645,7 @@ void gr_read(const float *R, const float *w_norm, const uint16_t *w_down,});} else/*- DPCT1049:46: The work-group size passed to the SYCL kernel may+ DPCT1049: The work-group size passed to the SYCL kernel mayexceed the limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size ifneeded.@@ -668,7 +668,7 @@ void gr_read(const float *R, const float *w_norm, const uint16_t *w_down,}/*- DPCT1010:361: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -699,7 +699,7 @@ void gr_write(const float *R, const float *block_out, const float *inject,strata::q_of(stream)->submit([&](sycl::handler &cgh) {/*- DPCT1083:1165: The size of local memory in the migrated code may+ DPCT1083: The size of local memory in the migrated code maybe different from the original code. Check that the allocatedmemory size in the migrated code is correct.*/diff --git a/sycl/src/kernels/cuda/iq_kernels.dp.cpp b/sycl/src/kernels/cuda/iq_kernels.dp.cppindex 2c7eab329..5a30fe7bd 100644--- a/sycl/src/kernels/cuda/iq_kernels.dp.cpp+++ b/sycl/src/kernels/cuda/iq_kernels.dp.cpp@@ -23,13 +23,13 @@ namespace {void check(const char* what) {/*- DPCT1010:928: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:929: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -393,7 +393,7 @@ template<> struct Fmt<42> { static constexpr int qk = 64, ipb = 2, step = 1;__dpct_inline__ float warp_sum(float v) {#pragma unroll/*- DPCT1108:230: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -439,7 +439,7 @@ __dpct_inline__ float row_dot(const uint8_t *row, const block_q8_1 *x, int nb,for (int k = lane; k < nb * F::ipb; k += 32) {const int kbx = k / F::ipb, iqs = F::step * (k % F::ipb);/*- DPCT1084:298: The function call "Fmt::dot" has multiple migration+ DPCT1084: The function call "Fmt::dot" has multiple migrationresults in different template instantiations that could not be unified.You may need to adjust the code.*/@@ -768,7 +768,7 @@ __dpct_inline__ void quantize_q8_1_kernel(const float *__restrict__ x,#pragma unrollfor (int o = 16; o > 0; o >>= 1) {/*- DPCT1108:231: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -778,7 +778,7 @@ __dpct_inline__ void quantize_q8_1_kernel(const float *__restrict__ x,0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),amax, o));/*- DPCT1108:232: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -1052,7 +1052,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int nconst auto* X = (const block_q8_1*) x_q8_1;switch (t) {/*- DPCT1049:233: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1073,7 +1073,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:234: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1094,7 +1094,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:235: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1115,7 +1115,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:236: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1136,7 +1136,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:237: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1157,7 +1157,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:238: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1178,7 +1178,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:239: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1199,7 +1199,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:240: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1220,7 +1220,7 @@ void iq_mmvq(int t, const void* w, const void* x_q8_1, float* y, int n_in, int n});} break;/*- DPCT1049:241: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/kv_q4.dp.cpp b/sycl/src/kernels/cuda/kv_q4.dp.cppindex 8834a75fb..630fe2e9f 100644--- a/sycl/src/kernels/cuda/kv_q4.dp.cpp+++ b/sycl/src/kernels/cuda/kv_q4.dp.cpp@@ -16,7 +16,7 @@ namespace {void check(const char* what) {/*- DPCT1010:430: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -54,7 +54,7 @@ __dpct_inline__ void fwht256_kernel(const float *__restrict__ src,for (int j = 0; j < el_w; ++j) {const float val = reg[j];/*- DPCT1108:77: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -92,7 +92,7 @@ __dpct_inline__ uint16_t q4_group(float x, int lane, uint8_t &byte) {#pragma unrollfor (int o = 16; o > 0; o >>= 1) {/*- DPCT1108:78: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -100,7 +100,7 @@ __dpct_inline__ uint16_t q4_group(float x, int lane, uint8_t &byte) {0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),amax, o);/*- DPCT1108:79: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -115,7 +115,7 @@ __dpct_inline__ uint16_t q4_group(float x, int lane, uint8_t &byte) {.convert<int, sycl::rounding_mode::rtz>()[0];const uint8_t qc = (uint8_t) (q < 0 ? 0 : (q > 15 ? 15 : q));/*- DPCT1108:80: '__shfl_down_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -142,7 +142,7 @@ __dpct_inline__ void kv_append_q4_kernel(const float *__restrict__ kcur, const float *__restrict__ vcur,int kv_heads, int head_dim, int page_size, KvHostPools host) {/*- DPCT1098:432: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -191,7 +191,7 @@ __dpct_inline__ void kv_gather_q4_kernel(const int32_t *__restrict__ step, int kv_heads, int head_dim, int page_size,uint16_t *__restrict__ k_scratch, uint16_t *__restrict__ v_scratch) {/*- DPCT1098:433: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/diff --git a/sycl/src/kernels/cuda/kv_q8.dp.cpp b/sycl/src/kernels/cuda/kv_q8.dp.cppindex 952d40ad9..215ea943f 100644--- a/sycl/src/kernels/cuda/kv_q8.dp.cpp+++ b/sycl/src/kernels/cuda/kv_q8.dp.cpp@@ -14,7 +14,7 @@ namespace {void check(const char* what) {/*- DPCT1010:1135: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -37,7 +37,7 @@ __dpct_inline__ void kv_append_q8_kernel(const float *__restrict__ kcur, const float *__restrict__ vcur,int kv_heads, int head_dim, int page_size, KvHostPools host) {/*- DPCT1098:1138: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -51,7 +51,7 @@ __dpct_inline__ void kv_append_q8_kernel(// max |x| over the 64 values: two warps, then combine through shared memory in a fixed orderfloat a = sycl::fabs(x);/*-DPCT1108:289: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -65,7 +65,7 @@ runtimes. You may need to adjust the code.sycl::ext::oneapi::this_work_item::get_work_group<3>());if ((t & 31) == 0) warp_max[t >> 5] = a;/*- DPCT1065:1137: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -101,7 +101,7 @@ __dpct_inline__ void kv_gather_q8_kernel(const int32_t *__restrict__ step, int kv_heads, int head_dim, int page_size,uint16_t *__restrict__ k_scratch, uint16_t *__restrict__ v_scratch) {/*- DPCT1098:1139: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/diff --git a/sycl/src/kernels/cuda/kv_stream.dp.cpp b/sycl/src/kernels/cuda/kv_stream.dp.cppindex fe1769d1b..d8118d42b 100644--- a/sycl/src/kernels/cuda/kv_stream.dp.cpp+++ b/sycl/src/kernels/cuda/kv_stream.dp.cpp@@ -17,7 +17,7 @@ namespace {void check(const char* what) {/*- DPCT1010:314: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -66,7 +66,7 @@ inline int block_scan(int v, int *warp_sums, int &total) {int x = v;for (int o = 1; o < 32; o <<= 1) {/*- DPCT1108:29: '__shfl_up_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_up_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -77,7 +77,7 @@ inline int block_scan(int v, int *warp_sums, int &total) {}if (lane == 31) warp_sums[w] = x;/*- DPCT1065:316: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -86,7 +86,7 @@ inline int block_scan(int v, int *warp_sums, int &total) {int t = warp_sums[lane];for (int o = 1; o < 32; o <<= 1) {/*- DPCT1108:30: '__shfl_up_sync' was migrated with the experimental+ DPCT1108: '__shfl_up_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -98,7 +98,7 @@ inline int block_scan(int v, int *warp_sums, int &total) {warp_sums[lane] = t;}/*- DPCT1065:317: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -106,7 +106,7 @@ inline int block_scan(int v, int *warp_sums, int &total) {total = warp_sums[31];const int excl = x - v + (w > 0 ? warp_sums[w - 1] : 0);/*- DPCT1065:318: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -131,7 +131,7 @@ auto &s_nmiss = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(const int epoch = m.ctl[0] + 1;if (item_ct1.get_local_id(2) == 0) { s_nmiss = 0; s_lookups = 0; }/*- DPCT1065:319: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -162,7 +162,7 @@ auto &s_nmiss = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(dpct::atomic_fetch_add<sycl::access::address_space::generic_space>(&s_lookups, lookups);/*- DPCT1065:320: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -180,11 +180,11 @@ auto &s_nmiss = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(const int want = need - got;if (item_ct1.get_local_id(2) == 0) s_cut = RT;/*- DPCT1118:31: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:321: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -193,11 +193,11 @@ auto &s_nmiss = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(item_ct1.get_local_id(2) +1; // the hand stops just past the last slot taken/*- DPCT1118:32: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:322: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -212,11 +212,11 @@ auto &s_nmiss = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(got += total < want ? total : want;hand = (int) (((long long) hand + cut) % n);/*- DPCT1118:33: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:323: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -331,7 +331,7 @@ void kv_stream_resolve(const KvStreamMap& m, const QsaAttnPools& slots, const Kvstd::exit(1);}/*- DPCT1049:34: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -396,7 +396,7 @@ void kv_ring_restore(const QsaAttnPools &slots, const KvHostPools &host,const int64_t sl = b % n_slots, run = std::min<int64_t>(b1 - b, n_slots - sl); // up to the ring's endfor (int a = 0; a < r.n; ++a)/*- DPCT1124:324: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -421,7 +421,7 @@ void kv_stage_from_host(const QsaAttnPools &stage, const KvHostPools &host,const Runs r = runs_of(stage, host, fmt, s);for (int a = 0; a < r.n; ++a)/*- DPCT1124:325: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.diff --git a/sycl/src/kernels/cuda/native_bf16.dp.cpp b/sycl/src/kernels/cuda/native_bf16.dp.cppindex 6745f0798..61f059015 100644--- a/sycl/src/kernels/cuda/native_bf16.dp.cpp+++ b/sycl/src/kernels/cuda/native_bf16.dp.cpp@@ -41,7 +41,7 @@ __dpct_inline__ float mmvf_warp_sum(float value) {#pragma unrollfor (int offset = 16; offset > 0; offset >>= 1)/*- DPCT1108:288: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -73,14 +73,14 @@ __dpct_inline__ void bf16_f32_mmvf_kernel(const float *__restrict__ x,const sycl::float2 input = inputs2[pair];// Match the two ordered multiply-adds in ggml_cuda_mad, not a pair sum followed by one add./*- DPCT1013:1094: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.*/acc = sycl::fma(f32_from_bf16((uint16_t)weight), input.x(), acc);/*- DPCT1013:1095: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -131,14 +131,14 @@ __dpct_inline__ void bf16_f32_mmvf_multi_kernel(reinterpret_cast<const sycl::float2 *>(x + (size_t)k *ldx)[pair];/*- DPCT1013:1096: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the originalcode. Verify the correctness. SYCL math built-in functionrounding mode is aligned with OpenCL C 1.2 standard.*/acc[k] = sycl::fma(w0, input.x(), acc[k]);/*- DPCT1013:1097: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the originalcode. Verify the correctness. SYCL math built-in functionrounding mode is aligned with OpenCL C 1.2 standard.@@ -249,23 +249,23 @@ void bf16_gemv_fp32_mmvf_multi(const float* x, int64_t ldx, const uint16_t* w, f}#undef STRATA_MMVF_M/*- DPCT1010:1100: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 result = 0;/*- DPCT1000:1099: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (result != 0)/*- DPCT1009:1101: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:1098: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("bf16_gemv_fp32_mmvf_multi launch: ") +@@ -319,23 +319,23 @@ void bf16_gemv_fp32_mmvf(const float* x, const uint16_t* w, float* y,}#undef STRATA_MMVF_CASE/*- DPCT1010:1104: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 result = 0;/*- DPCT1000:1103: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (result != 0)/*- DPCT1009:1105: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:1102: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("bf16_gemv_fp32_mmvf launch: ") +dpct::get_error_string_dummy(result));diff --git a/sycl/src/kernels/cuda/native_flash_attn.dp.cpp b/sycl/src/kernels/cuda/native_flash_attn.dp.cppindex 55c204a19..4b2d29512 100644--- a/sycl/src/kernels/cuda/native_flash_attn.dp.cpp+++ b/sycl/src/kernels/cuda/native_flash_attn.dp.cpp@@ -37,7 +37,7 @@ template <int Width> __dpct_inline__ float warp_sum(float x) {#pragma unrollfor (int offset = Width / 2; offset; offset >>= 1)/*- DPCT1108:81: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -50,7 +50,7 @@ __dpct_inline__ float warp_max(float x) {#pragma unrollfor (int offset = 16; offset; offset >>= 1)/*- DPCT1108:82: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -66,7 +66,7 @@ __dpct_inline__ float warp_max(float x) {// four values (float2) per load, four V columns per iteration. Padded length256// gives ntiles_KV=ceil(256/D)=1, so the pinned launcher selects grid.y=1./*-DPCT1110:83: The total declared local variable size in device function attend+DPCT1110: The total declared local variable size in device function attendexceeds 128 bytes and may cause high register pressure. Consult with yourhardware vendor to find the total register size available and adjust the code,or use smaller sub-group size to avoid high register pressure.@@ -156,7 +156,7 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,#pragma unrollfor (int offset = 8; offset < 32; offset <<= 1)/*- DPCT1108:84: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -202,7 +202,7 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,// that order despite this adapter's masked-load branches.if (k0 == 0) {/*- DPCT1013:437: The rounding mode could not be specified+ DPCT1013: The rounding mode could not be specifiedand the generated code may have different accuracy thanthe original code. Verify the correctness. SYCL mathbuilt-in function rounding mode is aligned with OpenCL@@ -211,7 +211,7 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,vkq[i0 / 8 + j].x() =sycl::fma(rescale, vkq[i0 / 8 + j].x(), a * weight);/*- DPCT1013:438: The rounding mode could not be specified+ DPCT1013: The rounding mode could not be specifiedand the generated code may have different accuracy thanthe original code. Verify the correctness. SYCL mathbuilt-in function rounding mode is aligned with OpenCL@@ -221,7 +221,7 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,sycl::fma(rescale, vkq[i0 / 8 + j].y(), b * weight);} else {/*- DPCT1013:439: The rounding mode could not be specified+ DPCT1013: The rounding mode could not be specifiedand the generated code may have different accuracy thanthe original code. Verify the correctness. SYCL mathbuilt-in function rounding mode is aligned with OpenCL@@ -230,7 +230,7 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,vkq[i0 / 8 + j].x() =sycl::fma(a, weight, vkq[i0 / 8 + j].x());/*- DPCT1013:440: The rounding mode could not be specified+ DPCT1013: The rounding mode could not be specifiedand the generated code may have different accuracy thanthe original code. Verify the correctness. SYCL mathbuilt-in function rounding mode is aligned with OpenCL@@ -245,14 +245,14 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,}if (warp == 0) { max_shared[lane] = -FLT_MAX / 2.0f; sum_shared[lane] = 0.0f; }/*- DPCT1065:434: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier();if (lane == 0) max_shared[warp] = maximum;/*- DPCT1065:435: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -262,14 +262,14 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,#pragma unrollfor (int i = 0; i < 16; ++i) {/*- DPCT1013:441: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/vkq[i].x() = vkq[i].x() * rescale;/*- DPCT1013:442: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -289,7 +289,7 @@ attend(const float *__restrict__ q, const sycl::half *__restrict__ k,sum = warp_sum<32>(sum);if (lane == 0) sum_shared[warp] = sum;/*- DPCT1065:436: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -358,23 +358,23 @@ void native_flash_attn_short_step(const float* q, const uint16_t* k, const uint1});}/*- DPCT1010:445: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto result = 0;/*- DPCT1000:444: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (result != 0)/*- DPCT1009:446: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:443: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("native FlashAttention launch: ") +dpct::get_error_string_dummy(result));diff --git a/sycl/src/kernels/cuda/native_gdn.dp.cpp b/sycl/src/kernels/cuda/native_gdn.dp.cppindex c4309722f..4faf25a36 100644--- a/sycl/src/kernels/cuda/native_gdn.dp.cpp+++ b/sycl/src/kernels/cuda/native_gdn.dp.cpp@@ -43,7 +43,7 @@ __dpct_inline__ float warp_sum(float value) {#pragma unrollfor (int offset = 16; offset > 0; offset >>= 1)/*- DPCT1108:157: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -144,21 +144,21 @@ void native_gdn_step(float* state, const float* q, const float* k, const float*});}/*- DPCT1010:804: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:805: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:802: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:803: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/native_gdn_preprocess.dp.cpp b/sycl/src/kernels/cuda/native_gdn_preprocess.dp.cppindex f0bd4ed39..d9f3b1f9d 100644--- a/sycl/src/kernels/cuda/native_gdn_preprocess.dp.cpp+++ b/sycl/src/kernels/cuda/native_gdn_preprocess.dp.cpp@@ -41,7 +41,7 @@ __dpct_inline__ float warp_sum(float value) {#pragma unrollfor (int offset = 16; offset > 0; offset >>= 1)/*- DPCT1108:100: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -56,7 +56,7 @@ __dpct_inline__ float norm_sum(float value, float *sums) {value = warp_sum(value);if (lane == 0) sums[item_ct1.get_local_id(2) / 32] = value;/*- DPCT1065:516: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -83,7 +83,7 @@ __dpct_inline__ void conv_silu(float *__restrict__ history,for (int tap = 0; tap < 4; ++tap) sum += values[tap] * weights[c * 4 + tap];// The native SSM kernel adds its zero bias even when there is no bias input./*- DPCT1013:517: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -110,14 +110,14 @@ __dpct_inline__ void l2_norm(float *input, float epsilon, float scale_after) {if (col < S) {// Preserve the FP32 store boundary between RMSNorm and ggml_scale./*- DPCT1013:518: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/const float normalized = scale * value;/*- DPCT1013:519: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -141,7 +141,7 @@ __dpct_inline__ void gate_softplus(const float *__restrict__ alpha,item_ct1.get_local_id(2);if (i >= count) return;/*- DPCT1013:520: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -170,7 +170,7 @@ __dpct_inline__ void out_norm(const float *__restrict__ input,if (col < S) {// RMSNorm+gamma is one pinned fused operator, followed by sigmoid*mul./*- DPCT1013:521: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -202,21 +202,21 @@ void norm_geometry(int64_t rows, int64_t cols, float epsilon, void* stream) {}void check_launch() {/*- DPCT1010:524: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:525: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:522: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:523: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/native_gr_norm.dp.cpp b/sycl/src/kernels/cuda/native_gr_norm.dp.cppindex 6bc15c6e8..63258c375 100644--- a/sycl/src/kernels/cuda/native_gr_norm.dp.cpp+++ b/sycl/src/kernels/cuda/native_gr_norm.dp.cpp@@ -41,7 +41,7 @@ __dpct_inline__ float norm_warp_sum(float value) {#pragma unrollfor (int offset = 16; offset > 0; offset >>= 1) {/*- DPCT1108:290: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -121,7 +121,7 @@ void native_gr_rms_norm_weighted(const float* input, const float* gamma, float*});} else/*- DPCT1049:291: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -140,23 +140,23 @@ void native_gr_rms_norm_weighted(const float* input, const float* gamma, float*});}/*- DPCT1010:1149: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1000:1148: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error != 0)/*- DPCT1009:1150: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:1147: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("native GR RMSNorm launch: ") +dpct::get_error_string_dummy(error));diff --git a/sycl/src/kernels/cuda/native_gr_postops.dp.cpp b/sycl/src/kernels/cuda/native_gr_postops.dp.cppindex a758831fd..436af20f3 100644--- a/sycl/src/kernels/cuda/native_gr_postops.dp.cpp+++ b/sycl/src/kernels/cuda/native_gr_postops.dp.cpp@@ -44,7 +44,7 @@ __dpct_inline__ float sigmoid(float x) {// explicitly so compile-time zero does not change signed-zero behavior.__dpct_inline__ float scale_zero_bias(float x, float scale) {/*- DPCT1013:908: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -74,7 +74,7 @@ pre_gated(const float *__restrict__ xn, float *__restrict__ gate,const std::size_t i = std::size_t(c) * n_embd + d;const float x = xn[i], w = sigmoid(gate[i]);/*- DPCT1013:909: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -82,14 +82,14 @@ pre_gated(const float *__restrict__ xn, float *__restrict__ gate,const float product = x * w;gate[i] = product;/*- DPCT1013:910: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/if constexpr (Fused) sum = sycl::fma(x, w, sum);/*- DPCT1013:911: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -112,7 +112,7 @@ __dpct_inline__ void post(const float *residual,const float weight = scale_zero_bias(sigmoid(scale_zero_bias(inject[c], scale)), 2.0f);// Exact residual/output alias is supported; no other thread reads residual[i]./*- DPCT1013:912: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -130,23 +130,23 @@ void check_shape(int n, int hc) {unsigned blocks(std::size_t n) { return unsigned((n + THREADS - 1) / THREADS); }void check_launch() {/*- DPCT1010:915: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1000:914: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error != 0)/*- DPCT1009:916: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:913: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("native GR postops launch: ") +dpct::get_error_string_dummy(error));diff --git a/sycl/src/kernels/cuda/native_mmvq.dp.cpp b/sycl/src/kernels/cuda/native_mmvq.dp.cppindex 61ad826db..3d05318d6 100644--- a/sycl/src/kernels/cuda/native_mmvq.dp.cpp+++ b/sycl/src/kernels/cuda/native_mmvq.dp.cpp@@ -131,7 +131,7 @@ __dpct_inline__ float warp_sum(float x) {#pragma unrollfor (int offset = WARP / 2; offset > 0; offset >>= 1) {/*- DPCT1108:203: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -146,7 +146,7 @@ __dpct_inline__ float warp_max(float x) {#pragma unrollfor (int offset = WARP / 2; offset > 0; offset >>= 1) {/*- DPCT1108:204: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -204,7 +204,7 @@ q5_q8_dot_impl(const int *__restrict__ vl, const int *__restrict__ vh,}/*-DPCT1110:205: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionq5_q8_dot exceeds 128 bytes and may cause high register pressure. Consult withyour hardware vendor to find the total register size available and adjust thecode, or use smaller sub-group size to avoid high register pressure.@@ -286,7 +286,7 @@ __dpct_inline__ void native_q5_k_mmvq_kernel(const Q5KBlock *__restrict__ w,tmp[i];}/*- DPCT1065:896: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -365,7 +365,7 @@ __dpct_inline__ void native_q2_0_mmvq_kernel(const Q20Block *__restrict__ w,tmp[i];}/*- DPCT1065:897: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -467,7 +467,7 @@ __dpct_inline__ void native_q3_k_mmvq_kernel(const Q3KBlock *__restrict__ w,tmp[i];}/*- DPCT1065:898: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -568,7 +568,7 @@ native_iq4_xs_mmvq_kernel(const IQ4XSBlock *__restrict__ w,tmp[i];}/*- DPCT1065:899: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -681,7 +681,7 @@ __dpct_inline__ void native_q4_k_mmvq_kernel(const Q4KBlock *__restrict__ w,tmp[i];}/*- DPCT1065:900: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -768,7 +768,7 @@ __dpct_inline__ void native_q6_k_mmvq_kernel(const Q6KBlock *__restrict__ w,tmp[i];}/*- DPCT1065:901: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -905,7 +905,7 @@ __dpct_inline__ void native_small_mmvq_kernel(const Weight *__restrict__ w,tmp[i];}/*- DPCT1065:902: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -1183,7 +1183,7 @@ bool g_multi_exact = true; // until the upstream layout is timed on an idle GPtemplate <typename F, int NCOLS, int NW, int ROWS>/*-DPCT1110:206: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionnative_mmvq_multi_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -1210,7 +1210,7 @@ native_mmvq_multi_kernel(const typename F::Block *__restrict__ w,if (row0 + i < n_out) {const std::size_t block = std::size_t(row0 + i) * blocks_per_row + kbx;/*- DPCT1084:299: The function call "Q5KTraits::load" has multiple+ DPCT1084: The function call "Q5KTraits::load" has multiplemigration results in different template instantiations thatcould not be unified. You may need to adjust the code.*/@@ -1219,7 +1219,7 @@ native_mmvq_multi_kernel(const typename F::Block *__restrict__ w,#pragma unrollfor (int j = 0; j < NCOLS; ++j) // then per column/*- DPCT1084:300: The function call "Q5KTraits::apply" has+ DPCT1084: The function call "Q5KTraits::apply" hasmultiple migration results in different templateinstantiations that could not be unified. You may need toadjust the code.@@ -1241,7 +1241,7 @@ native_mmvq_multi_kernel(const typename F::Block *__restrict__ w,[item_ct1.get_local_id(2)] = tmp[j][i];}/*- DPCT1065:903: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -1424,7 +1424,7 @@ void launch_multi_n(const void *weights, const void *x_q8_1, float *y, int n_in,constexpr int ROWS = 1; // SYCL port: one row per work-group (more groups: the kernel is latency-bound here)const unsigned blocks = unsigned((std::size_t(n_out) + ROWS - 1) / ROWS);/*- DPCT1049:207: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1453,7 +1453,7 @@ void launch_multi_n(const void *weights, const void *x_q8_1, float *y, int n_in,if (n_in / F::DIV < F::BPI) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:208: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1476,7 +1476,7 @@ void launch_multi_n(const void *weights, const void *x_q8_1, float *y, int n_in,}} else {/*- DPCT1049:209: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1529,23 +1529,23 @@ void validate_stream(void* stream) {}void launch_check() {/*- DPCT1010:906: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1000:905: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error != 0) {/*- DPCT1009:907: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:904: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("native MMVQ launch: ") +dpct::get_error_string_dummy(error));@@ -1573,7 +1573,7 @@ void small_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / 32 < 2 * WARPS * WARP / Qi) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:210: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1601,7 +1601,7 @@ void small_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:211: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1703,7 +1703,7 @@ void native_q5_k_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / QK < VDR * WARPS * WARP / QI) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:212: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1724,7 +1724,7 @@ void native_q5_k_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:213: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1778,7 +1778,7 @@ void native_q2_0_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / 64 < WARPS * WARP / 2) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:214: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1798,7 +1798,7 @@ void native_q2_0_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:215: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1850,7 +1850,7 @@ void native_q3_k_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / 256 < WARPS * WARP / 16) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:216: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1870,7 +1870,7 @@ void native_q3_k_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:217: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1922,7 +1922,7 @@ void native_iq4_xs_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / 256 < 4 * WARPS * WARP / 32) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:218: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1950,7 +1950,7 @@ void native_iq4_xs_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:219: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -2011,7 +2011,7 @@ void native_q4_k_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / 256 < WARPS * WARP / 16) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:220: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -2032,7 +2032,7 @@ void native_q4_k_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:221: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -2105,7 +2105,7 @@ void native_q6_k_mmvq(const void* weights, const void* x_q8_1, float* y,if (n_in / 256 < WARPS * WARP / 32) {const unsigned blocks = unsigned((std::size_t(n_out) + WARPS - 1) / WARPS);/*- DPCT1049:222: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -2125,7 +2125,7 @@ void native_q6_k_mmvq(const void* weights, const void* x_q8_1, float* y,}} else {/*- DPCT1049:223: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/native_moe.dp.cpp b/sycl/src/kernels/cuda/native_moe.dp.cppindex b94b5f850..3212e3ced 100644--- a/sycl/src/kernels/cuda/native_moe.dp.cpp+++ b/sycl/src/kernels/cuda/native_moe.dp.cpp@@ -94,21 +94,21 @@ void native_moe_combine(const float* parts, const float* weights, const float* s});}/*- DPCT1010:597: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:598: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:595: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:596: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=@@ -133,21 +133,21 @@ void native_moe_combine_multi(const float* parts, const float* weights, const fl});}/*- DPCT1010:601: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:602: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:599: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:600: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/native_ple_postops.dp.cpp b/sycl/src/kernels/cuda/native_ple_postops.dp.cppindex d90b7a458..a55748bd8 100644--- a/sycl/src/kernels/cuda/native_ple_postops.dp.cpp+++ b/sycl/src/kernels/cuda/native_ple_postops.dp.cpp@@ -37,7 +37,7 @@ namespace {constexpr int N = 2560, H = 4, D = N * H, HISTORY = 9;inline float warp_sum(float x) {/*-DPCT1108:50: '__shfl_xor_sync' was migrated with the experimental feature masked+DPCT1108: '__shfl_xor_sync' was migrated with the experimental feature maskedsub_group function which may not be supported by all compilers or runtimes. Youmay need to adjust the code.*/@@ -58,7 +58,7 @@ __dpct_inline__ void gate_kernel(const float *key, const float *query,for (int j = 0; j < 8; ++j) {const int d = item_ct1.get_local_id(2) + j * 512;/*- DPCT1013:372: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -82,7 +82,7 @@ __dpct_inline__ void gate_kernel(const float *key, const float *query,sum = warp_sum(sum);if (item_ct1.get_local_id(2) == 0) {/*- DPCT1013:373: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -91,7 +91,7 @@ __dpct_inline__ void gate_kernel(const float *key, const float *query,const float mag = sycl::sqrt(sycl::fmax(sycl::fabs(s), 1e-6f));const float sign = float((s > 0.0f) - (s < 0.0f));/*- DPCT1013:374: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -106,7 +106,7 @@ __dpct_inline__ void broadcast_kernel(const float *value, const float *gate,const int i = item_ct1.get_group(2) * item_ct1.get_local_range(2) +item_ct1.get_local_id(2);/*- DPCT1013:375: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -130,14 +130,14 @@ conv_residual_kernel(const float *history, const float *normalized,sycl::bit_cast<sycl::half, unsigned short>(weights[c * 4 + k])).convert<float, sycl::rounding_mode::automatic>()[0];/*- DPCT1013:376: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/const float term = x * w;/*- DPCT1013:377: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -148,7 +148,7 @@ conv_residual_kernel(const float *history, const float *normalized,conv[c] = activation;// Exact hidden/result alias is safe: each thread owns one element./*- DPCT1013:378: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -160,7 +160,7 @@ conv_residual_kernel(const float *history, const float *normalized,inline float norm_warp_sum(float value) {#pragma unroll/*- DPCT1108:51: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -212,7 +212,7 @@ __dpct_inline__ void broadcast_batch_kernel(const float *value,if (i >= size_t(T) * D) return;const size_t t = i / D, d = i % D;/*- DPCT1013:379: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -241,14 +241,14 @@ __dpct_inline__ void conv_residual_batch_kernel(const float *history,sycl::bit_cast<sycl::half, unsigned short>(weights[c * 4 + k])).convert<float, sycl::rounding_mode::automatic>()[0];/*- DPCT1013:380: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/const float term = x * wk;/*- DPCT1013:381: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -257,7 +257,7 @@ __dpct_inline__ void conv_residual_batch_kernel(const float *history,}const float activation = sum / (1.0f + sycl::native::exp(-sum));/*- DPCT1013:382: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -293,21 +293,21 @@ void validate(Span span) {}void launch_check() {/*- DPCT1010:385: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:386: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:383: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:384: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=@@ -339,7 +339,7 @@ void native_ple_postops(const float* projected_key, const float* hidden,native_gr_rms_norm_weighted(hidden,w.norm_query,b.query,N,H,NG_RMS_EPS,stream);auto st = strata::q_of(stream);/*- DPCT1049:52: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -399,7 +399,7 @@ void native_ple_postops_batch(float* key, float* hidden, const float* value, floconst unsigned rows = unsigned(T) * H;const unsigned blocks = unsigned((size_t(T) * D + 255) / 256);/*- DPCT1049:53: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -416,7 +416,7 @@ void native_ple_postops_batch(float* key, float* hidden, const float* value, flo});}/*- DPCT1049:54: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -433,7 +433,7 @@ void native_ple_postops_batch(float* key, float* hidden, const float* value, flo});}/*- DPCT1049:55: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -469,7 +469,7 @@ void native_ple_postops_batch(float* key, float* hidden, const float* value, flo});}/*- DPCT1049:56: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/native_qsa.dp.cpp b/sycl/src/kernels/cuda/native_qsa.dp.cppindex f0c4c0f91..221831459 100644--- a/sycl/src/kernels/cuda/native_qsa.dp.cpp+++ b/sycl/src/kernels/cuda/native_qsa.dp.cpp@@ -42,7 +42,7 @@ __dpct_inline__ float warp_sum(float value) {#pragma unrollfor (int offset = 16; offset; offset >>= 1)/*- DPCT1108:174: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -114,23 +114,23 @@ void buffers(const float* input, std::size_t in_bytes, const float* weight, std:}void check_launch() {/*- DPCT1010:844: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto result = 0;/*- DPCT1000:843: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (result != 0)/*- DPCT1009:845: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1001:842: The statement could not be removed.+ DPCT1001: The statement could not be removed.*/throw std::runtime_error(std::string("native QSA launch: ") +dpct::get_error_string_dummy(result));@@ -164,7 +164,7 @@ void native_qsa_rms_norm_weighted(const float* input, const float* gamma, float*});} else/*- DPCT1049:175: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/native_qsa_indexer.dp.cpp b/sycl/src/kernels/cuda/native_qsa_indexer.dp.cppindex bda43e8bc..c216b8d5e 100644--- a/sycl/src/kernels/cuda/native_qsa_indexer.dp.cpp+++ b/sycl/src/kernels/cuda/native_qsa_indexer.dp.cpp@@ -39,7 +39,7 @@ inline float warp_sum(float x) {#pragma unrollfor (int offset = 16; offset; offset >>= 1)/*- DPCT1108:133: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -82,14 +82,14 @@ append(const float *__restrict__ raw, const int32_t *__restrict__ pos_dev,#pragma unrollfor (int j = 1; j < R; ++j)/*- DPCT1013:637: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.*/sum = sum + pos == 0 || j == R - 1 ? incoming : tail[j * D + d];/*- DPCT1013:638: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -102,7 +102,7 @@ append(const float *__restrict__ raw, const int32_t *__restrict__ pos_dev,const int lane = d % 32;if (lane == 0) partials[d / 32] = square_sum;/*- DPCT1065:635: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -112,7 +112,7 @@ append(const float *__restrict__ raw, const int32_t *__restrict__ pos_dev,const float scale = sycl::rsqrt(square_sum / D + epsilon);if (d < D) values[d] = scale * mean * gamma[d];/*- DPCT1065:636: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -159,7 +159,7 @@ __dpct_inline__ float norm_scale(float mean, float *partials, int d) {const int lane = d % 32;if (lane == 0) partials[d / 32] = square_sum;/*- DPCT1065:639: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -192,14 +192,14 @@ __dpct_inline__ void append_first(const float *__restrict__ raw,float sum = incoming;#pragma unroll/*- DPCT1013:641: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/for (int j = 1; j < R; ++j) sum = sum + incoming;/*- DPCT1013:642: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -210,7 +210,7 @@ __dpct_inline__ void append_first(const float *__restrict__ raw,const float scale = sycl::rsqrt(square_sum / D + epsilon);if (d < D) values[d] = scale * mean * gamma[d];/*- DPCT1113:640: Consider replacing+ DPCT1113: Consider replacingsycl::nd_item::barrier(sycl::access::fence_space::local_space) withsycl::nd_item::barrier() if function "append_first" is called in amultidimensional kernel.@@ -253,14 +253,14 @@ append_blocks(const float *__restrict__ raw, int64_t n, int64_t p0,float sum = key(0);#pragma unroll/*- DPCT1013:643: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/for (int j = 1; j < R; ++j) sum = sum + key(j);/*- DPCT1013:644: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -344,21 +344,21 @@ void native_qsa_indexer_append(const float* raw, const int32_t* relative_pos_dev});}/*- DPCT1010:647: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:648: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:645: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:646: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=@@ -419,21 +419,21 @@ void native_qsa_indexer_append_batch(const float* raw, int64_t n, int64_t p0, in});}/*- DPCT1010:651: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:652: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:649: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:650: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/native_qsa_score.dp.cpp b/sycl/src/kernels/cuda/native_qsa_score.dp.cppindex d544e2e62..fe57d98af 100644--- a/sycl/src/kernels/cuda/native_qsa_score.dp.cpp+++ b/sycl/src/kernels/cuda/native_qsa_score.dp.cpp@@ -35,6 +35,7 @@ constexpr int D=128, HEADS=4, R=4, ROWS=32, WARPS=2, STRIDE=36, COMBINE=68;struct TileA { uint32_t x[4]; };struct TileB { uint32_t x[2]; };struct TileC { float x[4]={0.0f,0.0f,0.0f,0.0f}; };+#if !defined(__HIPCC__)#if 0 // SYCL: inline PTX (mma/ldmatrix/cp.async) - the XMX port is pending; see tools/fixups.py__dpct_inline__ void load_a(TileA &a, const float *p) {auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();@@ -64,7 +65,7 @@ __dpct_inline__ void load_b(TileB &b, const float *p) {__dpct_inline__ void mma(TileC &c, const TileA &a, const TileB &b) {// Deliberately no cvt.rn.tf32: pinned mma.cuh passes raw F32 bits directly./*- DPCT1053:75: Migration of device assembly code is not supported.+ DPCT1053: Migration of device assembly code is not supported.*/asm("mma.sync.aligned.m16n8k8.row.col.f32.tf32.tf32.f32 {%0,%1,%2,%3}, ""{%4,%5,%6,%7}, {%8,%9}, {%0,%1,%2,%3};"@@ -74,7 +75,7 @@ __dpct_inline__ void mma(TileC &c, const TileA &a, const TileB &b) {}#endif/*-DPCT1110:76: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionscore_kernel exceeds 128 bytes and may cause high register pressure. Consultwith your hardware vendor to find the total register size available and adjustthe code, or use smaller sub-group size to avoid high register pressure.@@ -143,7 +144,7 @@ __dpct_inline__ void score_kernel(const float *__restrict__ pooled,}}/*- DPCT1065:405: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -158,7 +159,7 @@ __dpct_inline__ void score_kernel(const float *__restrict__ pooled,}}/*- DPCT1065:406: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -172,14 +173,14 @@ __dpct_inline__ void score_kernel(const float *__restrict__ pooled,#pragma unrollfor(int j=0;j<HEADS;++j){/*- DPCT1013:407: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.*/float v = 0.0f + shared[j * COMBINE + lane];/*- DPCT1013:408: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -188,21 +189,21 @@ __dpct_inline__ void score_kernel(const float *__restrict__ pooled,h[j] = sycl::fmax(v, 0.0f);}/*- DPCT1013:409: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/float sum = h[0] + h[1] + h[2] + h[3];/*- DPCT1013:410: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/if (bias) sum = sum + bias[row];/*- DPCT1013:411: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -210,7 +211,7 @@ __dpct_inline__ void score_kernel(const float *__restrict__ pooled,sum = sum + row == full && n % R ? 1e9f : 0.0f;// The live causal mask is +0. Invalid/padded cells are never exported./*- DPCT1013:412: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -221,6 +222,42 @@ __dpct_inline__ void score_kernel(const float *__restrict__ pooled,}#endif}+#else+// gfx1100 has no CUDA ldmatrix/mma instruction sequence. Keep the same entry point and+// score contract with an ordered scalar F32 dot for each indexer head. The four heads+// run independently; their ReLU'd scores are then added in the documented head order.+// This path favors a well-defined fallback over pretending the CUDA PTX is portable.+__global__ void scalar_score_kernel(+ const float* __restrict__ pooled,const float* __restrict__ query,+ const float* __restrict__ bias,const int32_t* __restrict__ step,+ int max_cells,float* __restrict__ cells) {+ const int n=step[kStepNKv],full=step[kStepNBid];+ if(n<1||n>max_cells||step[kStepPos]!=n-1||full!=n/R||+ step[kStepWidth]!=(n<2051?n:2051))return;+ const int row=blockIdx.x;+ if(row>full)return;+ __shared__ float head_score[HEADS];+ const int head=threadIdx.x;+ if(head<HEADS){+ float dot=0.0f;+#pragma unroll+ for(int d=0;d<D;++d)+ dot=__fmaf_rn(pooled[size_t(row)*D+d],query[size_t(head)*D+d],dot);+ head_score[head]=dot>0.0f?dot:0.0f;+ }+ __syncthreads();+ if(head==0){+ float sum=(0.0f + head_score[0]);+ sum=(sum + head_score[1]);+ sum=(sum + head_score[2]);+ sum=(sum + head_score[3]);+ if(bias)sum=(sum + bias[row]);+ sum=(sum + row==full&&n%R?1e9f:0.0f);+ sum=(sum + 0.0f);+ for(int i=row*R;i<n&&i<(row+1)*R;++i)cells[i]=sum;+ }+}+#endifstruct Span{const void* p;size_t n;};void validate(Span s){const auto p=reinterpret_cast<uintptr_t>(s.p);@@ -245,12 +282,16 @@ void native_qsa_score(const float* pooled,const float* query,const float* bias,for(int i=0;i<count;++i)validate(spans[i]);for(int i=0;i<count;++i)for(int j=i+1;j<count;++j)if(overlaps(spans[i],spans[j]))throw std::invalid_argument("native QSA score spans overlap");+#if defined(__HIPCC__)+ scalar_score_kernel<<<unsigned(max_blocks),128,0,static_cast<cudaStream_t>(stream)>>>(+ pooled,query,bias,step,int(max_cells),cells);+#else{auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};((sycl::queue *)(strata::q_of(stream)))- ->parallel_for<dpct_kernel_name<class score_kernel_8b4dbe>>(+ ->parallel_for<dpct_kernel_name<class score_kernel_59cd1b>>(sycl::nd_range<3>(sycl::range(1, 1,unsigned((max_blocks + ROWS - 1) / ROWS)) *@@ -263,22 +304,23 @@ void native_qsa_score(const float* pooled,const float* query,const float* bias,cells);});}+#endif/*- DPCT1010:415: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:416: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:413: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:414: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/native_rope.dp.cpp b/sycl/src/kernels/cuda/native_rope.dp.cppindex 8c809bb3a..fa30f027e 100644--- a/sycl/src/kernels/cuda/native_rope.dp.cpp+++ b/sycl/src/kernels/cuda/native_rope.dp.cpp@@ -122,21 +122,21 @@ void native_rope_apply(const float* x, float* out, int rows, int head_dim,});}/*- DPCT1010:390: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:391: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:388: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:389: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/native_router.dp.cpp b/sycl/src/kernels/cuda/native_router.dp.cppindex fe28562c1..d0d361624 100644--- a/sycl/src/kernels/cuda/native_router.dp.cpp+++ b/sycl/src/kernels/cuda/native_router.dp.cpp@@ -37,7 +37,7 @@ std::atomic<bool> enabled{false};__dpct_inline__ float warp_sum(float value) {#pragma unroll/*- DPCT1108:177: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -50,7 +50,7 @@ __dpct_inline__ float warp_sum(float value) {__dpct_inline__ float warp_max(float value) {#pragma unroll/*- DPCT1108:178: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -62,7 +62,7 @@ __dpct_inline__ float warp_max(float value) {return value;}/*-DPCT1110:179: The total declared local variable size in device function route+DPCT1110: The total declared local variable size in device function routeexceeds 128 bytes and may cause high register pressure. Consult with yourhardware vendor to find the total register size available and adjust the code,or use smaller sub-group size to avoid high register pressure.@@ -110,7 +110,7 @@ __dpct_inline__ void route(const float *__restrict__ logits,#pragma unrollfor (int mask = 16; mask; mask >>= 1) {/*- DPCT1108:180: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -118,7 +118,7 @@ __dpct_inline__ void route(const float *__restrict__ logits,0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),best, mask);/*- DPCT1108:181: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -170,21 +170,21 @@ void native_router_top10(const float* logits, int32_t* ids, float* weights, void});}/*- DPCT1010:858: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:859: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:856: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:857: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=@@ -210,21 +210,21 @@ void native_router_top10_multi(const float* logits, int32_t* ids, float* weights});}/*- DPCT1010:862: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const auto error = 0;/*- DPCT1009:863: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:860: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:861: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (error !=diff --git a/sycl/src/kernels/cuda/ple.dp.cpp b/sycl/src/kernels/cuda/ple.dp.cppindex b8d466772..a6c06b876 100644--- a/sycl/src/kernels/cuda/ple.dp.cpp+++ b/sycl/src/kernels/cuda/ple.dp.cpp@@ -82,7 +82,7 @@ __dpct_inline__ float silu_f(float x) {/// fires.inline double block_sum(double v, double *scratch) {/*- DPCT1065:1040: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -91,12 +91,12 @@ inline double block_sum(double v, double *scratch) {const int lane = item_ct1.get_local_id(2) & 31,warp = item_ct1.get_local_id(2) >> 5;/*-DPCT1108:271: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*-DPCT1121:272: Make sure that the "v" which is used in the SYCL group+DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/#pragma unroll@@ -106,7 +106,7 @@ function/algorithm is initialized.off);if (lane == 0) scratch[warp] = v;/*- DPCT1065:1041: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -116,12 +116,12 @@ function/algorithm is initialized.: 0.0;if (warp == 0)/*-DPCT1108:273: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*-DPCT1121:274: Make sure that the "v" which is used in the SYCL group+DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/#pragma unroll@@ -131,7 +131,7 @@ function/algorithm is initialized.v, off);if (item_ct1.get_local_id(2) == 0) scratch[0] = v;/*- DPCT1065:1042: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -306,7 +306,7 @@ void ple_history_advance(float* hist, const float* normalized, void* stream) {});}/*- DPCT1010:1044: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -336,8 +336,9 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, coPleOut& out, void* scratch, void* stream) {const bool native_key = w.key_native_data != nullptr && w.key_bf16 == nullptr;if (native_key && (!emb || !hidden || !hist_rows || !out.result || !scratch || !stream ||- !w.key_native_q8_1 || w.key_native_type != 42))- throw std::invalid_argument("ple_block: native key requires Q2_0 weights, input/output, private scratch and explicit stream");+ !w.key_native_q8_1 ||+ (w.key_native_type != 42 && w.key_native_type != 18 && w.key_native_type != 23)))+ throw std::invalid_argument("ple_block: native key requires Q2_0, IQ3_XXS or IQ4_XS weights, input/output, private scratch and explicit stream");if (emb == nullptr || hidden == nullptr || hist_rows == nullptr || out.result == nullptr) return;const int n_embd = NG_N_EMBD, hc = NG_HC, hc_dim = NG_HC_DIM;static_assert(NG_N_EMBD == 2560 && NG_HC_DIM == 10240, "native PLE key geometry changed");@@ -429,7 +430,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, cost->submit([&](sycl::handler &cgh) {auto NG_RMS_EPS_ct4 = NG_RMS_EPS;- cgh.parallel_for<dpct_kernel_name<class gnorm_kernel_cf1ead>>(+ cgh.parallel_for<dpct_kernel_name<class gnorm_kernel_2584bb>>(sycl::nd_range<3>(sycl::range(1, 1, hc) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -450,7 +451,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, cost->submit([&](sycl::handler &cgh) {auto NG_RMS_EPS_ct4 = NG_RMS_EPS;- cgh.parallel_for<dpct_kernel_name<class gnorm_kernel_2584bb>>(+ cgh.parallel_for<dpct_kernel_name<class gnorm_kernel_e3be1c>>(sycl::nd_range<3>(sycl::range(1, 1, hc) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -472,7 +473,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, coauto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class to_bf16_kernel_e8b7a8>>(+ st->parallel_for<dpct_kernel_name<class to_bf16_kernel_ab93ff>>(sycl::nd_range<3>(sycl::range(1, 1, (n_embd + THREADS - 1) / THREADS) *sycl::range(1, 1, THREADS),@@ -487,7 +488,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, codpct::has_capability_or_fail(st->get_device(),{sycl::aspect::fp64});- st->parallel_for<dpct_kernel_name<class bf16_gemv_kernel_ab93ff>>(+ st->parallel_for<dpct_kernel_name<class bf16_gemv_kernel_47d04d>>(sycl::nd_range<3>(sycl::range(1, 1, (n_embd + THREADS - 1) / THREADS) *sycl::range(1, 1, THREADS),@@ -516,7 +517,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, cost->submit([&](sycl::handler &cgh) {auto sqrtf_float_n_embd_ct4 = 1.0f / sqrtf((float)n_embd);- cgh.parallel_for<dpct_kernel_name<class gate_kernel_2da4a8>>(+ cgh.parallel_for<dpct_kernel_name<class gate_kernel_ce83eb>>(sycl::nd_range<3>(sycl::range(1, 1, hc) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -532,7 +533,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, coauto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class bcast_kernel_ce83eb>>(+ st->parallel_for<dpct_kernel_name<class bcast_kernel_79d1c2>>(sycl::nd_range<3>(sycl::range(1, 1, (hc_dim + THREADS - 1) / THREADS) *sycl::range(1, 1, THREADS),@@ -550,7 +551,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, cost->submit([&](sycl::handler &cgh) {auto NG_RMS_EPS_ct4 = NG_RMS_EPS;- cgh.parallel_for<dpct_kernel_name<class gnorm_kernel_79d1c2>>(+ cgh.parallel_for<dpct_kernel_name<class gnorm_kernel_cb94da>>(sycl::nd_range<3>(sycl::range(1, 1, hc) *sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -571,7 +572,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, coauto NGRAM_SIZE_ct6 = NGRAM_SIZE;auto NG_HIST_ct7 = NG_HIST;- cgh.parallel_for<dpct_kernel_name<class conv_kernel_cb94da>>(+ cgh.parallel_for<dpct_kernel_name<class conv_kernel_f83a85>>(sycl::nd_range<3>(sycl::range(1, 1, (hc_dim + THREADS - 1) / THREADS) *sycl::range(1, 1, THREADS),@@ -587,7 +588,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, coauto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class add3_kernel_ba9359>>(+ st->parallel_for<dpct_kernel_name<class add3_kernel_26c4c6>>(sycl::nd_range<3>(sycl::range(1, 1, (hc_dim + THREADS - 1) / THREADS) *sycl::range(1, 1, THREADS),@@ -602,7 +603,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, co// `cb(key, ...)` capture is after `gnorm`; `value` is the projection before the gate. Each stage the// oracle records is reproduced here so a mismatch can be attributed instead of guessed at./*- DPCT1124:1045: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -612,7 +613,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, co"key");if (out.value)/*- DPCT1124:1046: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -621,7 +622,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, cost->memcpy(out.value, d_value, n_embd * sizeof(float))),"value");/*- DPCT1124:1047: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -631,7 +632,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, co"gate");if (out.gated)/*- DPCT1124:1048: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -641,7 +642,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, co"gated");if (out.normalized)/*- DPCT1124:1049: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -651,7 +652,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, co"norm");if (out.conv)/*- DPCT1124:1050: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -661,7 +662,7 @@ void ple_block(const float* emb, const float* hidden, const float* hist_rows, co"conv");/*- DPCT1010:1051: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/qsa.dp.cpp b/sycl/src/kernels/cuda/qsa.dp.cppindex 767417f35..09ccaff8c 100644--- a/sycl/src/kernels/cuda/qsa.dp.cpp+++ b/sycl/src/kernels/cuda/qsa.dp.cpp@@ -69,7 +69,7 @@ void fail(const char* what) {void check_launch(const char* what) {/*- DPCT1010:806: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -130,7 +130,7 @@ kv_append_kernel(uint16_t *__restrict__ k_pool, uint16_t *__restrict__ v_pool,const float *__restrict__ kcur, const float *__restrict__ vcur,int kv_heads, int head_dim, int page_size, KvHostPools host) {/*- DPCT1098:809: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -177,7 +177,7 @@ __dpct_inline__ void indexer_key_append_kernel(auto s_mean = (double *)dpct_local; // idx_dim doublesconst int d = item_ct1.get_local_id(2);/*- DPCT1098:813: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -204,7 +204,7 @@ __dpct_inline__ void indexer_key_append_kernel(for (int i = 0; i < idx_dim; ++i) {const double v = (double) raw[i];/*- DPCT1013:814: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -212,7 +212,7 @@ __dpct_inline__ void indexer_key_append_kernel(ss = ss + v * v;}/*- DPCT1013:815: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -226,7 +226,7 @@ __dpct_inline__ void indexer_key_append_kernel(if (slot != r - 1) return;/*- DPCT1065:810: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -238,7 +238,7 @@ __dpct_inline__ void indexer_key_append_kernel(// but the order of the SUM OF SQUARES below can, and it is fixed to d ascending on both sides.double m = 0.0;/*-DPCT1013:816: The rounding mode could not be specified and the generated code+DPCT1013: The rounding mode could not be specified and the generated codemay have different accuracy than the original code. Verify the correctness. SYCLmath built-in function rounding mode is aligned with OpenCL C 1.2 standard.*/@@ -246,7 +246,7 @@ math built-in function rounding mode is aligned with OpenCL C 1.2 standard.for (int j = 0; j < r - 1; ++j)m = m + (double)tail[(size_t)j * idx_dim + d];/*- DPCT1013:817: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -255,7 +255,7 @@ math built-in function rounding mode is aligned with OpenCL C 1.2 standard.m = m / (double) r;s_mean[d] = m;/*- DPCT1065:811: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -263,14 +263,14 @@ math built-in function rounding mode is aligned with OpenCL C 1.2 standard.double ss = 0.0;/*-DPCT1013:818: The rounding mode could not be specified and the generated code+DPCT1013: The rounding mode could not be specified and the generated codemay have different accuracy than the original code. Verify the correctness. SYCLmath built-in function rounding mode is aligned with OpenCL C 1.2 standard.*/#pragma unrollfor (int i = 0; i < idx_dim; ++i) ss = ss + s_mean[i] * s_mean[i];/*- DPCT1013:819: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -285,7 +285,7 @@ math built-in function rounding mode is aligned with OpenCL C 1.2 standard.// block's first cell's POSITION, `pos_base + b*r`, and NOT the cell index `b*r`.if (d == 0) *block_pos = (int32_t) (pos_base + b * r);/*- DPCT1065:812: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -320,14 +320,14 @@ __dpct_inline__ void qsa_index_kernel(const float *__restrict__ pooled,const int32_t *__restrict__ step,float *__restrict__ cell_scores) {/*- DPCT1098:820: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();const long long n_bid = (long long)*(step + kStepNBid);/*- DPCT1098:821: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -351,7 +351,7 @@ __dpct_inline__ void qsa_index_kernel(const float *__restrict__ pooled,#pragma unrollfor (int d = lane; d < idx_dim; d += 32)/*- DPCT1013:822: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -359,12 +359,12 @@ __dpct_inline__ void qsa_index_kernel(const float *__restrict__ pooled,acc = acc + (double)pooled[(size_t)b * idx_dim + d] *(double)q_idx[(size_t)wid * idx_dim + d];/*-DPCT1108:158: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*-DPCT1013:823: The rounding mode could not be specified and the generated code+DPCT1013: The rounding mode could not be specified and the generated codemay have different accuracy than the original code. Verify the correctness. SYCLmath built-in function rounding mode is aligned with OpenCL C 1.2 standard.*/@@ -412,7 +412,7 @@ __dpct_inline__ uint32_t order_key(float s) {constexpr int TOPK_THREADS = 256;/*-DPCT1110:159: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiontopk_kernel exceeds 128 bytes and may cause high register pressure. Consult withyour hardware vendor to find the total register size available and adjust thecode, or use smaller sub-group size to avoid high register pressure.@@ -421,14 +421,14 @@ __dpct_inline__ void topk_kernel(const float *__restrict__ scores,const int32_t *__restrict__ step,int *__restrict__ out_ids) {/*- DPCT1098:824: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();const long long n_kv = (long long)*(step + kStepNKv);/*- DPCT1098:825: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -459,7 +459,7 @@ __dpct_inline__ void topk_kernel(const float *__restrict__ scores,++j) if (order_key(scores[j]) >= cand)++ c;s_a[t] = c;/*- DPCT1118:160: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -467,7 +467,7 @@ __dpct_inline__ void topk_kernel(const float *__restrict__ scores,for (int s = TOPK_THREADS / 2; s > 0; s >>= 1) {if (t < s) s_a[t] += s_a[t + s];/*- DPCT1118:162: SYCL group functions and algorithms must be+ DPCT1118: SYCL group functions and algorithms must beencountered in converged control flow. You may need to adjust thecode.*/@@ -475,7 +475,7 @@ __dpct_inline__ void topk_kernel(const float *__restrict__ scores,}const int tot = s_a[0];/*- DPCT1118:161: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(@@ -558,7 +558,7 @@ __dpct_inline__ void kv_gather_kernel(const int32_t *__restrict__ step, int kv_heads, int head_dim, int page_size,uint16_t *__restrict__ k_scratch, uint16_t *__restrict__ v_scratch) {/*- DPCT1098:826: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -587,7 +587,7 @@ __dpct_inline__ void kv_gather_kernel(__dpct_inline__ float warp_max(float v) {/*-DPCT1108:163: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -601,7 +601,7 @@ runtimes. You may need to adjust the code.__dpct_inline__ float warp_sum(float v) {/*-DPCT1108:164: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -615,7 +615,7 @@ runtimes. You may need to adjust the code./// One block per query head. `s` holds the scores, which are then overwritten with the softmax weights./*-DPCT1110:165: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionqsa_attend_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -626,7 +626,7 @@ __dpct_inline__ void qsa_attend_kernel(int n_head, int n_head_kv, int head_dim, float *__restrict__ attn,float *__restrict__ weights, uint8_t *dpct_local) {/*- DPCT1098:834: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -663,7 +663,7 @@ __dpct_inline__ void qsa_attend_kernel(w[j] = acc * scale;}/*- DPCT1065:827: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -676,7 +676,7 @@ __dpct_inline__ void qsa_attend_kernel(mx = warp_max(mx);if (lane == 0) red[wid] = mx;/*- DPCT1065:828: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -687,14 +687,14 @@ __dpct_inline__ void qsa_attend_kernel(if (lane == 0) red[0] = mx;}/*- DPCT1065:829: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier();mx = red[0];/*- DPCT1065:830: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -709,7 +709,7 @@ __dpct_inline__ void qsa_attend_kernel(sum = warp_sum(sum);if (lane == 0) red[wid] = sum;/*- DPCT1065:831: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -720,14 +720,14 @@ __dpct_inline__ void qsa_attend_kernel(if (lane == 0) red[0] = 1.0f / sum;}/*- DPCT1065:832: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier();const float inv = red[0];/*- DPCT1065:833: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -799,7 +799,7 @@ catch (sycl::exception const &exc) {void step_upload_raw(const int32_t *h_step) try {int32_t* d = step_scratch();/*- DPCT1114:835: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -894,7 +894,7 @@ void qsa_index_step(const float* pooled, const float* q_idx, const float* bias,// `b > n_bid`, so the surplus blocks cost a launch and nothing else.const int threads = 32 * (int) s.idx_n_head;/*- DPCT1049:166: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -992,7 +992,7 @@ void qsa_attend_step(const float *q, const uint16_t *k_scratch,// then index past it at token 500. The kernel reads the real count from `step`, so a larger allocation is// exactly what it wants. The opt-in therefore happens once, for the capacity./*- DPCT1083:168: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -1006,7 +1006,7 @@ void qsa_attend_step(const float *q, const uint16_t *k_scratch,int dev = 0, max_shared = 0;dev = dpct::get_current_device_id();/*- DPCT1019:836: local_mem_size in SYCL is not a complete equivalent of+ DPCT1019: local_mem_size in SYCL is not a complete equivalent ofcudaDevAttrMaxSharedMemoryPerBlockOptin in CUDA. You may need to adjustthe code.*/@@ -1018,7 +1018,7 @@ void qsa_attend_step(const float *q, const uint16_t *k_scratch,}const dpct::err0 e =/*- DPCT1027:837: The call to cudaFuncSetAttribute was replaced with 0+ DPCT1027: The call to cudaFuncSetAttribute was replaced with 0because SYCL currently does not support corresponding setting.*/0;@@ -1026,7 +1026,7 @@ void qsa_attend_step(const float *q, const uint16_t *k_scratch,s_configured = smem;}/*- DPCT1049:167: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -1100,7 +1100,7 @@ void indexer_key_append(const float* raw, const int32_t* pos_dev, int32_t pos_bafail("indexer_key_append: the indexer buffers are not all set (tail/dead/pooled/block_pos)");const int threads = (int) s.idx_dim;/*- DPCT1083:170: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -1109,7 +1109,7 @@ void indexer_key_append(const float* raw, const int32_t* pos_dev, int32_t pos_ba// arguments here are identical for every token, which is the property a CUDA graph needs: this function can// be captured and replayed, and the position arrives through `pos_dev` like every other kernel's data./*- DPCT1049:169: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/qsa_decode_attn.dp.cpp b/sycl/src/kernels/cuda/qsa_decode_attn.dp.cppindex b1ce2fb35..0caac0219 100644--- a/sycl/src/kernels/cuda/qsa_decode_attn.dp.cpp+++ b/sycl/src/kernels/cuda/qsa_decode_attn.dp.cpp@@ -24,7 +24,7 @@ constexpr int WARPS = THREADS / 32;__dpct_inline__ float warp_sum(float v) {#pragma unroll/*- DPCT1108:85: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -37,7 +37,7 @@ __dpct_inline__ float warp_sum(float v) {__dpct_inline__ float warp_max(float v) {#pragma unroll/*- DPCT1108:86: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -49,55 +49,67 @@ __dpct_inline__ float warp_max(float v) {}// 8 consecutive values of one cell's key or value row for KV head `kvh`, dimensions [d0, d0+8).-template <int KV_MODE>-__dpct_inline__ void load8(const QsaAttnPools &p, bool value, long long row,- int d0, float *out) {- if constexpr (KV_MODE == 0) {- const uint16_t* base = (value ? p.v_pool : p.k_pool) + row * HD + d0;- const sycl::uint4 raw = *reinterpret_cast<const sycl::uint4 *>(base);- const sycl::half2 *h2 = reinterpret_cast<const sycl::half2 *>(&raw);+// Per-format bodies; `load8` below is the KV_MODE dispatcher. value=false is the K side, true the V side.+__dpct_inline__ void load8_f16(const QsaAttnPools &p, bool value, long long row,+ int d0, float *out) {+ const uint16_t* base = (value ? p.v_pool : p.k_pool) + row * HD + d0;+ const sycl::uint4 raw = *reinterpret_cast<const sycl::uint4 *>(base);+ const sycl::half2 *h2 = reinterpret_cast<const sycl::half2 *>(&raw);#pragma unroll- for (int j = 0; j < 4; ++j) {- const sycl::float2 f =- h2[j].template convert<float, sycl::rounding_mode::automatic>();- out[2 * j] = f.x();- out[2 * j + 1] = f.y();- }- } else if constexpr (KV_MODE == 1) {- const int8_t* codes = (value ? p.v_q : p.k_q) + row * HD + d0;- const uint16_t sbits = (value ? p.v_scale : p.k_scale)[row * (HD / KV_Q8_GROUP) + d0 / KV_Q8_GROUP];- const float sc =- sycl::vec<sycl::half, 1>(- sycl::bit_cast<sycl::half, unsigned short>(sbits))- .convert<float, sycl::rounding_mode::automatic>()[0];- const sycl::uint2 raw = *reinterpret_cast<const sycl::uint2 *>(codes);- const int8_t* c = reinterpret_cast<const int8_t*>(&raw);+ for (int j = 0; j < 4; ++j) {+ const sycl::float2 f =+ h2[j].template convert<float, sycl::rounding_mode::automatic>();+ out[2 * j] = f.x();+ out[2 * j + 1] = f.y();+ }+}+__dpct_inline__ void load8_q8(const QsaAttnPools &p, bool value, long long row,+ int d0, float *out) {+ const int8_t* codes = (value ? p.v_q : p.k_q) + row * HD + d0;+ const uint16_t sbits = (value ? p.v_scale : p.k_scale)[row * (HD / KV_Q8_GROUP) + d0 / KV_Q8_GROUP];+ const float sc = sycl::vec<sycl::half, 1>(+ sycl::bit_cast<sycl::half, unsigned short>(sbits))+ .convert<float, sycl::rounding_mode::automatic>()[0];+ const sycl::uint2 raw = *reinterpret_cast<const sycl::uint2 *>(codes);+ const int8_t* c = reinterpret_cast<const int8_t*>(&raw);#pragma unroll- for (int j = 0; j < 8; ++j) out[j] = (float) c[j] * sc;- } else {- constexpr int bytes_per_head = (HD / QK4_0) * sizeof(block_q4_0);- const int b = d0 / QK4_0;- const int rem = d0 % QK4_0;- const block_q4_0* blk = reinterpret_cast<const block_q4_0*>((value ? p.v_q4 : p.k_q4) + row * bytes_per_head) + b;- const float d =- sycl::vec<sycl::half, 1>(- sycl::bit_cast<sycl::half, unsigned short>(blk->d))- .convert<float, sycl::rounding_mode::automatic>()[0];- const int j = (rem == 0 || rem == 16) ? 0 : 8;- const uint8_t* bytes = blk->qs + j;- if (rem < 16) {+ for (int j = 0; j < 8; ++j) out[j] = (float) c[j] * sc;+}+__dpct_inline__ void load8_q4(const QsaAttnPools &p, bool value, long long row,+ int d0, float *out) {+ constexpr int bytes_per_head = (HD / QK4_0) * sizeof(block_q4_0);+ const int b = d0 / QK4_0;+ const int rem = d0 % QK4_0;+ const block_q4_0* blk = reinterpret_cast<const block_q4_0*>((value ? p.v_q4 : p.k_q4) + row * bytes_per_head) + b;+ const float d = sycl::vec<sycl::half, 1>(+ sycl::bit_cast<sycl::half, unsigned short>(blk->d))+ .convert<float, sycl::rounding_mode::automatic>()[0];+ const int j = (rem == 0 || rem == 16) ? 0 : 8;+ const uint8_t* bytes = blk->qs + j;+ if (rem < 16) {#pragma unroll- for (int k = 0; k < 8; ++k) out[k] = (float) ((int)(bytes[k] & 0x0F) - 8) * d;- } else {+ for (int k = 0; k < 8; ++k) out[k] = (float) ((int)(bytes[k] & 0x0F) - 8) * d;+ } else {#pragma unroll- for (int k = 0; k < 8; ++k) out[k] = (float) ((int)(bytes[k] >> 4) - 8) * d;- }+ for (int k = 0; k < 8; ++k) out[k] = (float) ((int)(bytes[k] >> 4) - 8) * d;}}+template <int KV_MODE>+__dpct_inline__ void load8(const QsaAttnPools &p, bool value, long long row,+ int d0, float *out) {+ if constexpr (KV_MODE == 0) load8_f16(p, value, row, d0, out);+ else if constexpr (KV_MODE == 1) load8_q8(p, value, row, d0, out);+ else if constexpr (KV_MODE == 3) {+ // hybrid K8V4: both sides are defined - K unrotated INT8, V rotated Q4_0 - so a value=true call+ // reads the Q4_0 pool instead of dereferencing the null v_q (no call site does today; PR review)+ if (value) load8_q4(p, value, row, d0, out);+ else load8_q8(p, value, row, d0, out);+ } else load8_q4(p, value, row, d0, out);+}template <int KV_MODE>/*-DPCT1110:87: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionattn_chunk_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -130,7 +142,7 @@ attn_chunk_kernel(const float *__restrict__ q, QsaAttnPools p,sycl::ext::oneapi::this_work_item::get_work_group<3>()); // pool row of each cell (page, kv head, slot)/*- DPCT1098:447: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -157,7 +169,7 @@ attn_chunk_kernel(const float *__restrict__ q, QsaAttnPools p,srow[t] = r;}/*- DPCT1065:448: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -184,7 +196,7 @@ attn_chunk_kernel(const float *__restrict__ q, QsaAttnPools p,}}/*- DPCT1065:449: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -201,7 +213,7 @@ attn_chunk_kernel(const float *__restrict__ q, QsaAttnPools p,if (lane == 0) { part_m[slot * G + h] = m; part_l[slot * G + h] = l; }}/*- DPCT1065:450: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -225,7 +237,7 @@ attn_chunk_kernel(const float *__restrict__ q, QsaAttnPools p,t / KV_Q8_GROUP])).convert<float, sycl::rounding_mode::automatic>()[0];v = (float) p.v_q[srow[c] * HD + t] * sc;- } else {+ } else { // modes 2 and 3: V is rotated Q4_0 (kv_q4.hpp); the caller rotates the output backconstexpr int bytes_per_head = (HD / QK4_0) * sizeof(block_q4_0);const int b = t / QK4_0;const int rem = t % QK4_0;@@ -284,13 +296,11 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3if (n_q <= 0) return;if (s.head_dim != HD || s.n_head != (int64_t) G * s.n_head_kv || cap <= 0 || !scratch || !ids || !steps ||!pools.page_table || n_q > 65535) {- std::fprintf(stderr, "qsa_decode_attn_batch: unsupported geometry or missing buffers (head_dim %lld want %d, "- "n_head %lld, n_head_kv %lld, cap %lld, n_q %lld, scratch %d ids %d steps %d page_table %d)\n",- (long long) s.head_dim, HD, (long long) s.n_head, (long long) s.n_head_kv, (long long) cap,- (long long) n_q, scratch != nullptr, ids != nullptr, steps != nullptr, pools.page_table != nullptr);+ std::fprintf(stderr, "qsa_decode_attn_batch: unsupported geometry or missing buffers\n");std::exit(1);}- const int kv_mode = pools.k_q4 != nullptr ? 2 : (pools.k_q != nullptr ? 1 : 0);+ const int kv_mode = pools.k_q4 != nullptr ? 2 : (pools.k_q != nullptr && pools.v_q4 != nullptr ? 3+ : (pools.k_q != nullptr ? 1 : 0));const int n_chunks = (int) ((cap + CHUNK - 1) / CHUNK);// per query: [acc: n_chunks*n_head*HD][m: n_chunks*n_head][l: n_chunks*n_head], all offsets from one strideconst long long stride = (long long) qsa_decode_attn_scratch_floats(cap, s);@@ -301,13 +311,29 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3const dpct::dim3 grid((unsigned)n_chunks, (unsigned)s.n_head_kv,(unsigned)n_q);dpct::queue_ptr st = strata::q_of(stream);- if (kv_mode == 2)+ if (kv_mode == 3)+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};+ dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});++ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_b8af5b,+ dpct_kernel_scalar<3>>>(+ sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),+ sycl::range(1, 1, THREADS)),+ exp_props,+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(32)]] {+ attn_chunk_kernel<3>(q, pools, ids, steps, (int)s.n_head_kv,+ (int)s.page_size, scale, part_acc, part_m,+ part_l, n_chunks, (int)cap, stride);+ });+ } else if (kv_mode == 2){auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});- st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_411f11,+ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_dfacfc,dpct_kernel_scalar<2>>>(sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -323,7 +349,7 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3sycl::ext::oneapi::experimental::use_root_sync};dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});- st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_5a54ec,+ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_b0d448,dpct_kernel_scalar<1>>>(sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -338,7 +364,7 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3sycl::ext::oneapi::experimental::use_root_sync};dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});- st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_d59020,+ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_2ad0a4,dpct_kernel_scalar<0>>>(sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -353,7 +379,7 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class attn_merge_kernel_ed01b1>>(+ st->parallel_for<dpct_kernel_name<class attn_merge_kernel_b5c617>>(sycl::nd_range<3>(sycl::range(1, (unsigned)n_q, (unsigned)s.n_head) *sycl::range(1, 1, HD),@@ -364,7 +390,7 @@ void qsa_decode_attn_batch(const float* q, const QsaAttnPools& pools, const int3});}/*- DPCT1010:451: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -383,8 +409,11 @@ void qsa_decode_attn_step(const float* q, const QsaAttnPools& pools, const int32std::fprintf(stderr, "qsa_decode_attn: unsupported geometry or missing buffers\n");std::exit(1);}- const int kv_mode = pools.k_q4 != nullptr ? 2 : (pools.k_q != nullptr ? 1 : 0);- if (kv_mode == 2 ? (!pools.v_q4) : (kv_mode == 1 ? (!pools.v_q || !pools.k_scale || !pools.v_scale) : (!pools.k_pool || !pools.v_pool))) {+ const int kv_mode = pools.k_q4 != nullptr ? 2 : (pools.k_q != nullptr && pools.v_q4 != nullptr ? 3+ : (pools.k_q != nullptr ? 1 : 0));+ if (kv_mode == 3 ? (!pools.k_scale || !pools.v_q4)+ : (kv_mode == 2 ? (!pools.v_q4) : (kv_mode == 1 ? (!pools.v_q || !pools.k_scale || !pools.v_scale)+ : (!pools.k_pool || !pools.v_pool)))) {std::fprintf(stderr, "qsa_decode_attn: incomplete KV pools\n");std::exit(1);}@@ -395,13 +424,29 @@ void qsa_decode_attn_step(const float* q, const QsaAttnPools& pools, const int32const float scale = 1.0f / sqrtf((float) HD);const dpct::dim3 grid((unsigned)n_chunks, (unsigned)s.n_head_kv);dpct::queue_ptr st = strata::q_of(stream);- if (kv_mode == 2)+ if (kv_mode == 3)+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};+ dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});++ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_61a169,+ dpct_kernel_scalar<3>>>(+ sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),+ sycl::range(1, 1, THREADS)),+ exp_props,+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(32)]] {+ attn_chunk_kernel<3>(q, pools, ids, step, (int)s.n_head_kv,+ (int)s.page_size, scale, part_acc, part_m,+ part_l, n_chunks, 0, 0);+ });+ } else if (kv_mode == 2){auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});- st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_bd420a,+ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_f262e6,dpct_kernel_scalar<2>>>(sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -417,7 +462,7 @@ void qsa_decode_attn_step(const float* q, const QsaAttnPools& pools, const int32sycl::ext::oneapi::experimental::use_root_sync};dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});- st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_19615d,+ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_4fd923,dpct_kernel_scalar<1>>>(sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -432,7 +477,7 @@ void qsa_decode_attn_step(const float* q, const QsaAttnPools& pools, const int32sycl::ext::oneapi::experimental::use_root_sync};dpct::has_capability_or_fail(st->get_device(), {sycl::aspect::fp16});- st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_bf0626,+ st->parallel_for<dpct_kernel_name<class attn_chunk_kernel_f6855e,dpct_kernel_scalar<0>>>(sycl::nd_range<3>(grid * sycl::range(1, 1, THREADS),sycl::range(1, 1, THREADS)),@@ -447,7 +492,7 @@ void qsa_decode_attn_step(const float* q, const QsaAttnPools& pools, const int32auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync};- st->parallel_for<dpct_kernel_name<class attn_merge_kernel_814186>>(+ st->parallel_for<dpct_kernel_name<class attn_merge_kernel_a9568f>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)s.n_head) *sycl::range(1, 1, HD),sycl::range(1, 1, HD)),@@ -456,7 +501,7 @@ void qsa_decode_attn_step(const float* q, const QsaAttnPools& pools, const int32});}/*- DPCT1010:453: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/qsa_prompt_attn.dp.cpp b/sycl/src/kernels/cuda/qsa_prompt_attn.dp.cppindex ea2c21be4..1f38376b0 100644--- a/sycl/src/kernels/cuda/qsa_prompt_attn.dp.cpp+++ b/sycl/src/kernels/cuda/qsa_prompt_attn.dp.cpp@@ -5,11 +5,13 @@#include "strata/sycl_queue.hpp"#include "strata/kernels/qsa_prompt_attn.hpp"#include "strata/kernels/kv_q8.hpp"+#include "strata/kernels/kv_q4.hpp"++#include <cmath>#include <cstdio>#include <cstdlib>#include <type_traits>-#include <cmath>namespace strata::kernels {namespace {@@ -25,7 +27,9 @@ constexpr int QS = HD + 8; // q row stride in halves (bank-conflict-free// The MMA and cp.async below need sm_80. Builds for older cards (the experimental sm_75 one) compile them to a trap;// qsa_prompt_attn_batch refuses such a device at run time, so the old kernel runs there.-#if 0 // SYCL: inline PTX (mma/ldmatrix/cp.async) - the XMX port is pending; see tools/fixups.py+#if defined(__HIPCC__) // AMD: no mma.sync / cp.async; the host keeps the old kernel (below)+#define STRATA_PA_SM80 0+#elif 0 // SYCL: inline PTX (mma/ldmatrix/cp.async) - the XMX port is pending; see tools/fixups.py#define STRATA_PA_SM80 1#else#define STRATA_PA_SM80 0@@ -77,15 +81,20 @@ __dpct_inline__ uint32_t pack_h2(float lo_k,}// KV_MODE 1: int8 codes + fp16 scale per 64 values. KV_MODE 0: fp16 values (scales 1).+// KV_MODE 3 (hybrid K8V4): K as mode 1, V as mode 0 - the row's q4_0 blocks are dequantized to fp16 at+// gather, so everything downstream of the load is the mode-0 V path; the caller un-rotates the output.template <int KV_MODE>struct Smem {- using Elem =+ using KElem =+ typename std::conditional<KV_MODE == 0, sycl::half, int8_t>::type;+ using VElem =typename std::conditional<KV_MODE == 1, int8_t, sycl::half>::type;- static constexpr int ROW = KV_MODE == 1 ? HD + 16 : HD + 8; // elements; 16-byte aligned rows, banks spread+ static constexpr int KROW = KV_MODE == 0 ? HD + 8 : HD + 16; // elements; 16-byte aligned rows, banks spread+ static constexpr int VROW = KV_MODE == 1 ? HD + 16 : HD + 8;sycl::half qh[16][QS];sycl::half ql[16][QS];- Elem k[CH][ROW];- Elem v[CH][ROW];+ KElem k[CH][KROW];+ VElem v[CH][VROW];float ks[CH][4];float vs[CH][4];float s[16][CH + 1];@@ -98,7 +107,7 @@ struct Smem {template <int KV_MODE>/*-DPCT1110:134: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionprompt_attn_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -118,7 +127,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,attn += (size_t) qi * n_head * HD + (size_t) kvh * G * HD;ids += (size_t) qi * cap;/*- DPCT1098:727: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -134,7 +143,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,qm = sycl::fmax(qm, sycl::fabs(q[i]));#pragma unroll/*- DPCT1108:135: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -144,7 +153,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,qm, o));if (lane == 0) S.qmax[warp] = qm;/*- DPCT1065:733: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -153,7 +162,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,sycl::fmax(S.qmax[2], S.qmax[3]));int qe = 0;/*- DPCT1017:728: The sycl::frexp call is used instead of the frexpf call. These+ DPCT1017: The sycl::frexp call is used instead of the frexpf call. Thesetwo calls do not provide exactly the same functionality. Check the potentialprecision and/or performance issues for the generated code.*/@@ -176,9 +185,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,.convert<float, sycl::rounding_mode::automatic>()[0]).convert<sycl::half, sycl::rounding_mode::rte>()[0];}- if (t < 16) {- S.mrow[t] = -sycl::bit_cast<float, int>(0x7f800000U); S.lsum[t] = 0.0f;- }+ if (t < 16) { S.mrow[t] = -INFINITY; S.lsum[t] = 0.0f; }float acc[8][4];#pragma unroll@@ -196,46 +203,28 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,S.row[t] = r;}/*- DPCT1118:136: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:735: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier(); // rows ready; the previous chunk's p.v is done with// k, v, s- // gather the chunk's K and V rows (16-byte pieces) and their scales+ // gather the chunk's K and V rows (16-byte pieces; K8V4's V as q4_0 blocks dequantized to fp16)+ // and their scales{- constexpr int PIECES = HD * (int) sizeof(typename Smem<KV_MODE>::Elem) / 16; // per row- for (int i = t; i < CH * PIECES; i += THREADS) {- const int c = i / PIECES, pc = i % PIECES;+ constexpr int KPIECES = HD * (int) sizeof(typename Smem<KV_MODE>::KElem) / 16; // per K row+ for (int i = t; i < CH * KPIECES; i += THREADS) {+ const int c = i / KPIECES, pc = i % KPIECES;const long long r = S.row[c];- sycl::uint4 kx = sycl::uint4(0, 0, 0, 0), vx = kx;+ sycl::uint4 kx = sycl::uint4(0, 0, 0, 0);if (r >= 0) {- if constexpr (KV_MODE == 1) {- /*- DPCT1098:729: The '*' expression is used instead of the- __ldg call. These two expressions do not provide the- exact same functionality. Check the generated code for- potential precision and/or performance issues.- */- kx = *(reinterpret_cast<const sycl::uint4 *>(p.k_q +- r * HD) +- pc);- /*- DPCT1098:730: The '*' expression is used instead of the- __ldg call. These two expressions do not provide the- exact same functionality. Check the generated code for- potential precision and/or performance issues.- */- vx = *(reinterpret_cast<const sycl::uint4 *>(p.v_q +- r * HD) +- pc);- } else {+ if constexpr (KV_MODE == 0)/*- DPCT1098:731: The '*' expression is used instead of the+ DPCT1098: The '*' expression is used instead of the__ldg call. These two expressions do not provide theexact same functionality. Check the generated code forpotential precision and/or performance issues.@@ -243,23 +232,87 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,kx = *(reinterpret_cast<const sycl::uint4 *>(p.k_pool +r * HD) +pc);+ else // modes 1 and 3: the K side is INT8/*- DPCT1098:732: The '*' expression is used instead of the+ DPCT1098: The '*' expression is used instead of the__ldg call. These two expressions do not provide theexact same functionality. Check the generated code forpotential precision and/or performance issues.*/- vx = *(reinterpret_cast<const sycl::uint4 *>(p.v_pool ++ kx = *(reinterpret_cast<const sycl::uint4 *>(p.k_q +r * HD) +pc);- }}*reinterpret_cast<sycl::uint4 *>(reinterpret_cast<unsigned char *>(&S.k[c][0]) + pc * 16) =kx;- *reinterpret_cast<sycl::uint4 *>(- reinterpret_cast<unsigned char *>(&S.v[c][0]) + pc * 16) =- vx;+ }+ if constexpr (KV_MODE == 3) { // V: dequantize the row's q4_0 blocks straight into the fp16 V row+ constexpr int BLKS = HD / QK4_0;+ constexpr int BYTES = BLKS * (int) sizeof(block_q4_0);+ for (int i = t; i < CH * BLKS; i += THREADS) {+ const int c = i / BLKS, b = i % BLKS;+ const long long r = S.row[c];+#pragma unroll+ for (int j = 0; j < QK4_0; ++j)+ S.v[c][b * QK4_0 + j] = sycl::half(0);+ if (r >= 0) {+ const block_q4_0* blk = reinterpret_cast<const block_q4_0*>(p.v_q4 + r * BYTES) + b;+ const float d =+ sycl::vec<sycl::half, 1>(+ sycl::bit_cast<sycl::half, unsigned short>(+ blk->d))+ .convert<float,+ sycl::rounding_mode::automatic>()[0];+#pragma unroll+ for (int j = 0; j < QK4_0 / 2; ++j) {+ S.v[c][b * QK4_0 + j] =+ sycl::vec<float, 1>(+ (float)((int)(blk->qs[j] & 0x0F) - 8) * d)+ .convert<sycl::half,+ sycl::rounding_mode::rte>()[0];+ S.v[c][b * QK4_0 + j + QK4_0 / 2] =+ sycl::vec<float, 1>(+ (float)((int)(blk->qs[j] >> 4) - 8) * d)+ .convert<sycl::half,+ sycl::rounding_mode::rte>()[0];+ }+ }+ }+ } else {+ constexpr int VPIECES = HD * (int) sizeof(typename Smem<KV_MODE>::VElem) / 16; // per V row+ for (int i = t; i < CH * VPIECES; i += THREADS) {+ const int c = i / VPIECES, pc = i % VPIECES;+ const long long r = S.row[c];+ sycl::uint4 vx = sycl::uint4(0, 0, 0, 0);+ if (r >= 0) {+ if constexpr (KV_MODE == 1)+ /*+ DPCT1098: The '*' expression is used instead of+ the __ldg call. These two expressions do not provide+ the exact same functionality. Check the generated+ code for potential precision and/or performance+ issues.+ */+ vx = *(reinterpret_cast<const sycl::uint4 *>(+ p.v_q + r * HD) ++ pc);+ else+ /*+ DPCT1098: The '*' expression is used instead of+ the __ldg call. These two expressions do not provide+ the exact same functionality. Check the generated+ code for potential precision and/or performance+ issues.+ */+ vx = *(reinterpret_cast<const sycl::uint4 *>(+ p.v_pool + r * HD) ++ pc);+ }+ *reinterpret_cast<sycl::uint4 *>(+ reinterpret_cast<unsigned char *>(&S.v[c][0]) ++ pc * 16) = vx;+ }}for (int i = t; i < CH * 4; i += THREADS) {const int c = i / 4, g = i % 4;@@ -277,6 +330,13 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,p.v_scale[r * (HD / KV_Q8_GROUP) + g])).convert<float,sycl::rounding_mode::automatic>()[0];+ } else if constexpr (KV_MODE == 3) { // K as int8, V dequantized to fp16 (scale 1)+ a = sycl::vec<sycl::half, 1>(+ sycl::bit_cast<sycl::half, unsigned short>(+ p.k_scale[r * (HD / KV_Q8_GROUP) + g]))+ .convert<float,+ sycl::rounding_mode::automatic>()[0];+ b = 1.0f;} else {a = b = 1.0f;}@@ -286,11 +346,11 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,}}/*- DPCT1118:137: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:736: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -315,7 +375,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,al[1] = *reinterpret_cast<const uint32_t*>(&S.ql[gid + 8][k0 + 2 * tig]);al[2] = *reinterpret_cast<const uint32_t*>(&S.ql[gid][k0 + 2 * tig + 8]);al[3] = *reinterpret_cast<const uint32_t*>(&S.ql[gid + 8][k0 + 2 * tig + 8]);- if constexpr (KV_MODE == 1) {+ if constexpr (KV_MODE != 0) { // modes 1 and 3: the K side is INT8 codesb[0] = i8x2_to_h2(*reinterpret_cast<const uint16_t*>(&S.k[cb + gid][k0 + 2 * tig]));b[1] = i8x2_to_h2(*reinterpret_cast<const uint16_t*>(&S.k[cb + gid][k0 + 2 * tig + 8]));} else {@@ -334,23 +394,17 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,sc[3] = sycl::fma(tg[3], (float)s1, sc[3]);}const int c = cb + 2 * tig;- S.s[gid][c] = c < nh ? sc[0] * qdown- : -sycl::bit_cast<float, int>(0x7f800000U);- S.s[gid][c + 1] = c + 1 < nh- ? sc[1] * qdown- : -sycl::bit_cast<float, int>(0x7f800000U);- S.s[gid + 8][c] = c < nh ? sc[2] * qdown- : -sycl::bit_cast<float, int>(0x7f800000U);- S.s[gid + 8][c + 1] =- c + 1 < nh ? sc[3] * qdown- : -sycl::bit_cast<float, int>(0x7f800000U);+ S.s[gid][c] = c < nh ? sc[0] * qdown : -INFINITY;+ S.s[gid][c + 1] = c + 1 < nh ? sc[1] * qdown : -INFINITY;+ S.s[gid + 8][c] = c < nh ? sc[2] * qdown : -INFINITY;+ S.s[gid + 8][c + 1] = c + 1 < nh ? sc[3] * qdown : -INFINITY;}/*- DPCT1118:138: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:737: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -359,14 +413,14 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,{constexpr int PER = CH / 8;const int r = t >> 3, sub = t & 7;- float x[PER], mx = -sycl::bit_cast<float, int>(0x7f800000U);+ float x[PER], mx = -INFINITY;#pragma unrollfor (int j = 0; j < PER; ++j) {x[j] = S.s[r][sub * PER + j]; mx = sycl::fmax(mx, x[j]);}#pragma unroll/*- DPCT1108:140: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -380,15 +434,14 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,float sum = 0.0f;#pragma unrollfor (int j = 0; j < PER; ++j) {- const float e = x[j] == -sycl::bit_cast<float, int>(0x7f800000U)- ? 0.0f- : sycl::exp2(x[j] - m_new);+ const float e =+ x[j] == -INFINITY ? 0.0f : sycl::exp2(x[j] - m_new);S.s[r][sub * PER + j] = e;sum += e;}#pragma unroll/*- DPCT1108:141: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -400,20 +453,18 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,sycl::ext::oneapi::this_work_item::get_sub_group());if (sub == 0) {const float a =- m_old == -sycl::bit_cast<float, int>(0x7f800000U)- ? 0.0f- : sycl::exp2(m_old - m_new);+ m_old == -INFINITY ? 0.0f : sycl::exp2(m_old - m_new);S.alpha[r] = a;S.lsum[r] = sycl::fma(S.lsum[r], (float)a, sum);S.mrow[r] = m_new;}}/*- DPCT1118:139: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:738: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -428,7 +479,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,vmax = sycl::fmax(vmax, S.vs[c][warp]);#pragma unroll/*- DPCT1108:142: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -506,7 +557,7 @@ prompt_attn_kernel(const float *__restrict__ q, QsaAttnPools p,}}/*- DPCT1065:734: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -552,7 +603,7 @@ __dpct_inline__ void cp_async16(void *smem, const void *gmem, bool valid) {#elseauto sa = smem;/*- DPCT1053:143: Migration of device assembly code is not supported.+ DPCT1053: Migration of device assembly code is not supported.*/asm volatile("cp.async.cg.shared.global [%0], [%1], 16, %2;\n" ::"r"(sa),"l"(gmem), "r"(valid ? 16 : 0));@@ -578,7 +629,7 @@ __dpct_inline__ void cp_async_wait1() {}/*-DPCT1110:146: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionprompt_attn_i8_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -598,7 +649,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,attn += (size_t) qi * n_head * HD + (size_t) kvh * G * HD;ids += (size_t) qi * cap;/*- DPCT1098:741: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -614,7 +665,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,qm = sycl::fmax(qm, sycl::fabs(q[i]));#pragma unroll/*- DPCT1108:147: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -623,11 +674,9 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),qm, o));if (lane == 0) S.qmax[warp] = qm;- if (t < 16) {- S.mrow[t] = -sycl::bit_cast<float, int>(0x7f800000U); S.lsum[t] = 0.0f;- }+ if (t < 16) { S.mrow[t] = -INFINITY; S.lsum[t] = 0.0f; }/*- DPCT1065:739: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -636,7 +685,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,sycl::fmax(S.qmax[2], S.qmax[3]));int qe = 0;/*- DPCT1017:742: The sycl::frexp call is used instead of the frexpf call. These+ DPCT1017: The sycl::frexp call is used instead of the frexpf call. Thesetwo calls do not provide exactly the same functionality. Check the potentialprecision and/or performance issues for the generated code.*/@@ -672,7 +721,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,// the chunk pipeline: cells two chunks ahead, their pool rows one chunk ahead, the data (cp.async) one aheadconst int n_chunks = (n + CH2 - 1) / CH2;/*- DPCT1098:743: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -682,7 +731,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,auto row_of = [&](int cell) -> long long {if (cell < 0) return -1;/*- DPCT1098:744: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -694,12 +743,12 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,for (int j = 0; j < 4; ++j) {const int idx = lane + 32 * j, cell = idx >> 2, pc = idx & 3;/*- DPCT1108:148: '__shfl_sync' was migrated with the experimental+ DPCT1108: '__shfl_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*//*- DPCT1121:149: Make sure that the "r" which is used in the SYCL group+ DPCT1121: Make sure that the "r" which is used in the SYCL groupfunction/algorithm is initialized.*/const long long rr = dpct::experimental::select_from_sub_group(@@ -711,7 +760,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,cp_async16(&S.kv[st][warp][1][0][0] + swz(cell, pc * 16), p.v_q + off, ok);}/*- DPCT1098:745: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -721,7 +770,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,.convert<float, sycl::rounding_mode::automatic>()[0]: 0.0f;/*- DPCT1098:746: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -775,11 +824,11 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,S.part[warp][gid + 8][c + 1] = tg[3] * s1;}/*- DPCT1118:150: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:747: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -787,20 +836,17 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,// online softmax over the four groups' sum (fixed order): row t/8, 4 cells per thread{const int r = t >> 3, sub = t & 7;- float x[4], mx = -sycl::bit_cast<float, int>(0x7f800000U);+ float x[4], mx = -INFINITY;#pragma unrollfor (int j = 0; j < 4; ++j) {const int c = sub * 4 + j;- x[j] = c0 + c < n ? (((S.part[0][r][c] + S.part[1][r][c]) +- S.part[2][r][c]) +- S.part[3][r][c]) *- qdown- : -sycl::bit_cast<float, int>(0x7f800000U);+ x[j] = c0 + c < n ? (((S.part[0][r][c] + S.part[1][r][c]) + S.part[2][r][c]) + S.part[3][r][c]) * qdown+ : -INFINITY;mx = sycl::fmax(mx, x[j]);}#pragma unroll/*- DPCT1108:152: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -814,15 +860,14 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,float sum = 0.0f;#pragma unrollfor (int j = 0; j < 4; ++j) {- const float e = x[j] == -sycl::bit_cast<float, int>(0x7f800000U)- ? 0.0f- : sycl::exp2(x[j] - m_new);+ const float e =+ x[j] == -INFINITY ? 0.0f : sycl::exp2(x[j] - m_new);S.p[r][sub * 4 + j] = e;sum += e;}#pragma unroll/*- DPCT1108:153: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -834,20 +879,18 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,sycl::ext::oneapi::this_work_item::get_sub_group());if (sub == 0) {const float a =- m_old == -sycl::bit_cast<float, int>(0x7f800000U)- ? 0.0f- : sycl::exp2(m_old - m_new);+ m_old == -INFINITY ? 0.0f : sycl::exp2(m_old - m_new);S.alpha[r] = a;S.lsum[r] = sycl::fma(S.lsum[r], (float)a, sum);S.mrow[r] = m_new;}}/*- DPCT1118:151: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:748: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -857,7 +900,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,float vmax = S.sc[st][warp][1][lane];#pragma unroll/*- DPCT1108:154: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -929,7 +972,7 @@ prompt_attn_i8_kernel(const float *__restrict__ q, QsaAttnPools p,sycl::group_barrier(sycl::ext::oneapi::this_work_item::get_sub_group());}/*- DPCT1065:740: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -955,7 +998,7 @@ bool launch_i8(const float *q, const QsaAttnPools &pools, const int32_t *ids,int dev = 0;dev = dpct::get_current_device_id();/*- DPCT1083:155: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -963,12 +1006,12 @@ bool launch_i8(const float *q, const QsaAttnPools &pools, const int32_t *ids,if (dev < 0 || dev >= 64) return false;if (!attr[dev]) {/*- DPCT1027:749: The call to cudaFuncSetAttribute was replaced with 0+ DPCT1027: The call to cudaFuncSetAttribute was replaced with 0because SYCL currently does not support corresponding setting.*/if (0 != 0) {/*- DPCT1026:750: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/return false;@@ -994,7 +1037,7 @@ bool launch_i8(const float *q, const QsaAttnPools &pools, const int32_t *ids,auto attn_q0_s_n_head_HD_ct7 = attn + q0 * s.n_head * HD;cgh.parallel_for<- dpct_kernel_name<class prompt_attn_i8_kernel_4540c2>>(+ dpct_kernel_name<class prompt_attn_i8_kernel_c3d463>>(sycl::nd_range<3>(sycl::range(1, (unsigned)s.n_head_kv, (unsigned)nb) *sycl::range(1, 1, THREADS),@@ -1015,7 +1058,7 @@ bool launch_i8(const float *q, const QsaAttnPools &pools, const int32_t *ids,}}/*- DPCT1010:751: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -1037,7 +1080,7 @@ bool launch(const float *q, const QsaAttnPools &pools, const int32_t *ids,int dev = 0;dev = dpct::get_current_device_id();/*- DPCT1083:156: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -1045,12 +1088,12 @@ bool launch(const float *q, const QsaAttnPools &pools, const int32_t *ids,if (dev < 0 || dev >= 64) return false;if (!attr[dev]) {/*- DPCT1027:756: The call to cudaFuncSetAttribute was replaced with 0+ DPCT1027: The call to cudaFuncSetAttribute was replaced with 0because SYCL currently does not support corresponding setting.*/if (0 != 0) {/*- DPCT1026:753: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/return false;@@ -1076,7 +1119,7 @@ bool launch(const float *q, const QsaAttnPools &pools, const int32_t *ids,auto attn_q0_s_n_head_HD_ct7 = attn + q0 * s.n_head * HD;cgh.parallel_for<- dpct_kernel_name<class prompt_attn_kernel_410441,+ dpct_kernel_name<class prompt_attn_kernel_e09b15,dpct_kernel_scalar<KV_MODE>>>(sycl::nd_range<3>(sycl::range(1, (unsigned)s.n_head_kv, (unsigned)nb) *@@ -1098,7 +1141,7 @@ bool launch(const float *q, const QsaAttnPools &pools, const int32_t *ids,}}/*- DPCT1010:754: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -1123,7 +1166,7 @@ bool qsa_prompt_attn_batch(const float *q, const QsaAttnPools &pools,static int cc_major[64] = {};int dev = 0;/*- DPCT1026:757: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/if (DPCT_CHECK_ERROR(dev = dpct::get_current_device_id()) != 0 ||@@ -1135,7 +1178,7 @@ bool qsa_prompt_attn_batch(const float *q, const QsaAttnPools &pools,if (DPCT_CHECK_ERROR(major = dpct::get_device(dev).get_major_version()) != 0) {/*- DPCT1026:758: The call to cudaGetLastError was removed because+ DPCT1026: The call to cudaGetLastError was removed becausethis functionality is redundant in SYCL.*/return false;@@ -1145,10 +1188,17 @@ bool qsa_prompt_attn_batch(const float *q, const QsaAttnPools &pools,(void) cc_major[dev];return false; // SYCL: the tensor-core kernel is not ported yet; the caller takes the older kernel}+#if defined(__HIPCC__)+ return false; // the tensor-core kernel is compiled out on AMD (its major version is not a CUDA sm)+#endifif (pools.k_q4 != nullptr || s.head_dim != HD || s.n_head != (int64_t) G * s.n_head_kv || cap <= 0 || !ids ||!steps || !pools.page_table)return false;dpct::queue_ptr st = strata::q_of(stream);+ if (pools.k_q != nullptr && pools.v_q4 != nullptr) { // hybrid K8V4: int8 K + dequantized-q4 V+ if (!pools.k_scale) return false;+ return launch<3>(q, pools, ids, steps, cap, s, attn, n_q, st);+ }if (pools.k_q != nullptr) {if (!pools.v_q || !pools.k_scale || !pools.v_scale) return false;// STRATA_PROMPT_ATTN_V1=1 (debug): the first version, same accuracy, another summation order - the controldiff --git a/sycl/src/kernels/cuda/qsa_select.dp.cpp b/sycl/src/kernels/cuda/qsa_select.dp.cppindex 676a89930..91ef8f695 100644--- a/sycl/src/kernels/cuda/qsa_select.dp.cpp+++ b/sycl/src/kernels/cuda/qsa_select.dp.cpp@@ -50,7 +50,7 @@ __dpct_inline__ void block_scores_kernel(const float *__restrict__ pooled,k4.w() * q4.w();#pragma unroll/*- DPCT1108:112: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -67,7 +67,7 @@ __dpct_inline__ void block_scores_kernel(const float *__restrict__ pooled,}/*-DPCT1110:113: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionblock_topk_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -111,11 +111,11 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(#pragma unrollfor (int i = t; i < 256; i += TOPK_T) hist[i] = 0;/*- DPCT1118:114: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:610: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -130,11 +130,11 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(&hist[(k >> shift) & 255], w);}/*- DPCT1118:115: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:611: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -150,11 +150,11 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(s_above = cum;}/*- DPCT1118:116: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:612: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -162,11 +162,11 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(prefix |= (uint32_t) s_digit << shift;above = s_above;/*- DPCT1118:117: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:613: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -186,7 +186,7 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(s_a[t] = gt;s_b[t] = eq;/*- DPCT1065:605: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -200,7 +200,7 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(}}/*- DPCT1065:606: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -211,14 +211,14 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(if (my_eq > eq) my_eq = eq;const int sel = gt + (int) my_eq;/*- DPCT1065:607: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier();s_a[t] = sel;/*- DPCT1065:608: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -228,7 +228,7 @@ auto &hist = *sycl::ext::oneapi::group_local_memory_for_overwrite<int[256]>(for (int i = 0; i < TOPK_T; ++i) { const int c = s_a[i]; s_a[i] = a; a += c; }}/*- DPCT1065:609: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -263,7 +263,9 @@ constexpr int TC_QS = IDX_HEADS * IDX_DIM + 4; // query row stride in floatsconstexpr int TC_KS = IDX_DIM + 4; // key row stride// TF32 conversion and MMA need sm_80: below it they compile to a trap and qsa_block_scores_tc refuses the device-#if 0 // SYCL: inline PTX (mma/ldmatrix/cp.async) - the XMX port is pending; see tools/fixups.py+#if defined(__HIPCC__) // AMD: no mma.sync / cp.async; the host keeps the warp kernel (below)+#define STRATA_SEL_SM80 0+#elif 0 // SYCL: inline PTX (mma/ldmatrix/cp.async) - the XMX port is pending; see tools/fixups.py#define STRATA_SEL_SM80 1#else#define STRATA_SEL_SM80 0@@ -272,7 +274,7 @@ __dpct_inline__ uint32_t tf32_hi(float x) {#if STRATA_SEL_SM80uint32_t r;/*- DPCT1053:118: Migration of device assembly code is not supported.+ DPCT1053: Migration of device assembly code is not supported.*/asm("cvt.rna.tf32.f32 %0, %1;" : "=r"(r) : "f"(x));return r;@@ -285,7 +287,7 @@ __dpct_inline__ void mma_tf32(float *c, const uint32_t *a, const uint32_t *b) {/* unreachable on SYCL: the launcher refuses this device */#else/*- DPCT1053:119: Migration of device assembly code is not supported.+ DPCT1053: Migration of device assembly code is not supported.*/asm volatile("mma.sync.aligned.m16n8k8.row.col.f32.tf32.tf32.f32 ""{%0,%1,%2,%3}, {%4,%5,%6,%7}, {%8,%9}, "@@ -297,7 +299,7 @@ __dpct_inline__ void mma_tf32(float *c, const uint32_t *a, const uint32_t *b) {}/*-DPCT1110:120: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionblock_scores_tc_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -337,11 +339,11 @@ __dpct_inline__ void block_scores_tc_kernel(((int64_t)item_ct1.get_group(2) * TC_ITER + it) * TC_NB;if (b0 >= reach || b0 >= hi_nbid) break; // blocks >= every query's n_bid: nothing to score/*- DPCT1118:121: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:614: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -354,11 +356,11 @@ __dpct_inline__ void block_scores_tc_kernel(*reinterpret_cast<sycl::float4 *>(sK + r * TC_KS + c * 4) = v;}/*- DPCT1118:122: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:615: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -439,7 +441,7 @@ __dpct_inline__ void block_scores_tail_kernel(const float *__restrict__ dead,k4.w() * q4.w();#pragma unroll/*- DPCT1108:123: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -469,7 +471,7 @@ __dpct_inline__ int block_excl_scan(int v, int *s_warp, int &total) {#pragma unrollfor (int o = 1; o < 32; o <<= 1) {/*- DPCT1108:124: '__shfl_up_sync' was migrated with the experimental+ DPCT1108: '__shfl_up_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -480,7 +482,7 @@ __dpct_inline__ int block_excl_scan(int v, int *s_warp, int &total) {}if (lane == 31) s_warp[warp] = x;/*- DPCT1065:616: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -491,7 +493,7 @@ __dpct_inline__ int block_excl_scan(int v, int *s_warp, int &total) {#pragma unrollfor (int o = 1; o < 32; o <<= 1) {/*- DPCT1108:125: '__shfl_up_sync' was migrated with the experimental+ DPCT1108: '__shfl_up_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -504,7 +506,7 @@ __dpct_inline__ int block_excl_scan(int v, int *s_warp, int &total) {if (lane == 31) s_warp[32] = z; // total}/*- DPCT1065:617: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -512,7 +514,7 @@ __dpct_inline__ int block_excl_scan(int v, int *s_warp, int &total) {const int r = s_warp[warp] + x - v;total = s_warp[32];/*- DPCT1065:618: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -521,7 +523,7 @@ __dpct_inline__ int block_excl_scan(int v, int *s_warp, int &total) {}/*-DPCT1110:126: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionblock_topk_reg_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -578,11 +580,11 @@ auto &hist =&hist[warp][(key[j] >> shift) & 255], w);}/*- DPCT1118:127: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:619: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -594,11 +596,11 @@ auto &hist =hist[0][t] = s;}/*- DPCT1118:128: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:620: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -614,11 +616,11 @@ auto &hist =s_above = cum;}/*- DPCT1118:129: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:621: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -626,11 +628,11 @@ auto &hist =prefix |= (uint32_t) s_digit << shift;above = s_above;/*- DPCT1118:130: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:622: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -691,7 +693,7 @@ void qsa_block_scores(const float* pooled, const float* dead, const float* q_idxsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class block_scores_kernel_8916c5>>(+ ->parallel_for<dpct_kernel_name<class block_scores_kernel_6f5935>>(sycl::nd_range<3>(grid * sycl::range(1, 1, SCORE_WARPS * 32),sycl::range(1, 1, SCORE_WARPS * 32)),exp_props,@@ -702,13 +704,13 @@ void qsa_block_scores(const float* pooled, const float* dead, const float* q_idx});}/*- DPCT1010:623: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:624: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -724,7 +726,7 @@ bool qsa_block_scores_tc(const float *pooled, const float *dead,static int cc_major[64] = {};int dev = 0;/*- DPCT1026:625: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/if (DPCT_CHECK_ERROR(dev = dpct::get_current_device_id()) != 0 ||@@ -736,7 +738,7 @@ bool qsa_block_scores_tc(const float *pooled, const float *dead,if (DPCT_CHECK_ERROR(major = dpct::get_device(dev).get_major_version()) != 0) {/*- DPCT1026:626: The call to cudaGetLastError was removed because+ DPCT1026: The call to cudaGetLastError was removed becausethis functionality is redundant in SYCL.*/return false;@@ -746,23 +748,26 @@ bool qsa_block_scores_tc(const float *pooled, const float *dead,(void) cc_major[dev];return false; // SYCL: the tensor-core kernel is not ported yet; the caller takes the older kernel}+#if defined(__HIPCC__)+ return false; // the tensor-core kernel is compiled out on AMD (its major version is not a CUDA sm)+#endifstatic bool attr[64] = {}; // the shared-memory opt-in is per device (a layer split runs it on several)int adev = 0;adev = dpct::get_current_device_id();/*- DPCT1083:131: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/const int bytes = (TC_QT * TC_QS + TC_NB * TC_KS) * (int)sizeof(float);if (!attr[adev]) {/*- DPCT1027:627: The call to cudaFuncSetAttribute was replaced with 0+ DPCT1027: The call to cudaFuncSetAttribute was replaced with 0because SYCL currently does not support corresponding setting.*/if (0 != 0) {/*- DPCT1026:628: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/return false;@@ -783,7 +788,7 @@ bool qsa_block_scores_tc(const float *pooled, const float *dead,sycl::range(bytes), cgh);cgh.parallel_for<- dpct_kernel_name<class block_scores_tc_kernel_236d56>>(+ dpct_kernel_name<class block_scores_tc_kernel_f08b24>>(sycl::nd_range<3>(grid * sycl::range(1, 1, 128),sycl::range(1, 1, 128)),exp_props, [=](sycl::nd_item<3> item_ct1) {@@ -801,7 +806,7 @@ bool qsa_block_scores_tc(const float *pooled, const float *dead,strata::q_of(stream)->parallel_for<- dpct_kernel_name<class block_scores_tail_kernel_79a8ce>>(+ dpct_kernel_name<class block_scores_tail_kernel_8303e7>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)nq) *sycl::range(1, 1, 32),sycl::range(1, 1, 32)),@@ -813,13 +818,13 @@ bool qsa_block_scores_tc(const float *pooled, const float *dead,});}/*- DPCT1010:629: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:630: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -844,7 +849,7 @@ void qsa_block_topk_ref(const float* scores, const int32_t* steps, int64_t nq, isycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class block_topk_kernel_52e176>>(+ ->parallel_for<dpct_kernel_name<class block_topk_kernel_409264>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)nq) *sycl::range(1, 1, TOPK_T),sycl::range(1, 1, TOPK_T)),@@ -853,13 +858,13 @@ void qsa_block_topk_ref(const float* scores, const int32_t* steps, int64_t nq, i});}/*- DPCT1010:631: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:632: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -880,7 +885,7 @@ void qsa_block_topk(const float* scores, const int32_t* steps, int64_t nq, int64std::exit(1);}/*- DPCT1049:132: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -890,7 +895,7 @@ void qsa_block_topk(const float* scores, const int32_t* steps, int64_t nq, int64strata::q_of(stream)->parallel_for<- dpct_kernel_name<class block_topk_reg_kernel_f7046a>>(+ dpct_kernel_name<class block_topk_reg_kernel_a867d1>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)nq) *sycl::range(1, 1, TK_T),sycl::range(1, 1, TK_T)),@@ -902,13 +907,13 @@ void qsa_block_topk(const float* scores, const int32_t* steps, int64_t nq, int64});}/*- DPCT1010:633: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:634: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/diff --git a/sycl/src/kernels/cuda/quantize_act.dp.cpp b/sycl/src/kernels/cuda/quantize_act.dp.cppindex 480da5b78..ec13c7dd4 100644--- a/sycl/src/kernels/cuda/quantize_act.dp.cpp+++ b/sycl/src/kernels/cuda/quantize_act.dp.cpp@@ -221,7 +221,7 @@ __dpct_inline__ void quantize_q8_K_kernel(const float *__restrict__ x,// from the reference in 1 element of 524,288 for exactly this reason, and `__fmul_rn` pins the// rounding step the source actually performs./*- DPCT1013:1066: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -284,7 +284,7 @@ void quantize_q8_0(const float* x, uint8_t* blocks, int64_t n, void* stream) {});}/*- DPCT1010:1067: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -324,7 +324,7 @@ void quantize_q8_0_scaled(const float* x, uint8_t* blocks, float* scales, int64_});}/*- DPCT1010:1069: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -352,7 +352,7 @@ void dequant_q8_0(const uint8_t* blocks, float* x, int64_t n, void* stream) {});}/*- DPCT1010:1071: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -384,7 +384,7 @@ void quantize_q8_K(const float* x, uint8_t* blocks, int64_t n, void* stream) {});}/*- DPCT1010:1073: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -412,7 +412,7 @@ void dequant_q8_K(const uint8_t* blocks, float* x, int64_t n, void* stream) {});}/*- DPCT1010:1075: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/rope.dp.cpp b/sycl/src/kernels/cuda/rope.dp.cppindex dfb884726..b11777b96 100644--- a/sycl/src/kernels/cuda/rope.dp.cpp+++ b/sycl/src/kernels/cuda/rope.dp.cpp@@ -112,7 +112,7 @@ void rope_neox_apply(const float* x, float* out, int64_t rows, int head_dim, int});}/*- DPCT1010:455: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/router_top10.dp.cpp b/sycl/src/kernels/cuda/router_top10.dp.cppindex 3bdaf09d0..b91748e72 100644--- a/sycl/src/kernels/cuda/router_top10.dp.cpp+++ b/sycl/src/kernels/cuda/router_top10.dp.cpp@@ -69,7 +69,7 @@ constexpr int RT_MAX_THREADS = 512;/// One BLOCK per token, so the reductions have somewhere to happen. `n_tokens` is 1 in decode; the grid keeps/// the batch case working without a second code path./*-DPCT1110:101: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionrouter_top10_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -107,7 +107,7 @@ __dpct_inline__ void router_top10_kernel(const float *__restrict__ logits,#pragma unrollfor (int e = tid; e < n_expert; e += nt) mx = sycl::fmax(mx, l[e]);/*-DPCT1108:102: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -118,7 +118,7 @@ runtimes. You may need to adjust the code.mx, off));if ((tid & 31) == 0) s_red[tid >> 5] = mx;/*- DPCT1065:526: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -127,7 +127,7 @@ runtimes. You may need to adjust the code.const int nw = (nt + 31) >> 5;float v = (tid < nw) ? s_red[tid] : -INFINITY;/*-DPCT1108:103: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -139,7 +139,7 @@ runtimes. You may need to adjust the code.if (tid == 0) s_red[0] = v;}/*- DPCT1065:527: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -152,7 +152,7 @@ runtimes. You may need to adjust the code.for (int e = tid; e < n_expert; e += nt)s_ex[e] = sycl::exp((double)l[e] - (double)mx);/*- DPCT1065:528: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -166,7 +166,7 @@ runtimes. You may need to adjust the code.s_sum = sum;}/*- DPCT1065:529: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -186,7 +186,7 @@ runtimes. You may need to adjust the code.#pragma unrollfor (int e = tid; e < n_expert; e += nt) s_p[e] = (float)(s_ex[e] * inv);/*- DPCT1065:530: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -207,7 +207,7 @@ runtimes. You may need to adjust the code.#pragma unrollfor (int e = tid; e < n_expert; e += nt) s_taken[e] = 0;/*- DPCT1065:531: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -223,7 +223,7 @@ runtimes. You may need to adjust the code.}for (int off = 16; off > 0; off >>= 1) {/*- DPCT1108:106: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -231,7 +231,7 @@ runtimes. You may need to adjust the code.0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),bv, off);/*- DPCT1108:107: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -242,11 +242,11 @@ runtimes. You may need to adjust the code.}if ((tid & 31) == 0) { s_red[tid >> 5] = bv; s_rid[tid >> 5] = bi; }/*- DPCT1118:104: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:533: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -257,7 +257,7 @@ runtimes. You may need to adjust the code.int ix = (tid < nw) ? s_rid[tid] : n_expert;for (int off = 16; off > 0; off >>= 1) {/*- DPCT1108:108: '__shfl_down_sync' was migrated with the+ DPCT1108: '__shfl_down_sync' was migrated with theexperimental feature masked sub_group function which may not besupported by all compilers or runtimes. You may need to adjustthe code.@@ -266,7 +266,7 @@ runtimes. You may need to adjust the code.0xffffffffu,sycl::ext::oneapi::this_work_item::get_sub_group(), v, off);/*- DPCT1108:109: '__shfl_down_sync' was migrated with the+ DPCT1108: '__shfl_down_sync' was migrated with theexperimental feature masked sub_group function which may not besupported by all compilers or runtimes. You may need to adjustthe code.@@ -284,18 +284,18 @@ runtimes. You may need to adjust the code.}}/*- DPCT1118:105: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:534: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier();}/*- DPCT1065:532: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -334,14 +334,14 @@ void router_top10(const float *logits, int n_tokens, int n_expert, int k,const size_t taken_bytes = ((size_t) n_expert + 15u) & ~(size_t) 15u;const size_t smem =/*- DPCT1083:111: The size of local memory in the migrated code may be+ DPCT1083: The size of local memory in the migrated code may bedifferent from the original code. Check that the allocated memory sizein the migrated code is correct.*/taken_bytes + (size_t)n_expert * sizeof(double) +(size_t)n_expert * sizeof(float);/*- DPCT1049:110: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -374,7 +374,7 @@ void router_top10(const float *logits, int n_tokens, int n_expert, int k,});}/*- DPCT1010:535: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/s2_expert_grouped.dp.cpp b/sycl/src/kernels/cuda/s2_expert_grouped.dp.cppindex 7b1e587ba..0098de164 100644--- a/sycl/src/kernels/cuda/s2_expert_grouped.dp.cpp+++ b/sycl/src/kernels/cuda/s2_expert_grouped.dp.cpp@@ -106,12 +106,12 @@ row_dot_s2_q8(const uint8_t *__restrict__ codes,__dpct_inline__ float warp_sum(float v) {#pragma unroll/*- DPCT1108:282: '__shfl_down_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*- DPCT1121:283: Make sure that the "v" which is used in the SYCL group+ DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/for (int off = 16; off > 0; off >>= 1) v +=@@ -237,7 +237,7 @@ __dpct_inline__ void activation_correction_kernel(const uint8_t *q8,#pragma unrollfor (int j = 0; j < 32; ++j) sum += q[j];/*- DPCT1013:1077: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -267,14 +267,14 @@ __dpct_inline__ float row_dot_cpu_order(const uint8_t *codes,const int hi = dot4(codes + b * 16 + 8 + lane,(const int8_t*) (xq + (size_t) (2 * b + 1) * 34 + 2) + lane * 4);/*- DPCT1013:1078: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.*/acc = sycl::fma(d * xs[2 * b], (float)lo, acc);/*- DPCT1013:1079: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -282,7 +282,7 @@ __dpct_inline__ float row_dot_cpu_order(const uint8_t *codes,acc = sycl::fma(d * xs[2 * b + 1], (float)hi, acc);if (lane == 0)/*- DPCT1013:1080: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -293,12 +293,12 @@ __dpct_inline__ float row_dot_cpu_order(const uint8_t *codes,// a standard shuffle tree in the order 4, 2, 1 is a different floating-point expression.constexpr unsigned mask = 0xffffffffu;/*- DPCT1108:284: '__shfl_down_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*- DPCT1013:1081: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -307,12 +307,12 @@ __dpct_inline__ float row_dot_cpu_order(const uint8_t *codes,mask, sycl::ext::oneapi::this_work_item::get_sub_group(),acc, 4, 8);/*- DPCT1108:285: '__shfl_down_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*- DPCT1013:1082: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -321,12 +321,12 @@ __dpct_inline__ float row_dot_cpu_order(const uint8_t *codes,mask, sycl::ext::oneapi::this_work_item::get_sub_group(),acc, 1, 8);/*- DPCT1108:286: '__shfl_down_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*- DPCT1013:1083: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -335,7 +335,7 @@ __dpct_inline__ float row_dot_cpu_order(const uint8_t *codes,mask, sycl::ext::oneapi::this_work_item::get_sub_group(),acc, 2, 8);/*- DPCT1013:1084: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -380,7 +380,7 @@ __dpct_inline__ void cpu_order_swiglu_kernel(float *gu, int pairs) {// CPU/GPU libc last-bit differences are diagnosed separately by the micro, not hidden with FP64 here.const float eg = sycl::native::exp(-g);/*- DPCT1013:1085: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -401,14 +401,14 @@ __dpct_inline__ void cpu_order_quantize_kernel(const float *x, uint8_t *blocks,#pragma unrollfor (int j = 0; j < 32; ++j) amax = sycl::fmax(amax, sycl::fabs(xb[j]));/*- DPCT1013:1086: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/const float s = amax > 0.0f ? amax / 127.0f : 0.0f;/*- DPCT1013:1087: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -423,14 +423,14 @@ __dpct_inline__ void cpu_order_quantize_kernel(const float *x, uint8_t *blocks,int sum = 0;for (int j = 0; j < 32; ++j) {/*- DPCT1013:1088: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.*/const float t = xb[j] * inv;/*- DPCT1013:1089: The rounding mode could not be specified and the+ DPCT1013: The rounding mode could not be specified and thegenerated code may have different accuracy than the original code.Verify the correctness. SYCL math built-in function rounding mode isaligned with OpenCL C 1.2 standard.@@ -441,7 +441,7 @@ __dpct_inline__ void cpu_order_quantize_kernel(const float *x, uint8_t *blocks,sum += v;}/*- DPCT1013:1090: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -453,7 +453,7 @@ constexpr int THREADS = 256;void check(const char* who, void* stream) {/*- DPCT1010:1091: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -896,7 +896,7 @@ __dpct_inline__ float chunk_dot(sycl::uint2 cb, const int *xw, float dw,// its fp32 scales) are staged once into shared memory as aligned words; each warp then walks its rows, loading// each lane's code chunks once and dotting them with every entry./*-DPCT1110:287: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongu_grouped_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -1269,7 +1269,7 @@ void moe_hit_grouped_s2_cpu_order(const uint8_t *blob_base,check("cpu_order/gate_up", stream);if (gate_up_trace != nullptr &&/*- DPCT1124:1093: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.diff --git a/sycl/src/kernels/cuda/s2_gemv_fast.dp.cpp b/sycl/src/kernels/cuda/s2_gemv_fast.dp.cppindex 4014fdfb6..0da3d67c9 100644--- a/sycl/src/kernels/cuda/s2_gemv_fast.dp.cpp+++ b/sycl/src/kernels/cuda/s2_gemv_fast.dp.cpp@@ -73,7 +73,7 @@ catch (sycl::exception const &exc) {// configurations and the bench can measure them against each other with nothing else changed.template <bool STAGE_X>/*-DPCT1110:224: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functions2_gemv_fast_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -98,7 +98,7 @@ __dpct_inline__ void s2_gemv_fast_kernel(#pragma unrollfor (long long i = tid; i < n_in; i += threads_per_row) sx[i] = xh[i];/*- DPCT1118:225: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -142,7 +142,7 @@ __dpct_inline__ void s2_gemv_fast_kernel(for (int step = threads_per_row / 2; step > 0; step >>= 1) {if (tid < step) partial[tid] += partial[tid + step];/*- DPCT1118:226: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -167,7 +167,7 @@ void s2_gemv_fast(const uint16_t *x, const uint8_t *codes, const float *scales,std::exit(1);}/*- DPCT1083:228: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -175,7 +175,7 @@ void s2_gemv_fast(const uint16_t *x, const uint8_t *codes, const float *scales,(size_t)threads_per_row * sizeof(float);if (stage_x) {/*- DPCT1049:227: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -207,7 +207,7 @@ void s2_gemv_fast(const uint16_t *x, const uint8_t *codes, const float *scales,});} else {/*- DPCT1049:229: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/s2_gemv_q8.dp.cpp b/sycl/src/kernels/cuda/s2_gemv_q8.dp.cppindex 0be7d4ce5..f8cf26fe3 100644--- a/sycl/src/kernels/cuda/s2_gemv_q8.dp.cpp+++ b/sycl/src/kernels/cuda/s2_gemv_q8.dp.cpp@@ -77,7 +77,7 @@ __dpct_inline__ void s2_gemv_q8_kernel(const uint8_t *__restrict__ act,for (int step = threads_per_row / 2; step > 0; step >>= 1) {if (tid < step) partial[tid] += partial[tid + step];/*- DPCT1118:47: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -95,13 +95,13 @@ void s2_gemv_q8(const uint8_t* act, const uint8_t* codes, const float* scales, fstd::exit(1);}/*- DPCT1083:49: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/const size_t smem = (size_t)threads_per_row * sizeof(float);/*- DPCT1049:48: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -129,7 +129,7 @@ void s2_gemv_q8(const uint8_t* act, const uint8_t* codes, const float* scales, f});}/*- DPCT1010:367: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/s2_gemv_quads.dp.cpp b/sycl/src/kernels/cuda/s2_gemv_quads.dp.cppindex 3a267ad4c..1e4a5a5d0 100644--- a/sycl/src/kernels/cuda/s2_gemv_quads.dp.cpp+++ b/sycl/src/kernels/cuda/s2_gemv_quads.dp.cpp@@ -73,7 +73,7 @@ __dpct_inline__ void s2_gemv_quads_kernel(const uint16_t *__restrict__ x,for (int step = threads_per_row / 2; step > 0; step >>= 1) {if (tid < step) partial[tid] += partial[tid + step];/*- DPCT1118:268: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -92,13 +92,13 @@ void s2_gemv_quads(const uint16_t *x, const uint8_t *codes, const float *scales,std::exit(1);}/*- DPCT1083:270: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/const size_t smem = (size_t)threads_per_row * sizeof(float);/*- DPCT1049:269: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/diff --git a/sycl/src/kernels/cuda/s_gemv.dp.cpp b/sycl/src/kernels/cuda/s_gemv.dp.cppindex d61cd144b..64eb51317 100644--- a/sycl/src/kernels/cuda/s_gemv.dp.cpp+++ b/sycl/src/kernels/cuda/s_gemv.dp.cpp@@ -62,7 +62,7 @@ constexpr int Q8K_BLOCK_ELEMS = 256;__dpct_inline__ float q8k_at(const uint8_t *__restrict__ x, long long i) {const uint8_t* blk = x + (i / Q8K_BLOCK_ELEMS) * Q8K_BLOCK_BYTES;/*- DPCT1098:301: The '*' expression is used instead of the __ldg call. These+ DPCT1098: The '*' expression is used instead of the __ldg call. Thesetwo expressions do not provide the exact same functionality. Check thegenerated code for potential precision and/or performance issues.*/@@ -160,7 +160,7 @@ auto &s_iq4nl =/// decode, the quad loop, the shared codebook and the reduction are identical.template <int CODE_BITS, bool Q8K>/*-DPCT1110:21: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functions_gemv_q8_split_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -272,7 +272,7 @@ __dpct_inline__ void s_gemv_q8_split_kernel(const uint8_t* xb = x + (i / blk_elems) * (Q8K ? Q8K_BLOCK_BYTES : Q8_0_BLOCK_BYTES);const int xi = (int) (i % blk_elems);/*- DPCT1098:302: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -329,7 +329,7 @@ __dpct_inline__ void s_gemv_q8_split_kernel(float acc = (((acc0 + acc1) + (acc2 + acc3)) + ((acc4 + acc5) + (acc6 + acc7))) +(((acc8 + acc9) + (acc10 + acc11)) + ((acc12 + acc13) + (acc14 + acc15)));/*-DPCT1108:22: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -488,7 +488,7 @@ namespace {// non-power-of-two group rather than silently computing a wrong index.template <int CODE_BITS>/*-DPCT1110:23: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functions_gemv_split_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -594,7 +594,7 @@ __dpct_inline__ void s_gemv_split_kernel(for (int step = threads_per_row / 2; step > 0; step >>= 1) {if (tid < step) partial[tid] += partial[tid + step];/*- DPCT1118:24: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -631,7 +631,7 @@ static void s_gemv_split_impl(const uint16_t *x, const uint8_t *codes,int group_shift = 0;while ((1 << group_shift) < form.group_elems) ++group_shift;/*- DPCT1083:26: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -640,7 +640,7 @@ static void s_gemv_split_impl(const uint16_t *x, const uint8_t *codes,switch (form.code_bits) {case 2:/*- DPCT1049:25: The work-group size passed to the SYCL kernel may+ DPCT1049: The work-group size passed to the SYCL kernel mayexceed the limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size ifneeded.@@ -674,7 +674,7 @@ static void s_gemv_split_impl(const uint16_t *x, const uint8_t *codes,break;case 4:/*- DPCT1049:27: The work-group size passed to the SYCL kernel may+ DPCT1049: The work-group size passed to the SYCL kernel mayexceed the limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size ifneeded.@@ -708,7 +708,7 @@ static void s_gemv_split_impl(const uint16_t *x, const uint8_t *codes,break;case 8:/*- DPCT1049:28: The work-group size passed to the SYCL kernel may+ DPCT1049: The work-group size passed to the SYCL kernel mayexceed the limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size ifneeded.@@ -790,7 +790,7 @@ bool q8k_form_ok(const SForm& form, int64_t n_in, const char* who) {void finish(const char *who, void *stream) try {/*- DPCT1010:305: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/sampler.dp.cpp b/sycl/src/kernels/cuda/sampler.dp.cppindex 00f279ae4..df94e4afa 100644--- a/sycl/src/kernels/cuda/sampler.dp.cpp+++ b/sycl/src/kernels/cuda/sampler.dp.cpp@@ -126,7 +126,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,for (int w = item_ct1.get_local_id(2); w < bits_words;w += item_ct1.get_local_range(2)) penal_bits[w] = 0u;/*- DPCT1118:57: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -138,7 +138,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,sycl::access::address_space::generic_space>(&penal_bits[hrow[i] >> 5], 1u << (hrow[i] & 31));/*- DPCT1118:58: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -159,7 +159,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,}for (int off = 16; off > 0; off >>= 1) {/*- DPCT1108:59: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -167,7 +167,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,0xFFFFFFFFu, sycl::ext::oneapi::this_work_item::get_sub_group(), bv,off);/*- DPCT1108:60: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -191,7 +191,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,int wi = lane < nw ? si[lane] : n_vocab;for (int off = 16; off > 0; off >>= 1) {/*- DPCT1108:61: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -199,7 +199,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,0xFFFFFFFFu, sycl::ext::oneapi::this_work_item::get_sub_group(),wv, off);/*- DPCT1108:62: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -227,7 +227,7 @@ sampler_greedy_kernel(const float *__restrict__ logits, int n_vocab,/// order - is unchanged; `top_p`'s cut reads that order in double arithmetic as before; temperature and the/// Philox draw apply after the cut. `sampler_parity` pins all of it against the host reference./*-DPCT1110:63: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionsampler_kernel exceeds 128 bytes and may cause high register pressure. Consultwith your hardware vendor to find the total register size available and adjustthe code, or use smaller sub-group size to avoid high register pressure.@@ -268,7 +268,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,for (int w = item_ct1.get_local_id(2); w < bits_words;w += item_ct1.get_local_range(2)) penal_bits[w] = 0u;/*- DPCT1118:64: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -280,7 +280,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,sycl::access::address_space::generic_space>(&penal_bits[hrow[i] >> 5], 1u << (hrow[i] & 31));/*- DPCT1118:65: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -327,7 +327,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,}for (int off = 16; off > 0; off >>= 1) {/*- DPCT1108:68: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -335,7 +335,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,0xFFFFFFFFu, sycl::ext::oneapi::this_work_item::get_sub_group(),bv, off);/*- DPCT1108:69: '__shfl_down_sync' was migrated with the experimental+ DPCT1108: '__shfl_down_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -348,7 +348,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,lane = (int)(item_ct1.get_local_id(2) & 31);if (lane == 0) { sv[warp] = bv; si[warp] = best; }/*- DPCT1118:66: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -359,7 +359,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,int wi = lane < nw ? si[lane] : n_vocab;for (int off = 16; off > 0; off >>= 1) {/*- DPCT1108:70: '__shfl_down_sync' was migrated with the+ DPCT1108: '__shfl_down_sync' was migrated with theexperimental feature masked sub_group function which may not besupported by all compilers or runtimes. You may need to adjustthe code.@@ -369,7 +369,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,sycl::ext::oneapi::this_work_item::get_sub_group(), wv,off);/*- DPCT1108:71: '__shfl_down_sync' was migrated with the+ DPCT1108: '__shfl_down_sync' was migrated with theexperimental feature masked sub_group function which may not besupported by all compilers or runtimes. You may need to adjustthe code.@@ -383,7 +383,7 @@ __dpct_inline__ void sampler_kernel(const float *__restrict__ logits,if (lane == 0) { sel_ids[i] = (wi < n_vocab) ? wi : 0; sel_logit[i] = wv; }}/*- DPCT1118:67: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -454,7 +454,7 @@ void sample_tokens(const float* logits, int n_tokens, int n_vocab, const int* histd::exit(1);}/*- DPCT1083:73: The size of local memory in the migrated code may be different+ DPCT1083: The size of local memory in the migrated code may be differentfrom the original code. Check that the allocated memory size in the migratedcode is correct.*/@@ -467,7 +467,7 @@ void sample_tokens(const float* logits, int n_tokens, int n_vocab, const int* hi// One block per token, 1,024 threads over the vocabulary. See `sampler_greedy_kernel`.const int gthreads = 1024;/*- DPCT1049:72: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -503,7 +503,7 @@ void sample_tokens(const float* logits, int n_tokens, int n_vocab, const int* hi// The same block-per-token shape: the selection's k argmax rounds reduce inside the block. See// `sampler_kernel`'s header for what the old one-thread-per-token launch cost./*- DPCT1049:74: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -535,7 +535,7 @@ void sample_tokens(const float* logits, int n_tokens, int n_vocab, const int* hi});}/*- DPCT1010:403: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/kernels/cuda/shared_expert.dp.cpp b/sycl/src/kernels/cuda/shared_expert.dp.cppindex 95a95e581..654105163 100644--- a/sycl/src/kernels/cuda/shared_expert.dp.cpp+++ b/sycl/src/kernels/cuda/shared_expert.dp.cpp@@ -113,12 +113,12 @@ void to_f16_kernel(const float* __restrict__ in, uint16_t* __restrict__ out, int// 0.5 and reads 1.0 scales the shared expert by 2x and produces perfectly finite, perfectly plausible logits.__dpct_inline__ double warp_sum_d(double v) {/*-DPCT1108:242: '__shfl_down_sync' was migrated with the experimental feature+DPCT1108: '__shfl_down_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*-DPCT1121:243: Make sure that the "v" which is used in the SYCL group+DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/#pragma unroll@@ -127,12 +127,12 @@ function/algorithm is initialized.0xFFFFFFFFu, sycl::ext::oneapi::this_work_item::get_sub_group(), v,off);/*- DPCT1108:244: '__shfl_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*//*- DPCT1121:245: Make sure that the "v" which is used in the SYCL group+ DPCT1121: Make sure that the "v" which is used in the SYCL groupfunction/algorithm is initialized.*/return dpct::experimental::select_from_sub_group(@@ -184,7 +184,7 @@ __dpct_inline__ void native_scalar_sigmoid_kernel(float *gate) {__dpct_inline__ void native_scalar_sigmoid_multi_kernel(float *gate) { // thread t = token t, same expression/*- DPCT1064:936: Migrated __expf call is used in a macro/template definition+ DPCT1064: Migrated __expf call is used in a macro/template definitionand may not be valid for all macro/template uses. Adjust the code.*/auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();@@ -257,7 +257,7 @@ void shared_expert_multi(int n_tok, const float* x, const uint16_t* x_bf16, consif (native_bf16 && batch && n_tok > 1) { // one gemv for all rows (outputs identical), one sigmoid launchbf16_gemv_fp32_mmvf_multi(x, n_embd, gate_inp_bf16, g, 1, n_embd, 1, n_tok, stream);/*- DPCT1049:246: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -334,21 +334,21 @@ void shared_expert_multi(int n_tok, const float* x, const uint16_t* x_bf16, cons});}/*- DPCT1010:939: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:940: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*//*- DPCT1001:937: The statement could not be removed.+ DPCT1001: The statement could not be removed.*//*- DPCT1000:938: Error handling if-stmt was detected but could not be+ DPCT1000: Error handling if-stmt was detected but could not berewritten.*/if (e != 0) throw std::runtime_error(std::string("shared_expert_multi: ") +diff --git a/sycl/src/kernels/cuda/verify_kernels.dp.cpp b/sycl/src/kernels/cuda/verify_kernels.dp.cppindex bdc700906..402b0e2af 100644--- a/sycl/src/kernels/cuda/verify_kernels.dp.cpp+++ b/sycl/src/kernels/cuda/verify_kernels.dp.cpp@@ -22,13 +22,13 @@ constexpr int RPG = S / RG;void check(const char* what) {/*- DPCT1010:871: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:872: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -59,7 +59,7 @@ auto &part =if ((int)item_ct1.get_group(2) < qk_heads) {float sq = y * y;/*-DPCT1108:184: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -71,7 +71,7 @@ runtimes. You may need to adjust the code.if ((item_ct1.get_local_id(2) & 31) == 0)part[item_ct1.get_local_id(2) >> 5] = sq;/*- DPCT1118:183: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*/item_ct1.barrier(sycl::access::fence_space::local_space);@@ -102,7 +102,7 @@ gdn_conv_commit_kernel(float *__restrict__ hist, const float *__restrict__ qkv,}/*-DPCT1110:185: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongdn_ab_multi_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -125,7 +125,7 @@ __dpct_inline__ void gdn_ab_multi_kernel(for (int t = 0; t < kVerifyMaxT; ++t) acc[t] = 0.0f;for (int j = lane; j < n / 8; j += 32) {/*- DPCT1098:873: The '*' expression is used instead of the __ldg call.+ DPCT1098: The '*' expression is used instead of the __ldg call.These two expressions do not provide the exact same functionality. Checkthe generated code for potential precision and/or performance issues.*/@@ -163,7 +163,7 @@ __dpct_inline__ void gdn_ab_multi_kernel(if (t >= T) break;float a = acc[t];/*-DPCT1108:186: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -184,7 +184,7 @@ runtimes. You may need to adjust the code.}/*-DPCT1110:187: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongdn_step_norm_multi_kernel exceeds 128 bytes and may cause high registerpressure. Consult with your hardware vendor to find the total register sizeavailable and adjust the code, or use smaller sub-group size to avoid high@@ -223,22 +223,22 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(for (int t = 0; t < n; ++t) {const float* ht = hbuf + (size_t) t * C;/*- DPCT1118:188: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:874: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier(); // the previous token is done with sk/sq/red/wsumif (tid < S) { sk[tid] = ht[qk + qh * S + tid]; sq[tid] = ht[qh * S + tid]; }/*- DPCT1118:189: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:875: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -250,11 +250,11 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(kv = sycl::fma(s[r], sk[rg * RPG + r], kv);red[rg][col] = kv;/*- DPCT1118:190: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:876: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -268,22 +268,22 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(o = sycl::fma(s[r], sq[rg * RPG + r], o);}/*- DPCT1118:191: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:877: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier();red[rg][col] = o;/*- DPCT1118:192: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:878: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -296,7 +296,7 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(}if (t < t_out_begin) continue; // a replayed token: its state update is needed, its output is not/*-DPCT1108:194: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -307,11 +307,11 @@ runtimes. You may need to adjust the code.sq_part, o2);if ((tid & 31) == 0) wsum[tid >> 5] = sq_part;/*- DPCT1118:193: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:879: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -352,14 +352,14 @@ __dpct_inline__ void embedding_gather_dev_kernel(const int code = (c[i / per_byte] >> ((i % per_byte) * code_bits)) & mask;const int64_t group = i / group_elems;/*- DPCT1013:880: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.*/const float product = (float)(code + code_bias) * sc[group];/*- DPCT1013:881: The rounding mode could not be specified and the generated+ DPCT1013: The rounding mode could not be specified and the generatedcode may have different accuracy than the original code. Verify thecorrectness. SYCL math built-in function rounding mode is aligned withOpenCL C 1.2 standard.@@ -484,7 +484,7 @@ auto &part = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(for (int i = item_ct1.get_local_id(2); i < n_vocab;i += item_ct1.get_local_range(2)) s += sycl::native::exp(l[i] - m);/*-DPCT1108:195: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -607,7 +607,7 @@ void add_streams_broadcast(const float* h, const float* e, float* R, int64_t n_evoid ident_hits(const int32_t* ids, int n, int32_t* slot, int32_t* dst, int32_t* count, void* stream) {if (n < 1 || n > 1024) { std::fprintf(stderr, "ident_hits: n out of range\n"); std::exit(1); }/*- DPCT1049:196: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -716,7 +716,7 @@ void map_ids(int32_t* ids, const int32_t* table, int n, void* stream) {void row_top_prob(const float* logits, int n_rows, int n_vocab, const int32_t* ids, float* probs, void* stream) {/*- DPCT1049:197: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -754,7 +754,7 @@ __dpct_inline__ void window_ids_kernel(int32_t *steps, int window, int32_t *ids,j += item_ct1.get_group_range(2) * item_ct1.get_local_range(2))ids[q * stride + j] = start + j;/*- DPCT1065:882: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -879,7 +879,7 @@ void gdn_step_norm_multi(float* state, const float* h, int conv_channels, conststd::exit(1);}/*- DPCT1049:198: The work-group size passed to the SYCL kernel may exceed the+ DPCT1049: The work-group size passed to the SYCL kernel may exceed thelimit. To get the device limit, query info::device::max_work_group_size.Adjust the work-group size if needed.*/@@ -908,13 +908,13 @@ namespace {__dpct_inline__ void wait_flag_ge_kernel(const volatile uint32_t *flag,uint32_t value) {/*- DPCT1008:883: __nanosleep function is not defined in SYCL. This is a+ DPCT1008: __nanosleep function is not defined in SYCL. This is ahardware-specific feature. Consult with your hardware vendor to find areplacement.*/for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) < value; ++spin) {}/*- DPCT1078:199: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictionsare needed.*/@@ -967,7 +967,7 @@ __dpct_inline__ void resident_plan_kernel(counts[1] = entries;counts[2] = 0;/*- DPCT1078:200: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictionsare needed.*/@@ -979,13 +979,13 @@ __dpct_inline__ void wait_flag_ge_or_kernel(const volatile uint32_t *flag,const volatile uint32_t *skip) {if (strata::sys_load(skip) == value) return;/*- DPCT1008:884: __nanosleep function is not defined in SYCL. This is a+ DPCT1008: __nanosleep function is not defined in SYCL. This is ahardware-specific feature. Consult with your hardware vendor to find areplacement.*/for (uint32_t spin = 0; spin < strata::kSpinMax && strata::sys_load(flag) < value; ++spin) {}/*- DPCT1078:201: Consider replacing memory_order::acq_rel with+ DPCT1078: Consider replacing memory_order::acq_rel withmemory_order::seq_cst for correctness if strong memory order restrictionsare needed.*/@@ -1002,7 +1002,7 @@ __dpct_inline__ void copy_i32_unless_kernel(int32_t *__restrict__ dst,i += item_ct1.get_local_range(2)) dst[i] = src[i];}/*-DPCT1052:885: SYCL does not support the member access for a volatile qualified+DPCT1052: SYCL does not support the member access for a volatile qualifiedvector type. The volatile qualifier was removed. You may need to rewrite thecode.*/@@ -1177,10 +1177,14 @@ void copy_indexed(float* dst, const float* src, int64_t stride, const int32_t* inamespace {__dpct_inline__ void gpu_stamp_kernel(unsigned long long *buf, int i) {unsigned long long t;+#if defined(__HIPCC__)+ t = wall_clock64() * 10ull; // gfx11: a constant 100 MHz counter, in ns+#else/*- DPCT1053:202: Migration of device assembly code is not supported.+ DPCT1053: Migration of device assembly code is not supported.*/t = 0; // SYCL: no %globaltimer equivalent; the stage profiler is inert on this backend+#endifbuf[i] = t;} }void gpu_stamp(unsigned long long* buf, int i, void* stream) {@@ -1188,7 +1192,7 @@ void gpu_stamp(unsigned long long* buf, int i, void* stream) {sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gpu_stamp_kernel_596fa5>>(+ ->parallel_for<dpct_kernel_name<class gpu_stamp_kernel_76ad79>>(sycl::nd_range<3>(sycl::range(1, 1, 1), sycl::range(1, 1, 1)),exp_props, [=](sycl::nd_item<3> item_ct1) {gpu_stamp_kernel(buf, i);diff --git a/sycl/src/kernels/cvec_parity.cpp b/sycl/src/kernels/cvec_parity.cppindex 239a1a353..c94491380 100644--- a/sycl/src/kernels/cvec_parity.cpp+++ b/sycl/src/kernels/cvec_parity.cpp@@ -38,7 +38,7 @@ T* dalloc(size_t n) {template <typename T>/*-DPCT1114:920: cudaMemcpy is migrated to asynchronization memcpy, assuming in the+DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in theoriginal code the source host memory is pageable memory. If the memory is notpageable, call wait() on event return by memcpy API to ensure synchronizationbehavior.diff --git a/sycl/src/kernels/dequant_s2_parity.cpp b/sycl/src/kernels/dequant_s2_parity.cppindex a1f6680ea..0d43eaa07 100644--- a/sycl/src/kernels/dequant_s2_parity.cpp+++ b/sycl/src/kernels/dequant_s2_parity.cpp@@ -87,7 +87,7 @@ int main(int argc, char** argv) {cpu.size(), dpct::get_in_order_queue())),"cudaMalloc out");/*- DPCT1114:370: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -96,7 +96,7 @@ int main(int argc, char** argv) {d_codes, codes.data(), codes.size()).wait()),"copy codes");/*- DPCT1114:371: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/elementwise_parity.cpp b/sycl/src/kernels/elementwise_parity.cppindex dc086e62d..594b45980 100644--- a/sycl/src/kernels/elementwise_parity.cpp+++ b/sycl/src/kernels/elementwise_parity.cpp@@ -108,7 +108,7 @@ int main(int argc, char** argv) {n * 4, dpct::get_in_order_queue())),"g");/*- DPCT1114:712: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -117,7 +117,7 @@ int main(int argc, char** argv) {dpct::get_in_order_queue().memcpy(d_a, alpha.data(), n * 4).wait()),"ca");/*- DPCT1114:713: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -126,7 +126,7 @@ int main(int argc, char** argv) {dpct::get_in_order_queue().memcpy(d_dt, dt.data(), n * 4).wait()),"cd");/*- DPCT1114:714: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -205,7 +205,7 @@ int main(int argc, char** argv) {n * 4, dpct::get_in_order_queue())),"sx");/*- DPCT1114:715: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -242,7 +242,7 @@ int main(int argc, char** argv) {n * 2, dpct::get_in_order_queue())),"eh");/*- DPCT1114:716: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -338,7 +338,7 @@ int main(int argc, char** argv) {w.size() * 4, dpct::get_in_order_queue())),"m rmsw");/*- DPCT1114:717: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -347,7 +347,7 @@ int main(int argc, char** argv) {x.size() * 4).wait()),"c rmsx");/*- DPCT1114:718: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -386,7 +386,7 @@ int main(int argc, char** argv) {// sides were never looking at the same input.const std::vector<float> want_null = ref(false, false);/*- DPCT1114:719: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -414,7 +414,7 @@ int main(int argc, char** argv) {{dpct::queue_ptr stream;/*- DPCT1025:720: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/check(DPCT_CHECK_ERROR(@@ -463,7 +463,7 @@ int main(int argc, char** argv) {((size_t)n + 2), dpct::get_in_order_queue())),"embedding output");/*- DPCT1124:721: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -473,7 +473,7 @@ int main(int argc, char** argv) {stream->memcpy(dc, codes.data(), codes.size())),"embedding codes upload");/*- DPCT1124:722: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -484,7 +484,7 @@ int main(int argc, char** argv) {ds, scales.data(), scales.size() * sizeof(float))),"embedding scales upload");/*- DPCT1124:723: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -510,7 +510,7 @@ int main(int argc, char** argv) {if (std::memcmp(&fused, &want[(size_t) i], sizeof(float)) != 0) ++fma_diff;}/*- DPCT1124:724: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API mightbe synchronous, it depends on the type of operandmemory, so you may need to call wait() on event@@ -526,7 +526,7 @@ int main(int argc, char** argv) {with_offset ? dof + (size_t) row * row_groups : nullptr,n, bits, bias, group, out + 1, stream);/*- DPCT1124:725: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API mightbe synchronous, it depends on the type of operandmemory, so you may need to call wait() on event@@ -576,7 +576,7 @@ int main(int argc, char** argv) {stream->ext_oneapi_graph(*exec)),"embedding replay");/*- DPCT1124:726: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin APImight be synchronous, it depends on the type ofoperand memory, so you may need to call wait()diff --git a/sycl/src/kernels/gdn_parity.cpp b/sycl/src/kernels/gdn_parity.cppindex 5df2e2816..c749c07f1 100644--- a/sycl/src/kernels/gdn_parity.cpp+++ b/sycl/src/kernels/gdn_parity.cpp@@ -183,7 +183,7 @@ int main(int argc, char** argv) {(size_t)h_v * S * 4, dpct::get_in_order_queue())),"o");/*- DPCT1114:486: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -192,7 +192,7 @@ int main(int argc, char** argv) {d_st, st_dev.data(), st_dev.size() * 4).wait()),"cst");/*- DPCT1114:487: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -201,7 +201,7 @@ int main(int argc, char** argv) {q.size() * 4).wait()),"cq");/*- DPCT1114:488: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -210,7 +210,7 @@ int main(int argc, char** argv) {k.size() * 4).wait()),"ck");/*- DPCT1114:489: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -219,7 +219,7 @@ int main(int argc, char** argv) {v.size() * 4).wait()),"cv");/*- DPCT1114:490: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -228,7 +228,7 @@ int main(int argc, char** argv) {d_g, gate.data(), gate.size() * 4).wait()),"cg");/*- DPCT1114:491: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -275,7 +275,7 @@ int main(int argc, char** argv) {{std::vector<float> zero(st_dev.size(), 0.0f), zg((size_t) h_v, 0.0f), zb((size_t) h_v, 0.0f);/*- DPCT1114:492: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -284,7 +284,7 @@ int main(int argc, char** argv) {d_st, zero.data(), zero.size() * 4).wait()),"z0");/*- DPCT1114:493: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -293,7 +293,7 @@ int main(int argc, char** argv) {d_g, zg.data(), zg.size() * 4).wait()),"z1");/*- DPCT1114:494: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -396,7 +396,7 @@ int main(int argc, char** argv) {(size_t)C * 4, dpct::get_in_order_queue())),"co");/*- DPCT1114:495: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -405,7 +405,7 @@ int main(int argc, char** argv) {d_cs, cs.data(), cs.size() * 4).wait()),"ccs");/*- DPCT1114:496: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -414,7 +414,7 @@ int main(int argc, char** argv) {x.size() * 4).wait()),"ccx");/*- DPCT1114:497: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -478,7 +478,7 @@ int main(int argc, char** argv) {x.size() * 4, dpct::get_in_order_queue())),"lx");/*- DPCT1114:498: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -529,7 +529,7 @@ int main(int argc, char** argv) {y_ref.size() * 4, dpct::get_in_order_queue())),"ny");/*- DPCT1114:499: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -538,7 +538,7 @@ int main(int argc, char** argv) {o.size() * 4).wait()),"nco");/*- DPCT1114:500: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -547,7 +547,7 @@ int main(int argc, char** argv) {z.size() * 4).wait()),"ncz");/*- DPCT1114:501: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/gr_parity.cpp b/sycl/src/kernels/gr_parity.cppindex 86f6900c7..3df9764c7 100644--- a/sycl/src/kernels/gr_parity.cpp+++ b/sycl/src/kernels/gr_parity.cpp@@ -23,6 +23,7 @@#include <sycl/sycl.hpp>#include <dpct/dpct.hpp>#include "strata/kernels/gr.hpp"+#include "strata/kernels/fused_gr.hpp"#include <cmath>#include <cstdio>@@ -196,7 +197,7 @@ int scalar_activation_contract() {bf16_bits(2.0f), 0 // injection: 2*xn[0]};/*- DPCT1114:966: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -205,7 +206,7 @@ int scalar_activation_contract() {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -215,7 +216,7 @@ int scalar_activation_contract() {"scalar upload weights");dpct::queue_ptr stream;/*- DPCT1025:968: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/check(DPCT_CHECK_ERROR(stream =@@ -225,7 +226,7 @@ int scalar_activation_contract() {for (float gamma : {1.0f, 1.00390625f}) {const float gammas[] = {gamma, gamma};/*- DPCT1114:969: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -348,6 +349,260 @@ int scalar_activation_contract() {return bad;}+int fused_multi_lds_parity(const float* d_norm, const uint16_t* d_down, const uint16_t* d_up,+ const uint16_t* d_inject, float eps) {+ using namespace strata::kernels;+ constexpr int N = 2560, HC = 4, LR = 320, D = N * HC, T = kFusedGrMaxT;+ std::mt19937 rng(0x6f8a);+ std::normal_distribution<float> normal(0.0f, 0.3f);+ std::vector<float> r((size_t) T * D), bo((size_t) T * N), inj((size_t) T * HC);+ for (auto& x : r) x = normal(rng);+ for (auto& x : bo) x = normal(rng);+ for (auto& x : inj) x = normal(rng);++ float *d_r = nullptr, *d_r_out = nullptr, *d_bo = nullptr, *d_inj = nullptr;+ float *d_lo = nullptr, *d_rs = nullptr, *d_inj_out = nullptr, *d_mixed = nullptr, *d_xn = nullptr;+ check(DPCT_CHECK_ERROR(d_r = sycl::malloc_device<float>(+ r.size(), dpct::get_in_order_queue())),+ "multi R");+ check(DPCT_CHECK_ERROR(d_r_out = sycl::malloc_device<float>(+ r.size(), dpct::get_in_order_queue())),+ "multi R_out");+ check(DPCT_CHECK_ERROR(d_bo = sycl::malloc_device<float>(+ bo.size(), dpct::get_in_order_queue())),+ "multi bo");+ check(DPCT_CHECK_ERROR(d_inj = sycl::malloc_device<float>(+ inj.size(), dpct::get_in_order_queue())),+ "multi inj");+ check(DPCT_CHECK_ERROR(d_lo = sycl::malloc_device<float>(+ (size_t)T * LR, dpct::get_in_order_queue())),+ "multi lo");+ check(DPCT_CHECK_ERROR(d_rs = sycl::malloc_device<float>(+ (size_t)T * HC, dpct::get_in_order_queue())),+ "multi rs");+ check(DPCT_CHECK_ERROR(d_inj_out = sycl::malloc_device<float>(+ (size_t)T * HC, dpct::get_in_order_queue())),+ "multi injection");+ check(DPCT_CHECK_ERROR(d_mixed = sycl::malloc_device<float>(+ (size_t)T * N, dpct::get_in_order_queue())),+ "multi mixed");+ check(DPCT_CHECK_ERROR(d_xn = sycl::malloc_device<float>(+ (size_t)T * D, dpct::get_in_order_queue())),+ "multi xn");+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ the original code the source host memory is pageable memory. If the memory+ is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(+ d_r, r.data(), r.size() * sizeof(float)).wait()),+ "multi copy R");+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ the original code the source host memory is pageable memory. If the memory+ is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(+ d_bo, bo.data(), bo.size() * sizeof(float)).wait()),+ "multi copy bo");+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ the original code the source host memory is pageable memory. If the memory+ is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ check(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(+ d_inj, inj.data(), inj.size() * sizeof(float)).wait()),+ "multi copy inj");++ std::vector<FusedGrArgs> args(T);+ for (int t = 0; t < T; ++t) {+ auto& a = args[t];+ a.R = d_r + (size_t) t * D;+ a.R_out = d_r_out + (size_t) t * D;+ a.apply = true;+ a.bo_prev = d_bo + (size_t) t * N;+ a.inj_prev = d_inj + (size_t) t * HC;+ a.w_norm = d_norm;+ a.w_down = d_down;+ a.w_up = d_up;+ a.w_inject = d_inject;+ a.eps = eps;+ a.lo = d_lo + (size_t) t * LR;+ a.rs = d_rs + (size_t) t * HC;+ a.inject_out = d_inj_out + (size_t) t * HC;+ a.mixed = d_mixed + (size_t) t * N;+ }++ struct Snapshot {+ std::vector<float> r_out, lo, rs, inject, mixed;+ };+ auto snapshot = [&]() {+ try {+ Snapshot s;+ s.r_out.resize((size_t) T * D);+ s.lo.resize((size_t) T * LR);+ s.rs.resize((size_t) T * HC);+ s.inject.resize((size_t) T * HC);+ s.mixed.resize((size_t) T * N);+ check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(s.r_out.data(), d_r_out,+ s.r_out.size() * sizeof(float))+ .wait()),+ "multi read R_out");+ check(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue()+ .memcpy(s.lo.data(), d_lo, s.lo.size() * sizeof(float))+ .wait()),+ "multi read lo");+ check(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue()+ .memcpy(s.rs.data(), d_rs, s.rs.size() * sizeof(float))+ .wait()),+ "multi read rs");+ check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(s.inject.data(), d_inj_out,+ s.inject.size() * sizeof(float))+ .wait()),+ "multi read inject");+ check(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(s.mixed.data(), d_mixed,+ s.mixed.size() * sizeof(float))+ .wait()),+ "multi read mixed");+ return s;+ }+ catch (sycl::exception const &exc) {+ std::cerr << exc.what() << "Exception caught at file:" << __FILE__+ << ", line:" << __LINE__ << std::endl;+ std::exit(1);+ }+ };+ auto same = [](const Snapshot& a, const Snapshot& b) {+ return std::memcmp(a.r_out.data(), b.r_out.data(), a.r_out.size() * sizeof(float)) == 0 &&+ std::memcmp(a.lo.data(), b.lo.data(), a.lo.size() * sizeof(float)) == 0 &&+ std::memcmp(a.rs.data(), b.rs.data(), a.rs.size() * sizeof(float)) == 0 &&+ std::memcmp(a.inject.data(), b.inject.data(), a.inject.size() * sizeof(float)) == 0 &&+ std::memcmp(a.mixed.data(), b.mixed.data(), a.mixed.size() * sizeof(float)) == 0;+ };++ dpct::queue_ptr stream = &dpct::get_in_order_queue();+ /*+ DPCT1025: The SYCL queue is created ignoring the flag and priority+ options.+ */+ check(DPCT_CHECK_ERROR(stream =+ dpct::get_current_device().create_queue(true)),+ "multi stream");+ // Max T forces the HIP kernel's full dynamic-LDS request: 8 * 1280 * sizeof(float) = 40 KiB.+ fused_gr_read_multi(args.data(), T, d_xn, stream);+ check(DPCT_CHECK_ERROR(stream->wait()), "multi max-T sync");+ const Snapshot multi = snapshot();+ for (int t = 0; t < T; ++t) fused_gr_read(args[t], stream);+ check(DPCT_CHECK_ERROR(stream->wait()), "single reference sync");+ const Snapshot single = snapshot();+ int bad = 0;+ if (!same(multi, single)) {+ std::printf(" fused GR multi max-T differs from single-token calls\n");+ ++bad;+ }++ dpct::experimental::command_graph_ptr graph = nullptr;+ dpct::experimental::command_graph_exec_ptr graph_exec = nullptr;+ check(DPCT_CHECK_ERROR(dpct::experimental::begin_recording(stream)),+ "multi graph begin");+ fused_gr_read_multi(args.data(), T, d_xn, stream);+ check(DPCT_CHECK_ERROR(dpct::experimental::end_recording(stream, &graph)),+ "multi graph end");+ check(DPCT_CHECK_ERROR(+ graph_exec = new sycl::ext::oneapi::experimental::command_graph<+ sycl::ext::oneapi::experimental::graph_state::executable>(+ graph->finalize())),+ "multi graph instantiate");+ check(DPCT_CHECK_ERROR(stream->ext_oneapi_graph(*graph_exec)),+ "multi graph initial replay");+ check(DPCT_CHECK_ERROR(stream->wait()), "multi graph initial sync");+ const Snapshot captured = snapshot();+ if (!same(multi, captured)) {+ std::printf(" fused GR multi captured graph differs from direct max-T call\n");+ ++bad;+ }++ // Reuse the same captured pointers with new payloads; then independently run the single-token path again.+ for (size_t i = 0; i < r.size(); ++i) r[i] = -0.7f * r[i] + 0.001f * (float) (i % 17);+ for (size_t i = 0; i < bo.size(); ++i) bo[i] = -0.4f * bo[i] + 0.02f;+ for (size_t i = 0; i < inj.size(); ++i) inj[i] += 0.3f;+ /*+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ the origin API might be synchronous, it depends on the type of operand+ memory, so you may need to call wait() on event return by memcpy API to+ ensure synchronization behavior.+ */+ check(DPCT_CHECK_ERROR(+ stream->memcpy(d_r, r.data(), r.size() * sizeof(float))),+ "multi replay R");+ /*+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ the origin API might be synchronous, it depends on the type of operand+ memory, so you may need to call wait() on event return by memcpy API to+ ensure synchronization behavior.+ */+ check(DPCT_CHECK_ERROR(+ stream->memcpy(d_bo, bo.data(), bo.size() * sizeof(float))),+ "multi replay bo");+ /*+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ the origin API might be synchronous, it depends on the type of operand+ memory, so you may need to call wait() on event return by memcpy API to+ ensure synchronization behavior.+ */+ check(DPCT_CHECK_ERROR(+ stream->memcpy(d_inj, inj.data(), inj.size() * sizeof(float))),+ "multi replay inj");+ check(DPCT_CHECK_ERROR(stream->ext_oneapi_graph(*graph_exec)),+ "multi graph changed replay");+ check(DPCT_CHECK_ERROR(stream->wait()), "multi graph changed sync");+ const Snapshot replay = snapshot();+ if (std::memcmp(multi.mixed.data(), replay.mixed.data(), multi.mixed.size() * sizeof(float)) == 0) {+ std::printf(" fused GR graph replay ignored changed inputs\n");+ ++bad;+ }+ for (int t = 0; t < T; ++t) fused_gr_read(args[t], stream);+ check(DPCT_CHECK_ERROR(stream->wait()), "changed single reference sync");+ if (!same(replay, snapshot())) {+ std::printf(" fused GR changed graph replay differs from single-token calls\n");+ ++bad;+ }++ std::printf(" fused GR multi max-T=8 LDS launch and changing graph replay %s\n",+ bad == 0 ? "pass" : "FAIL");+ check(DPCT_CHECK_ERROR(delete (graph_exec)), "multi graph exec destroy");+ check(DPCT_CHECK_ERROR(delete (graph)), "multi graph destroy");+ check(DPCT_CHECK_ERROR(dpct::get_current_device().destroy_queue(stream)),+ "multi stream destroy");+ check(DPCT_CHECK_ERROR(sycl::free(d_xn, dpct::get_in_order_queue())),+ "free multi xn");+ check(DPCT_CHECK_ERROR(sycl::free(d_mixed, dpct::get_in_order_queue())),+ "free multi mixed");+ check(DPCT_CHECK_ERROR(sycl::free(d_inj_out, dpct::get_in_order_queue())),+ "free multi injection");+ check(DPCT_CHECK_ERROR(sycl::free(d_rs, dpct::get_in_order_queue())),+ "free multi rs");+ check(DPCT_CHECK_ERROR(sycl::free(d_lo, dpct::get_in_order_queue())),+ "free multi lo");+ check(DPCT_CHECK_ERROR(sycl::free(d_inj, dpct::get_in_order_queue())),+ "free multi inj");+ check(DPCT_CHECK_ERROR(sycl::free(d_bo, dpct::get_in_order_queue())),+ "free multi bo");+ check(DPCT_CHECK_ERROR(sycl::free(d_r_out, dpct::get_in_order_queue())),+ "free multi R_out");+ check(DPCT_CHECK_ERROR(sycl::free(d_r, dpct::get_in_order_queue())),+ "free multi R");+ return bad;+}+} // namespaceint main(int argc, char** argv) {@@ -422,7 +677,7 @@ int main(int argc, char** argv) {(size_t)hc, dpct::get_in_order_queue())),"m inject");/*- DPCT1114:970: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -431,7 +686,7 @@ int main(int argc, char** argv) {d_R, R.data(), R.size() * sizeof(float)).wait()),"c R");/*- DPCT1114:971: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -440,7 +695,7 @@ int main(int argc, char** argv) {d_norm, w_norm.data(), w_norm.size() * sizeof(float)).wait()),"c norm");/*- DPCT1114:972: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -449,7 +704,7 @@ int main(int argc, char** argv) {d_down, q_down.data(), q_down.size() * sizeof(uint16_t)).wait()),"c down");/*- DPCT1114:973: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -458,7 +713,7 @@ int main(int argc, char** argv) {d_up, q_up.data(), q_up.size() * sizeof(uint16_t)).wait()),"c up");/*- DPCT1114:974: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -605,7 +860,7 @@ int main(int argc, char** argv) {for (long long k = 0; k < hc_lr; ++k)tr_up[(size_t) (k * hc_dim + i)] = q_up[(size_t) (i * hc_lr + k)];/*- DPCT1114:975: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -614,7 +869,7 @@ int main(int argc, char** argv) {d_down_bad, tr_down.data(), tr_down.size() * 2).wait()),"cb d");/*- DPCT1114:976: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -679,7 +934,7 @@ int main(int argc, char** argv) {R.size(), dpct::get_in_order_queue())),"m outw");/*- DPCT1114:977: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -688,7 +943,7 @@ int main(int argc, char** argv) {d_Rw, R.data(), R.size() * sizeof(float)).wait()),"c Rw");/*- DPCT1114:978: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -697,7 +952,7 @@ int main(int argc, char** argv) {d_bo, block_out.data(), block_out.size() * sizeof(float)).wait()),"c bo");/*- DPCT1114:979: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -754,7 +1009,7 @@ int main(int argc, char** argv) {std::vector<float> inj((size_t) hc);for (auto& x : inj) x = gauss(rng) * 3.0f;/*- DPCT1114:980: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -835,7 +1090,7 @@ int main(int argc, char** argv) {(size_t)rhc * 4, dpct::get_in_order_queue())),"rI");/*- DPCT1114:981: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -844,7 +1099,7 @@ int main(int argc, char** argv) {dR, rR.data(), rR.size() * 4).wait()),"crR");/*- DPCT1114:982: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -853,7 +1108,7 @@ int main(int argc, char** argv) {dN, rnorm.data(), rnorm.size() * 4).wait()),"crN");/*- DPCT1114:983: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -862,7 +1117,7 @@ int main(int argc, char** argv) {dD, qd.data(), qd.size() * 2).wait()),"crD");/*- DPCT1114:984: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -871,7 +1126,7 @@ int main(int argc, char** argv) {dU, qu.data(), qu.size() * 2).wait()),"crU");/*- DPCT1114:985: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -911,6 +1166,7 @@ int main(int argc, char** argv) {activation_mode_name(mode), ok ? "pass" : "*** FAIL ***", rm, ri);if (!ok) ++bad;}+ bad += fused_multi_lds_parity(dN, dD, dU, dJ, eps);select_activation_mode(0);sycl::free(rws_raw, dpct::get_in_order_queue());sycl::free(dR, dpct::get_in_order_queue());diff --git a/sycl/src/kernels/iq_parity.cpp b/sycl/src/kernels/iq_parity.cppindex 3311bacb8..9adfcb577 100644--- a/sycl/src/kernels/iq_parity.cpp+++ b/sycl/src/kernels/iq_parity.cpp@@ -42,7 +42,7 @@ int main(int argc, char** argv) {dq = (float *)sycl::malloc_device(ref.size() * 4,dpct::get_in_order_queue());/*- DPCT1114:365: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -74,7 +74,7 @@ int main(int argc, char** argv) {dy = (float *)sycl::malloc_device((size_t)2 * rows * 4,dpct::get_in_order_queue());/*- DPCT1114:366: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/kv_hybrid_parity.cpp b/sycl/src/kernels/kv_hybrid_parity.cppnew file mode 100644index 000000000..73ea80caa--- /dev/null+++ b/sycl/src/kernels/kv_hybrid_parity.cpp@@ -0,0 +1,478 @@+// src/kernels/kv_hybrid_parity.cpp - hybrid K8V4 KV against host references (GPU, no model).+//+// Exercises the EXACT composed calls the engine's hybrid path makes (layer.cpp / prefill.cpp): the q8/q4+// append and gather kernels invoked with the unused half's pointers folded onto the used pool, and the+// fused decode attention's KV_MODE 3 (INT8 K, rotated Q4_0 V) followed by the output's inverse Hadamard.+// 1. K: INT8 codes + FP16 scales bitwise vs the host reference (kv_q8.hpp's rules);+// 2. V: after fwht256, Q4_0 blocks bitwise vs the host reference (kv_q4.hpp's rules, PR #21);+// 3. the composed gathers bitwise vs the host dequantization of those codes;+// 4. qsa_decode_attn<3> + output fwht vs a host attention over the SAME dequantized K/V (fp32 math), and+// bounded against the fp32-true attention from the unquantized K/V.+#define DPCT_PROFILING_ENABLED+#include <sycl/sycl.hpp>+#include <dpct/dpct.hpp>+#include "strata/kernels/f16_bits.hpp"+#include "strata/kernels/kv_q4.hpp"+#include "strata/kernels/kv_q8.hpp"+#include "strata/kernels/qsa.hpp"+#include "strata/kernels/qsa_decode_attn.hpp"+#include "strata/kernels/qsa_prompt_attn.hpp"++#include <algorithm>+#include <cmath>+#include <cstdio>+#include <cstdlib>+#include <cstring>+#include <random>+#include <vector>++namespace k = strata::kernels;++namespace {+int g_fail = 0;+void ck(dpct::err0 e, const char *w) {+ /*+ DPCT1009: SYCL reports errors using exceptions and does not use error+ codes. Please replace the "get_error_string_dummy(...)" with a real+ error-handling function.+ */+}+template <typename T> T* dalloc(size_t n) {+ T* p = nullptr;+ ck(DPCT_CHECK_ERROR(p = (T *)sycl::malloc_device(+ n * sizeof(T) + 64, dpct::get_in_order_queue())),+ "malloc");+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue().memset(p, 0, n * sizeof(T) + 64).wait()),+ "memset");+ return p;+}++// kv_q4_parity.cpp's exact CPU references.+void fwht256_host_reference(float* x) {+ constexpr int n = 256;+ for (int s = 1; s < n; s *= 2) {+ for (int i = 0; i < n; i += 2 * s) {+ for (int j = 0; j < s; ++j) {+ const float u = x[i + j];+ const float v = x[i + j + s];+ x[i + j] = u + v;+ x[i + j + s] = u - v;+ }+ }+ }+ const float scale = 1.0f / 16.0f;+ for (int i = 0; i < n; ++i) x[i] *= scale;+}+void quantize_block_q4_0_host(const float* x, k::block_q4_0& blk) {+ float amax = 0.0f, max_val = 0.0f;+ for (int i = 0; i < 32; ++i) {+ const float v = x[i];+ if (amax < std::fabs(v)) { amax = std::fabs(v); max_val = v; }+ }+ const float d = max_val / -8.0f;+ const float id = d != 0.0f ? 1.0f / d : 0.0f;+ blk.d = k::f16_from_f32(d);+ for (int i = 0; i < 16; ++i) {+ const int q0 = (int) (x[i] * id + 8.5f);+ const int q1 = (int) (x[i + 16] * id + 8.5f);+ const uint8_t xi0 = (uint8_t) std::min(15, std::max(0, q0));+ const uint8_t xi1 = (uint8_t) std::min(15, std::max(0, q1));+ blk.qs[i] = xi0 | (xi1 << 4);+ }+}+} // namespace++int main() {+ std::printf("=== Running kv_hybrid_parity test ===\n");+ k::QsaShapes s = k::qsa_real_shapes();+ s.page_size = 64;+ const int H = (int) s.n_head_kv, D = (int) s.head_dim, P = (int) s.page_size, G = D / k::KV_Q8_GROUP;+ const int QH = (int) s.n_head, PER = QH / H; // query heads per KV head+ const int pages = 24, cells = pages * P; // n_chunks >= n_head: the batched merge overlaps queries below that+ std::mt19937 rng(17);+ std::normal_distribution<float> nd(0.0f, 1.0f);++ std::vector<int32_t> table(pages);+ for (int i = 0; i < pages; ++i) table[i] = (i * 5 + 3) % pages;+ int32_t* d_table = dalloc<int32_t>(pages);+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ the original code the source host memory is pageable memory. If the memory+ is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue().memcpy(d_table, table.data(), pages * 4).wait()),+ "table");++ std::vector<float> K((size_t) cells * H * D), V((size_t) cells * H * D);+ for (auto& x : K) x = nd(rng) * 0.5f;+ for (auto& x : V) x = nd(rng) * 0.5f;++ // ---- host reference: K in INT8 (kv_q8.hpp), rotated V in Q4_0 (kv_q4.hpp)+ std::vector<int8_t> rk((size_t) cells * H * D);+ std::vector<uint16_t> rk_s((size_t) cells * H * G);+ for (int c = 0; c < cells; ++c)+ for (int h = 0; h < H; ++h)+ for (int g = 0; g < G; ++g) {+ float amax = 0.0f;+ for (int t = 0; t < k::KV_Q8_GROUP; ++t)+ amax = std::max(amax, std::fabs(K[((size_t) c * H + h) * D + g * k::KV_Q8_GROUP + t]));+ const uint16_t sb = k::f16_from_f32(amax / 127.0f);+ const float sf = k::f32_from_f16(sb);+ for (int t = 0; t < k::KV_Q8_GROUP; ++t) {+ int q = 0;+ if (sf > 0.0f) {+ q = (int) std::nearbyint(K[((size_t) c * H + h) * D + g * k::KV_Q8_GROUP + t] / sf); // rn: ties to even, as the kernel+ q = std::max(-127, std::min(127, q));+ }+ rk[((size_t) c * H + h) * D + g * k::KV_Q8_GROUP + t] = (int8_t) q;+ }+ rk_s[((size_t) c * H + h) * G + g] = sb;+ }+ std::vector<float> Vrot((size_t) cells * H * D);+ std::memcpy(Vrot.data(), V.data(), V.size() * 4);+ for (int c = 0; c < cells * H; ++c) fwht256_host_reference(Vrot.data() + (size_t) c * D);+ std::vector<k::block_q4_0> rv4((size_t) cells * H * (D / 32));+ for (int c = 0; c < cells; ++c)+ for (int h = 0; h < H; ++h)+ for (int b = 0; b < D / 32; ++b)+ quantize_block_q4_0_host(&Vrot[((size_t) c * H + h) * D + b * 32],+ rv4[((size_t) c * H + h) * (D / 32) + b]);++ // ---- device: one cell appended through the COMPOSED hybrid calls, then gathered+ const int64_t q4_row = (int64_t) k::kv_q4_bytes_per_head(D);+ int8_t* d_kq = dalloc<int8_t>((size_t) cells * H * D);+ uint16_t* d_ks = dalloc<uint16_t>((size_t) cells * H * G);+ uint8_t* d_v4 = dalloc<uint8_t>((size_t) cells * H * q4_row);+ float *d_kcur = dalloc<float>((size_t) H * D), *d_vcur = dalloc<float>((size_t) H * D);+ int32_t* d_step = dalloc<int32_t>(k::kStepCount);++ int append_bad = 0, gather_bad = 0;+ for (int c = 0; c < cells; ++c) {+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue()+ .memcpy(d_kcur, &K[(size_t)c * H * D], (size_t)H * D * 4)+ .wait()),+ "kcur");+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue()+ .memcpy(d_vcur, &V[(size_t)c * H * D], (size_t)H * D * 4)+ .wait()),+ "vcur");+ int32_t step[k::kStepCount];+ k::qsa_step_fill(step, c, s);+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,+ assuming in the original code the source host memory is pageable memory.+ If the memory is not pageable, call wait() on event return by memcpy API+ to ensure synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue().memcpy(d_step, step, sizeof step).wait()),+ "step");+ // exactly what qsa_layer's hybrid branch does+ k::fwht256_inplace_cuda(d_vcur, H, nullptr);+ k::kv_append_q8_step(d_kq, d_kq, d_ks, d_ks, d_table, d_step, d_kcur, d_kcur, s, nullptr, nullptr);+ k::kv_append_q4_step(d_v4, d_v4, d_table, d_step, d_vcur, d_vcur, s, nullptr, nullptr);+ /*+ DPCT1010: SYCL uses exceptions to report errors and does not use the+ error codes. The cudaGetLastError function call was replaced with 0. You+ need to rewrite this code.+ */+ ck(0 != 0 ? 0 : 0, "append");+ }+ ck(DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw()),+ "append sync");++ std::vector<int8_t> hk((size_t) cells * H * D);+ std::vector<uint16_t> hks((size_t) cells * H * G);+ std::vector<uint8_t> hv4((size_t) cells * H * q4_row);+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(hk.data(), d_kq, hk.size())+ .wait()),+ "kq");+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(hks.data(), d_ks, hks.size() * 2)+ .wait()),+ "ks");+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(hv4.data(), d_v4, hv4.size())+ .wait()),+ "v4");+ // the pools are PHYSICAL (page, head, slot); the reference is by LOGICAL cell - compare through the table+ const k::block_q4_0* hv4b = reinterpret_cast<const k::block_q4_0*>(hv4.data());+ for (int c = 0; c < cells; ++c) {+ const long long row = ((long long) table[c / P] * H);+ for (int h = 0; h < H; ++h) {+ const long long r = (row + h) * P + c % P;+ for (int d = 0; d < D; ++d)+ if (hk[(size_t) r * D + d] != rk[((size_t) c * H + h) * D + d]) ++append_bad;+ for (int g = 0; g < G; ++g)+ if (hks[(size_t) r * G + g] != rk_s[((size_t) c * H + h) * G + g]) ++append_bad;+ for (int b = 0; b < D / 32; ++b) {+ const k::block_q4_0& got = hv4b[(size_t) r * (D / 32) + b];+ if (got.d != rv4[((size_t) c * H + h) * (D / 32) + b].d ||+ std::memcmp(got.qs, rv4[((size_t) c * H + h) * (D / 32) + b].qs, 16) != 0) ++append_bad;+ }+ }+ }+ std::printf("[1/3] composed appends: %s (%d bad values of %zu K / %zu V)\n",+ append_bad == 0 ? "PASS" : "FAIL", append_bad, hk.size(), rv4.size());++ // gather every cell (ids = all, ascending - the identity selection for width = cells)+ std::vector<int32_t> ids(cells);+ for (int i = 0; i < cells; ++i) ids[i] = i;+ int32_t* d_ids = dalloc<int32_t>(cells);+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ the original code the source host memory is pageable memory. If the memory+ is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue().memcpy(d_ids, ids.data(), cells * 4).wait()),+ "ids");+ int32_t step[k::kStepCount];+ k::qsa_step_fill(step, cells - 1, s);+ step[k::kStepWidth] = cells; // select everything+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ the original code the source host memory is pageable memory. If the memory+ is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue().memcpy(d_step, step, sizeof step).wait()),+ "step2");+ uint16_t *d_ksc = dalloc<uint16_t>((size_t) cells * H * D), *d_vsc = dalloc<uint16_t>((size_t) cells * H * D);+ k::kv_gather_q8_step(d_kq, d_kq, d_ks, d_ks, d_table, d_ids, d_step, cells, s, d_ksc, d_ksc, nullptr);+ k::kv_gather_q4_step(d_v4, d_v4, d_table, d_ids, d_step, cells, s, d_vsc, d_vsc, nullptr);+ ck(DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw()),+ "gather sync");+ std::vector<uint16_t> h_ksc((size_t) cells * H * D), h_vsc((size_t) cells * H * D);+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(h_ksc.data(), d_ksc, h_ksc.size() * 2)+ .wait()),+ "ksc");+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(h_vsc.data(), d_vsc, h_vsc.size() * 2)+ .wait()),+ "vsc");+ for (int c = 0; c < cells; ++c)+ for (int h = 0; h < H; ++h)+ for (int d = 0; d < D; ++d) {+ const float kref = k::f32_from_f16(k::f16_from_f32(+ (float) rk[((size_t) c * H + h) * D + d] * k::f32_from_f16(rk_s[((size_t) c * H + h) * G + d / k::KV_Q8_GROUP])));+ if (k::f32_from_f16(h_ksc[((size_t) c * H + h) * D + d]) != kref) ++gather_bad;+ const k::block_q4_0& b = rv4[((size_t) c * H + h) * (D / 32) + d / 32];+ const int nib = d % 32 < 16 ? (b.qs[d % 32] & 0x0F) - 8 : ((b.qs[d % 32 - 16] >> 4) - 8);+ const float vref = k::f32_from_f16(k::f16_from_f32((float) nib * k::f32_from_f16(b.d)));+ if (k::f32_from_f16(h_vsc[((size_t) c * H + h) * D + d]) != vref) ++gather_bad;+ }+ std::printf("[2/3] composed gathers: %s (%d bad of %zu)\n",+ gather_bad == 0 ? "PASS" : "FAIL", gather_bad, h_ksc.size());++ // ---- attention: qsa_decode_attn KV_MODE 3 over the hybrid pools + output fwht, vs fp32 references+ std::vector<float> q((size_t) QH * D);+ for (auto& x : q) x = nd(rng);+ float* d_q = dalloc<float>(q.size());+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming+ in the original code the source host memory is pageable memory. If the+ memory is not pageable, call wait() on event return by memcpy API to ensure+ synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue().memcpy(d_q, q.data(), q.size() * 4).wait()),+ "q");+ k::QsaAttnPools pools;+ pools.k_q = d_kq; pools.k_scale = d_ks; pools.v_q4 = d_v4; pools.page_table = d_table;+ float* d_scr = dalloc<float>(k::qsa_decode_attn_scratch_floats(cells, s) + 16);+ float* d_attn = dalloc<float>((size_t) QH * D);+ k::qsa_decode_attn_step(d_q, pools, d_ids, d_step, cells, s, d_scr, d_attn, nullptr);+ k::fwht256_inplace_cuda(d_attn, QH, nullptr); // the engine's inverse rotation of the output+ ck(DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw()),+ "attn sync");+ std::vector<float> h_attn((size_t) QH * D);+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(h_attn.data(), d_attn, h_attn.size() * 4)+ .wait()),+ "attn");++ // reference A: attention over the SAME dequantized K/V (isolates the kernel; fp32 host math)+ // reference B: attention over the TRUE unquantized K/V (bounds the format's error)+ auto host_attn = [&](const std::vector<float>& Keq, const std::vector<float>& Veq, std::vector<float>& out) {+ out.assign((size_t) QH * D, 0.0f);+ for (int h = 0; h < QH; ++h) {+ const int kvh = h / PER;+ std::vector<float> sc(cells);+ float m = -1e30f;+ for (int c = 0; c < cells; ++c) {+ float d_ = 0.0f;+ for (int t = 0; t < D; ++t)+ d_ += q[(size_t) h * D + t] * Keq[((size_t) c * H + kvh) * D + t];+ sc[c] = d_ / std::sqrt((float) D);+ m = std::max(m, sc[c]);+ }+ float l = 0.0f;+ for (int c = 0; c < cells; ++c) { sc[c] = std::exp(sc[c] - m); l += sc[c]; }+ for (int c = 0; c < cells; ++c)+ for (int t = 0; t < D; ++t) out[(size_t) h * D + t] += sc[c] / l * Veq[((size_t) c * H + kvh) * D + t];+ }+ };+ std::vector<float> Kdq((size_t) cells * H * D), Vdq((size_t) cells * H * D);+ for (int c = 0; c < cells; ++c)+ for (int h = 0; h < H; ++h)+ for (int d = 0; d < D; ++d) {+ Kdq[((size_t) c * H + h) * D + d] =+ (float) rk[((size_t) c * H + h) * D + d] * k::f32_from_f16(rk_s[((size_t) c * H + h) * G + d / k::KV_Q8_GROUP]);+ const k::block_q4_0& b = rv4[((size_t) c * H + h) * (D / 32) + d / 32];+ const int nib = d % 32 < 16 ? (b.qs[d % 32] & 0x0F) - 8 : ((b.qs[d % 32 - 16] >> 4) - 8);+ Vdq[((size_t) c * H + h) * D + d] = (float) nib * k::f32_from_f16(b.d);+ }+ // un-rotate the dequantized V (the kernel returns the output in the UNROTATED domain)+ std::vector<float> Vdq_un(Vdq.size());+ std::memcpy(Vdq_un.data(), Vdq.data(), Vdq.size() * 4);+ for (int c = 0; c < cells * H; ++c) fwht256_host_reference(Vdq_un.data() + (size_t) c * D);++ // ---- batched form with TWO queries and per-query step arrays (the verify.cpp window's exact call)+ {+ const int nq = 2;+ std::vector<float> q2((size_t) nq * QH * D);+ for (auto& x : q2) x = nd(rng);+ float* d_q2 = dalloc<float>(q2.size());+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,+ assuming in the original code the source host memory is pageable memory.+ If the memory is not pageable, call wait() on event return by memcpy API+ to ensure synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(d_q2, q2.data(),+ q2.size() * 4).wait()),+ "q2");+ // the batched kernel indexes ids[z * cap + ...]: one FULL selection per query+ std::vector<int32_t> ids2((size_t) nq * cells);+ for (int i = 0; i < nq; ++i) for (int c = 0; c < cells; ++c) ids2[(size_t) i * cells + c] = c;+ int32_t* d_ids2 = dalloc<int32_t>((size_t) nq * cells);+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,+ assuming in the original code the source host memory is pageable memory.+ If the memory is not pageable, call wait() on event return by memcpy API+ to ensure synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(+ d_ids2, ids2.data(), ids2.size() * 4).wait()),+ "ids2");+ int32_t* d_steps2 = dalloc<int32_t>(nq * k::kStepCount);+ for (int i = 0; i < nq; ++i) {+ int32_t st2[k::kStepCount];+ k::qsa_step_fill(st2, cells - 1 - i, s);+ st2[k::kStepWidth] = cells - i; // slightly different widths, as verify's windows have+ /*+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,+ assuming in the original code the source host memory is pageable+ memory. If the memory is not pageable, call wait() on event return+ by memcpy API to ensure synchronization behavior.+ */+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(+ d_steps2 + i * k::kStepCount, st2, sizeof st2).wait()),+ "steps2");+ }+ float* d_scr2 = dalloc<float>(k::qsa_decode_attn_scratch_floats(cells, s) * nq + 64);+ float* d_at2 = dalloc<float>((size_t) nq * QH * D);+ k::qsa_decode_attn_batch(d_q2, pools, d_ids2, d_steps2, cells, s, d_scr2, d_at2, nq, nullptr);+ k::fwht256_inplace_cuda(d_at2, (int64_t) nq * QH, nullptr);+ ck(DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw()),+ "attn2 sync");+ std::vector<float> h_at2((size_t) nq * QH * D);+ ck(DPCT_CHECK_ERROR(dpct::get_in_order_queue()+ .memcpy(h_at2.data(), d_at2, h_at2.size() * 4)+ .wait()),+ "at2");+ double max_b = 0.0;+ double per_q[2] = {0.0, 0.0};+ for (int i = 0; i < nq; ++i)+ for (int h = 0; h < QH; ++h) {+ // reference over the cells this query's width selects (ids are ascending: the first width)+ const int w = cells - i;+ std::vector<float> sc(w);+ float m = -1e30f;+ for (int c = 0; c < w; ++c) {+ float d_ = 0.0f;+ for (int t = 0; t < D; ++t)+ d_ += q2[((size_t) i * QH + h) * D + t] * Kdq[((size_t) c * H + h / PER) * D + t];+ sc[c] = d_ / std::sqrt((float) D);+ m = std::max(m, sc[c]);+ }+ float l = 0.0f;+ for (int c = 0; c < w; ++c) { sc[c] = std::exp(sc[c] - m); l += sc[c]; }+ for (int d = 0; d < D; ++d) {+ float acc = 0.0f;+ for (int c = 0; c < w; ++c)+ acc += sc[c] / l * Vdq_un[((size_t) c * H + h / PER) * D + d]; // dim d only+ const double e = (double) std::fabs(h_at2[((size_t) i * QH + h) * D + d] - acc);+ max_b = std::max(max_b, e);+ per_q[i] = std::max(per_q[i], e);+ }+ }+ const bool bok = max_b < 5e-3;+ std::printf(" (per-query max: q0 %.2e, q1 %.2e)\n", per_q[0], per_q[1]);+ std::printf("[4/4] mode-3 BATCHED attention (verify's form): %s (vs dequant ref %.2e)\n",+ bok ? "PASS" : "FAIL", max_b);+ if (!bok) g_fail = 1;+ }++ std::vector<float> ref_deq, ref_true;+ host_attn(Kdq, Vdq_un, ref_deq);+ host_attn(K, V, ref_true);+ double max_deq = 0.0, max_true = 0.0;+ for (size_t i = 0; i < h_attn.size(); ++i) {+ max_deq = std::max(max_deq, (double) std::fabs(h_attn[i] - ref_deq[i]));+ max_true = std::max(max_true, (double) std::fabs(h_attn[i] - ref_true[i]));+ }+ // The tensor-core prompt path (qsa_prompt_attn, 0.1.22+) takes hybrid pools as KV_MODE 3: INT8 K, and V+ // dequantized from its q4_0 blocks to fp16 at gather. Its summation order differs from the old kernel's+ // (accuracy-level, not bitwise - qsa_prompt_attn.hpp says the same of its int8 mode), so: tolerance check+ // against the SAME dequant reference, output un-rotated exactly as prefill.cpp does.+ {+ float* d_at4 = dalloc<float>((size_t) QH * D);+ const bool took = k::qsa_prompt_attn_batch(d_q, pools, d_ids, d_step, cells, s, d_at4, 1, nullptr);+ if (!took) {+#if defined(STRATA_USE_HIP)+ // AMD: the tensor-core prompt path is CUDA-only, so it refuses every pool and the old kernel runs+ std::printf("[5/5] qsa_prompt_attn mode 3: PASS (refused on HIP - the old kernel runs)\n");+#else+ std::printf("[5/5] qsa_prompt_attn mode 3: FAIL (refused the hybrid pools)\n");+ g_fail = 1;+#endif+ } else {+ k::fwht256_inplace_cuda(d_at4, QH, nullptr);+ ck(DPCT_CHECK_ERROR(+ dpct::get_current_device().queues_wait_and_throw()),+ "at4 sync");+ std::vector<float> h_at4((size_t) QH * D);+ ck(DPCT_CHECK_ERROR(+ dpct::get_in_order_queue()+ .memcpy(h_at4.data(), d_at4, h_at4.size() * 4)+ .wait()),+ "at4");+ double max_p = 0.0;+ for (size_t i = 0; i < h_at4.size(); ++i)+ max_p = std::max(max_p, (double) std::fabs(h_at4[i] - ref_deq[i]));+ const bool pok = max_p < 1e-2;+ std::printf("[5/5] qsa_prompt_attn mode 3 (tensor cores): %s (vs dequant ref %.2e)\n",+ pok ? "PASS" : "FAIL", max_p);+ if (!pok) g_fail = 1;+ }+ }++ const bool attn_ok = max_deq < 5e-3; // fp32 kernel math vs fp64-ish host accumulation+ std::printf("[3/3] mode-3 attention + output fwht: %s (vs dequant ref %.2e, vs true fp32 %.2e)\n",+ attn_ok ? "PASS" : "FAIL", max_deq, max_true);++ const bool ok = append_bad == 0 && gather_bad == 0 && attn_ok && g_fail == 0;+ std::printf("=== kv_hybrid_parity: %s ===\n", ok ? "ALL PASS" : "FAILED");+ return ok ? 0 : 1;+}diff --git a/sycl/src/kernels/kv_q4_parity.cpp b/sycl/src/kernels/kv_q4_parity.cppindex adb24e7de..13d823f15 100644--- a/sycl/src/kernels/kv_q4_parity.cpp+++ b/sycl/src/kernels/kv_q4_parity.cpp@@ -116,7 +116,7 @@ int main() {float* d_src = dalloc<float>(n_vectors * 256);float* d_dst = dalloc<float>(n_vectors * 256);/*- DPCT1114:781: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -213,7 +213,7 @@ int main() {for (int i = 0; i < pages; ++i) table[i] = (i * 3 + 5) % pages; // permutationint32_t* d_table = dalloc<int32_t>(pages);/*- DPCT1114:782: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -251,7 +251,7 @@ int main() {int32_t hstep[k::kStepCount] = {pos, pos + 1, 0, 0};/*- DPCT1114:783: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -260,7 +260,7 @@ int main() {dpct::get_in_order_queue().memcpy(d_step, hstep, sizeof(hstep)).wait()),"memcpy step");/*- DPCT1114:784: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -269,7 +269,7 @@ int main() {d_kcur, kv.data(), kv.size() * sizeof(float)).wait()),"memcpy k");/*- DPCT1114:785: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -351,7 +351,7 @@ int main() {ids[i] = positions[rng() % n_fill];}/*- DPCT1114:786: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -362,7 +362,7 @@ int main() {int32_t hstep[k::kStepCount] = {0, 0, 0, max_ids};/*- DPCT1114:787: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/kv_q8_parity.cpp b/sycl/src/kernels/kv_q8_parity.cppindex 7865de8eb..2655b6df4 100644--- a/sycl/src/kernels/kv_q8_parity.cpp+++ b/sycl/src/kernels/kv_q8_parity.cpp@@ -26,7 +26,7 @@ namespace {int g_fail = 0;void ck(dpct::err0 e, const char *w) {/*- DPCT1009:423: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -54,7 +54,7 @@ int main() {for (int i = 0; i < pages; ++i) table[i] = (i * 5 + 3) % pages; // a non-identity permutationint32_t* d_table = dalloc<int32_t>(pages);/*- DPCT1114:424: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -83,7 +83,7 @@ int main() {hk[pos] = kv; hv[pos] = vv;int32_t hstep[k::kStepCount] = {pos, pos + 1, 0, 0};/*- DPCT1114:425: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -92,7 +92,7 @@ int main() {dpct::get_in_order_queue().memcpy(step, hstep, sizeof hstep).wait()),"step");/*- DPCT1114:426: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -101,7 +101,7 @@ int main() {kv.size() * 4).wait()),"k");/*- DPCT1114:427: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -165,7 +165,7 @@ int main() {std::vector<int32_t> ids(n_ids);for (auto& id : ids) id = positions[rng() % n_fill];/*- DPCT1114:428: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -175,7 +175,7 @@ int main() {"ids");int32_t hstep[k::kStepCount] = {0, 0, 0, n_ids};/*- DPCT1114:429: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/kv_stream_parity.cpp b/sycl/src/kernels/kv_stream_parity.cppindex 8c178d437..1c5e087b0 100644--- a/sycl/src/kernels/kv_stream_parity.cpp+++ b/sycl/src/kernels/kv_stream_parity.cpp@@ -32,7 +32,7 @@ namespace {int g_fail = 0;void ck(dpct::err0 e, const char *w) {/*- DPCT1009:886: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -51,7 +51,7 @@ template <typename T> T* halloc(size_t n) { // pinned, mapped; returns the devvoid* h = nullptr;void* d = nullptr;/*- DPCT1048:13: The original value cudaHostAllocMapped is not meaningful in the+ DPCT1048: The original value cudaHostAllocMapped is not meaningful in themigrated code and was removed or replaced with 0. You may need to check themigrated code.*/@@ -136,7 +136,7 @@ bool run(int fmt) {std::vector<int32_t> t(n_blocks);for (int64_t i = 0; i < n_blocks; ++i) t[i] = (int32_t) i;/*- DPCT1114:887: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -172,7 +172,7 @@ bool run(int fmt) {for (auto& x : hv) x = nd(rng);const int32_t st[4] = {(int32_t) pos, (int32_t) (pos + 1), (int32_t) ((pos + 1) / 4), 0};/*- DPCT1114:888: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -181,7 +181,7 @@ bool run(int fmt) {dpct::get_in_order_queue().memcpy(kc, hk.data(), hk.size() * 4).wait()),"k");/*- DPCT1114:889: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -190,7 +190,7 @@ bool run(int fmt) {dpct::get_in_order_queue().memcpy(vc, hv.data(), hv.size() * 4).wait()),"v");/*- DPCT1114:890: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -215,7 +215,7 @@ bool run(int fmt) {}for (auto& x : hq) x = nd(rng);/*- DPCT1114:891: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -224,7 +224,7 @@ bool run(int fmt) {hids.size() * 4).wait()),"ids");/*- DPCT1114:892: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -233,7 +233,7 @@ bool run(int fmt) {hst.size() * 4).wait()),"steps");/*- DPCT1114:893: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -298,7 +298,7 @@ bool run(int fmt) {std::vector<int32_t> hids((size_t) cap), hst = {(int32_t) (N - 1), (int32_t) N, (int32_t) (N / 4), (int32_t) width};for (int64_t i = 0; i < width; ++i) hids[i] = (int32_t) (N - width + i); // the window's last cells/*- DPCT1114:894: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -307,7 +307,7 @@ bool run(int fmt) {hids.size() * 4).wait()),"ids");/*- DPCT1114:895: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/ple_parity.cpp b/sycl/src/kernels/ple_parity.cppindex 79aede9c1..5679df58a 100644--- a/sycl/src/kernels/ple_parity.cpp+++ b/sycl/src/kernels/ple_parity.cpp@@ -209,7 +209,7 @@ int history_advance_regression() {float* history = history_storage + guard;float* norm = norm_storage + guard;/*- DPCT1114:944: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -221,7 +221,7 @@ int history_advance_regression() {dpct::experimental::command_graph_ptr graph;dpct::experimental::command_graph_exec_ptr executable;/*- DPCT1025:945: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/ck(DPCT_CHECK_ERROR(stream = dpct::get_current_device().create_queue(true)),@@ -244,7 +244,7 @@ int history_advance_regression() {expected[c * rows + rows - 1] = normalized[c];}/*- DPCT1124:946: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -764,7 +764,7 @@ int main(int argc, char** argv) {hcd * 4, dpct::get_in_order_queue())),"cr");/*- DPCT1114:947: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -773,7 +773,7 @@ int main(int argc, char** argv) {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -782,7 +782,7 @@ int main(int argc, char** argv) {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -791,7 +791,7 @@ int main(int argc, char** argv) {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -800,7 +800,7 @@ int main(int argc, char** argv) {d_kc, key_codes.data(), key_codes.size()).wait()),"ckc");/*- DPCT1114:951: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -809,7 +809,7 @@ int main(int argc, char** argv) {d_vb, value_bf16.data(), value_bf16.size() * 2).wait()),"cvb");/*- DPCT1114:952: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -831,7 +831,7 @@ int main(int argc, char** argv) {key_scales.size() * 4, dpct::get_in_order_queue())),"ks");/*- DPCT1114:953: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -861,7 +861,7 @@ int main(int argc, char** argv) {std::vector<float> hist_state = cap.hist;for (int t = 0; t < cap.nt; ++t) {/*- DPCT1114:954: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -870,7 +870,7 @@ int main(int argc, char** argv) {d_emb, cap.emb.data() + (size_t)t * nd, nd * 4).wait()),"cemb");/*- DPCT1114:955: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -879,7 +879,7 @@ int main(int argc, char** argv) {d_hid, cap.hidden.data() + (size_t)t * hcd, hcd * 4).wait()),"chid");/*- DPCT1114:956: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -1010,7 +1010,7 @@ int main(int argc, char** argv) {reference_value[row] = float(sum);}/*- DPCT1114:957: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -1030,7 +1030,7 @@ int main(int argc, char** argv) {"legacy PLE witness value");dpct::queue_ptr stream;/*- DPCT1025:958: The SYCL queue is created ignoring the flag and+ DPCT1025: The SYCL queue is created ignoring the flag andpriority options.*/ck(DPCT_CHECK_ERROR(@@ -1089,7 +1089,7 @@ int main(int argc, char** argv) {dpct::get_current_device().destroy_queue(stream)),"native PLE stream destroy");/*- DPCT1114:959: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -1147,7 +1147,7 @@ int main(int argc, char** argv) {void* native_data = static_cast<uint8_t*>(native_storage) + guard;void* native_q = static_cast<uint8_t*>(q_storage) + guard;/*- DPCT1114:960: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -1159,7 +1159,7 @@ int main(int argc, char** argv) {nw.key_native_data = native_data; nw.key_native_type = 42; nw.key_native_q8_1 = native_q;dpct::queue_ptr stream;/*- DPCT1025:961: The SYCL queue is created ignoring the flag and+ DPCT1025: The SYCL queue is created ignoring the flag andpriority options.*/ck(DPCT_CHECK_ERROR(@@ -1203,7 +1203,7 @@ int main(int argc, char** argv) {std::vector<float> projected(hcd), normalized(hcd), actual_key(hcd), actual_result(hcd), replay(hcd);for (int p = 0; p < std::min(cap.nt, 2); ++p) {/*- DPCT1114:962: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -1300,7 +1300,7 @@ int main(int argc, char** argv) {sycl::free(q_storage, dpct::get_in_order_queue());sycl::free(native_storage, dpct::get_in_order_queue());/*- DPCT1114:963: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -1354,7 +1354,7 @@ int main(int argc, char** argv) {std::printf(" PLE separate exports and in-place hidden result: %s\n", equal ? "byte-identical" : "FAIL");if (!equal) ++bad;/*- DPCT1114:964: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.diff --git a/sycl/src/kernels/qsa_parity.cpp b/sycl/src/kernels/qsa_parity.cppindex e4c3df23b..efbb202a2 100644--- a/sycl/src/kernels/qsa_parity.cpp+++ b/sycl/src/kernels/qsa_parity.cpp@@ -92,7 +92,7 @@ struct Dev {void put(const std::vector<T>& v) {if (!p) alloc(v.size());/*- DPCT1114:1008: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/qsa_prompt_attn_parity.cpp b/sycl/src/kernels/qsa_prompt_attn_parity.cppindex 5746b6c8a..645f21f87 100644--- a/sycl/src/kernels/qsa_prompt_attn_parity.cpp+++ b/sycl/src/kernels/qsa_prompt_attn_parity.cpp@@ -27,7 +27,7 @@ namespace k = strata::kernels;namespace {void ck(dpct::err0 e, const char *w) {/*- DPCT1009:788: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -39,7 +39,7 @@ template <typename T> T* up(const std::vector<T>& h) {dpct::get_in_order_queue())),"malloc");/*- DPCT1114:789: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/qsa_select_bench.cpp b/sycl/src/kernels/qsa_select_bench.cppindex 6287a804b..533237f94 100644--- a/sycl/src/kernels/qsa_select_bench.cpp+++ b/sycl/src/kernels/qsa_select_bench.cpp@@ -20,7 +20,7 @@ namespace k = strata::kernels;namespace {void ck(dpct::err0 e, const char *w) {/*- DPCT1009:603: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -32,7 +32,7 @@ template <typename T> T* up(const std::vector<T>& h) {dpct::get_in_order_queue())),"malloc");/*- DPCT1114:604: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/quantize_act_parity.cpp b/sycl/src/kernels/quantize_act_parity.cppindex 8f3a15b17..bc11b8540 100644--- a/sycl/src/kernels/quantize_act_parity.cpp+++ b/sycl/src/kernels/quantize_act_parity.cpp@@ -84,7 +84,7 @@ int run_case(const char* name, const std::vector<float>& x, bool check_bytes) {(size_t)n, dpct::get_in_order_queue())),"malloc back");/*- DPCT1114:1053: cudaMemcpy is migrated to asynchronization memcpy, assuming+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assumingin the original code the source host memory is pageable memory. If thememory is not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -216,7 +216,7 @@ int run_case_k(const char* name, const std::vector<float>& x, bool check_bytes,(size_t)n, dpct::get_in_order_queue())),"malloc back");/*- DPCT1114:1054: cudaMemcpy is migrated to asynchronization memcpy, assuming+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assumingin the original code the source host memory is pageable memory. If thememory is not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/rope_parity.cpp b/sycl/src/kernels/rope_parity.cppindex 0b7e5ad3b..ccb1df640 100644--- a/sycl/src/kernels/rope_parity.cpp+++ b/sycl/src/kernels/rope_parity.cpp@@ -107,7 +107,7 @@ int main(int argc, char** argv) {pos.size(), dpct::get_in_order_queue())),"malloc pos");/*- DPCT1114:309: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -116,7 +116,7 @@ int main(int argc, char** argv) {d_x, x.data(), x.size() * sizeof(float)).wait()),"copy x");/*- DPCT1114:310: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -125,7 +125,7 @@ int main(int argc, char** argv) {d_cos, hcos.data(), hcos.size() * sizeof(float)).wait()),"copy cos");/*- DPCT1114:311: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -134,7 +134,7 @@ int main(int argc, char** argv) {d_sin, hsin.data(), hsin.size() * sizeof(float)).wait()),"copy sin");/*- DPCT1114:312: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -189,7 +189,7 @@ int main(int argc, char** argv) {e[0] = 1.0f;std::vector<float> o((size_t) head_dim, 0.0f);/*- DPCT1114:313: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/router_top10_parity.cpp b/sycl/src/kernels/router_top10_parity.cppindex f492bd74d..b94e243a1 100644--- a/sycl/src/kernels/router_top10_parity.cpp+++ b/sycl/src/kernels/router_top10_parity.cpp@@ -79,7 +79,7 @@ int run_case(const char* name, const std::vector<float>& logits, int n_tokens, ih_w.size(), dpct::get_in_order_queue())),"malloc w");/*- DPCT1114:853: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/s2_gemv_parity.cpp b/sycl/src/kernels/s2_gemv_parity.cppindex 1f4bd0c25..2f60eb513 100644--- a/sycl/src/kernels/s2_gemv_parity.cpp+++ b/sycl/src/kernels/s2_gemv_parity.cpp@@ -125,7 +125,7 @@ int main(int argc, char** argv) {(size_t)n_out, dpct::get_in_order_queue())),"cudaMalloc y");/*- DPCT1114:482: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -134,7 +134,7 @@ int main(int argc, char** argv) {d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"copy x");/*- DPCT1114:483: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -143,7 +143,7 @@ int main(int argc, char** argv) {d_codes, codes.data(), codes.size()).wait()),"copy codes");/*- DPCT1114:484: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/s2_gemv_q8_parity.cpp b/sycl/src/kernels/s2_gemv_q8_parity.cppindex 53a5b0ad7..4f2f89805 100644--- a/sycl/src/kernels/s2_gemv_q8_parity.cpp+++ b/sycl/src/kernels/s2_gemv_q8_parity.cpp@@ -74,7 +74,7 @@ int main(int argc, char** argv) {(size_t)n_out, dpct::get_in_order_queue())),"m y2");/*- DPCT1114:931: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -83,7 +83,7 @@ int main(int argc, char** argv) {d_x, x.data(), x.size() * sizeof(float)).wait()),"c x");/*- DPCT1114:932: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -92,7 +92,7 @@ int main(int argc, char** argv) {d_codes, codes.data(), codes.size()).wait()),"c codes");/*- DPCT1114:933: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -198,7 +198,7 @@ int main(int argc, char** argv) {hx.size(), dpct::get_in_order_queue())),"m hx");/*- DPCT1114:934: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.diff --git a/sycl/src/kernels/s_gemv_parity.cpp b/sycl/src/kernels/s_gemv_parity.cppindex 9cd4972a0..6ebbb46a7 100644--- a/sycl/src/kernels/s_gemv_parity.cpp+++ b/sycl/src/kernels/s_gemv_parity.cpp@@ -247,7 +247,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {(size_t)n_out, dpct::get_in_order_queue())),"cudaMalloc y");/*- DPCT1114:393: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -256,7 +256,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"copy x");/*- DPCT1114:394: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -265,7 +265,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {d_codes, codes.data(), codes.size()).wait()),"copy codes");/*- DPCT1114:395: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -274,7 +274,7 @@ void test_q4k(long long n_in, long long n_out, double tol, int* total_bad) {d_scales, scales.data(), scales.size() * sizeof(float)).wait()),"copy scales");/*- DPCT1114:396: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -367,7 +367,7 @@ void bench_s2_gemv(long long n_in, long long n_out, int iters, int* split_bad) {(size_t)n_out, dpct::get_in_order_queue())),"bench y");/*- DPCT1114:397: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -376,7 +376,7 @@ void bench_s2_gemv(long long n_in, long long n_out, int iters, int* split_bad) {d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"bench copy x");/*- DPCT1114:398: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -385,7 +385,7 @@ void bench_s2_gemv(long long n_in, long long n_out, int iters, int* split_bad) {d_codes, codes.data(), codes.size()).wait()),"bench copy codes");/*- DPCT1114:399: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -664,7 +664,7 @@ int main(int argc, char** argv) {(size_t)n_out, dpct::get_in_order_queue())),"cudaMalloc y");/*- DPCT1114:400: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -673,7 +673,7 @@ int main(int argc, char** argv) {d_x, x.data(), x.size() * sizeof(uint16_t)).wait()),"copy x");/*- DPCT1114:401: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -682,7 +682,7 @@ int main(int argc, char** argv) {d_codes, codes.data(), codes.size()).wait()),"copy codes");/*- DPCT1114:402: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/s_gemv_q8k_parity.cpp b/sycl/src/kernels/s_gemv_q8k_parity.cppindex 9f572cf90..95f289421 100644--- a/sycl/src/kernels/s_gemv_q8k_parity.cpp+++ b/sycl/src/kernels/s_gemv_q8k_parity.cpp@@ -123,7 +123,7 @@ int main(int argc, char** argv) {xq8k.size(), dpct::get_in_order_queue())),"xq");/*- DPCT1114:847: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -165,7 +165,7 @@ int main(int argc, char** argv) {(size_t)n_out * 4, dpct::get_in_order_queue())),"y");/*- DPCT1114:848: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -174,7 +174,7 @@ int main(int argc, char** argv) {d_codes, codes.data(), codes.size()).wait()),"cc");/*- DPCT1114:849: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -183,7 +183,7 @@ int main(int argc, char** argv) {d_scales, scales.data(), scales.size() * 4).wait()),"cs");/*- DPCT1114:850: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -280,7 +280,7 @@ int main(int argc, char** argv) {(size_t)n_in * 2, dpct::get_in_order_queue())),"x16");/*- DPCT1114:851: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.diff --git a/sycl/src/kernels/sampler_parity.cpp b/sycl/src/kernels/sampler_parity.cppindex 46e140a5b..0ea146080 100644--- a/sycl/src/kernels/sampler_parity.cpp+++ b/sycl/src/kernels/sampler_parity.cpp@@ -108,7 +108,7 @@ int run(const char* name, const std::vector<float>& logits, int n_tokens, const(size_t)n_tokens, dpct::get_in_order_queue())),"malloc out");/*- DPCT1114:503: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -129,7 +129,7 @@ int run(const char* name, const std::vector<float>& logits, int n_tokens, consthist.size(), dpct::get_in_order_queue())),"malloc hist");/*- DPCT1114:504: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -372,7 +372,7 @@ int main(int argc, char** argv) {(size_t)NT, dpct::get_in_order_queue())),"m3");/*- DPCT1114:505: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -881,7 +881,7 @@ int main(int argc, char** argv) {count, dpct::get_in_order_queue())),"counter output");/*- DPCT1114:506: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/kernels/shared_expert_parity.cpp b/sycl/src/kernels/shared_expert_parity.cppindex e6bd26546..08e9a44d1 100644--- a/sycl/src/kernels/shared_expert_parity.cpp+++ b/sycl/src/kernels/shared_expert_parity.cpp@@ -227,7 +227,7 @@ int main(int argc, char** argv) {(size_t)n_embd, dpct::get_in_order_queue())),"m out");/*- DPCT1114:334: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -236,7 +236,7 @@ int main(int argc, char** argv) {d_x, hx.data(), hx.size() * sizeof(uint16_t)).wait()),"c x");/*- DPCT1114:335: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -245,7 +245,7 @@ int main(int argc, char** argv) {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -254,7 +254,7 @@ int main(int argc, char** argv) {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -263,7 +263,7 @@ int main(int argc, char** argv) {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+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -272,7 +272,7 @@ int main(int argc, char** argv) {d_gs, gs.data(), gs.size() * sizeof(float)).wait()),"c gs");/*- DPCT1114:339: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -281,7 +281,7 @@ int main(int argc, char** argv) {d_us, us.data(), us.size() * sizeof(float)).wait()),"c us");/*- DPCT1114:340: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -290,7 +290,7 @@ int main(int argc, char** argv) {d_ds, ds.data(), ds.size() * sizeof(float)).wait()),"c ds");/*- DPCT1114:341: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -299,7 +299,7 @@ int main(int argc, char** argv) {d_ginp, ginp.data(), ginp.size() * sizeof(float)).wait()),"c ginp");/*- DPCT1114:342: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -308,7 +308,7 @@ int main(int argc, char** argv) {d_xb, hx_bf16.data(), hx_bf16.size() * sizeof(uint16_t)).wait()),"c xb");/*- DPCT1114:343: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -335,7 +335,7 @@ int main(int argc, char** argv) {hx0.size(), dpct::get_in_order_queue())),"x0");/*- DPCT1114:344: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -467,7 +467,7 @@ int main(int argc, char** argv) {witness.size(), dpct::get_in_order_queue())),"native shared x");/*- DPCT1114:345: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -480,7 +480,7 @@ int main(int argc, char** argv) {d_dc, d_ds, nullptr, d_ginpb, d_scratch, d_out, n_embd, n_ff, tpr, stream, x_float);};/*- DPCT1114:346: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -496,7 +496,7 @@ int main(int argc, char** argv) {.wait()),"half shared output");/*- DPCT1114:347: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -505,7 +505,7 @@ int main(int argc, char** argv) {d_ginpb, basis.data(), basis.size() * sizeof(uint16_t)).wait()),"basis shared gate");/*- DPCT1114:348: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -526,7 +526,7 @@ int main(int argc, char** argv) {if (!refused_missing) ++bad;dpct::queue_ptr stream;/*- DPCT1025:349: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/check(DPCT_CHECK_ERROR(@@ -585,7 +585,7 @@ int main(int argc, char** argv) {DPCT_CHECK_ERROR(dpct::get_current_device().destroy_queue(stream)),"native shared stream destroy");/*- DPCT1114:350: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -595,7 +595,7 @@ int main(int argc, char** argv) {hginp_bf16.size() * sizeof(uint16_t)).wait()),"restore shared gate");/*- DPCT1114:351: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -668,7 +668,7 @@ int main(int argc, char** argv) {(size_t)n_embd2 * 4, dpct::get_in_order_queue())),"mc y");/*- DPCT1114:352: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -677,7 +677,7 @@ int main(int argc, char** argv) {d_p, parts.data(), parts.size() * 4).wait()),"mc cp");/*- DPCT1114:353: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -686,7 +686,7 @@ int main(int argc, char** argv) {w.size() * 4).wait()),"mc cw");/*- DPCT1114:354: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.diff --git a/sycl/src/prefill/gemm.dp.cpp b/sycl/src/prefill/gemm.dp.cppindex 1f1f362ba..3a683a7a8 100644--- a/sycl/src/prefill/gemm.dp.cpp+++ b/sycl/src/prefill/gemm.dp.cpp@@ -7,10 +7,34 @@#include "strata/kernels/dequant_bf16.hpp"#include <dpct/blas_utils.hpp>+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+// The HIP compatibility shim maps CUDA shuffle spellings to Strata helpers.+// hipBLASLt's public headers declare native HIP shuffle functions, so keep+// those declarations from being macro-expanded in this translation unit.+#undef __shfl_xor_sync+#undef __shfl_down_sync+#undef __shfl_up_sync+#undef __shfl_sync+#undef __ballot_sync+#endif++#include <climits>#include <cstdio>#include <cstdlib>+#include <cstring>+#include <memory>#include <dpct/lib_common_utils.hpp>+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+#include "hipblaslt_tuning.hpp"+#include <hip/hip_runtime_api.h>+#include <hipblaslt/hipblaslt.h>+#include <hipblaslt/hipblaslt-ext.hpp>+#include <map>+#include <set>+#include <tuple>+#endif+namespace strata::prefill {namespace {@@ -21,9 +45,239 @@ void ck(int s, const char *what) {}}+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+struct HipLtCallKey {+ strata::prefill::hipblaslt::InputType type;+ int t;+ int n;+ int k;+ int ldy;+ uint32_t beta_bits;++ bool operator<(const HipLtCallKey& other) const {+ return std::tie(type, n, k, ldy, t, beta_bits) <+ std::tie(other.type, other.n, other.k, other.ldy, other.t, other.beta_bits);+ }+};++struct HipLtCachedAlgo {+ bool supported = false;+ hipblasLtMatmulAlgo_t algo{};+ size_t workspace_bytes = 0;+};++struct HipLtState {+ hipblasLtHandle_t handle = nullptr;+ void* workspace = nullptr;+ size_t workspace_bytes = 0;+ strata::prefill::hipblaslt::TuningTable table;+ std::map<HipLtCallKey, HipLtCachedAlgo> cache;+ uint64_t lt_launches = 0;+ uint64_t fallbacks = 0;+ std::set<std::tuple<strata::prefill::hipblaslt::InputType, int, int, int, int>> fallback_shapes;++ ~HipLtState() {+ if (std::getenv("STRATA_HIPBLASLT_VERBOSE")) {+ std::fprintf(stderr, "prefill gemm: hipBLASLt summary launches=%llu fallbacks=%llu unique_fallback_shapes=%zu\n",+ (unsigned long long) lt_launches, (unsigned long long) fallbacks, fallback_shapes.size());+ for (const auto& shape : fallback_shapes) {+ const auto type = std::get<0>(shape);+ std::fprintf(stderr, "prefill gemm: fallback shape dtype=%s T=%d N=%d K=%d ldy=%d\n",+ type == strata::prefill::hipblaslt::InputType::bf16 ? "bf16" : "f16",+ std::get<1>(shape), std::get<2>(shape), std::get<3>(shape), std::get<4>(shape));+ }+ }+ if (handle) hipblasLtDestroy(handle);+ }+};++struct HipLtDescriptors {+ hipblasLtMatmulDesc_t op = nullptr;+ hipblasLtMatrixLayout_t a = nullptr;+ hipblasLtMatrixLayout_t b = nullptr;+ hipblasLtMatrixLayout_t c = nullptr;++ ~HipLtDescriptors() {+ if (op) hipblasLtMatmulDescDestroy(op);+ if (a) hipblasLtMatrixLayoutDestroy(a);+ if (b) hipblasLtMatrixLayoutDestroy(b);+ if (c) hipblasLtMatrixLayoutDestroy(c);+ }++ bool init(hipDataType type, int t, int n, int k, int ldy) {+ const hipblasOperation_t trans_a = HIPBLAS_OP_T;+ const hipblasOperation_t trans_b = HIPBLAS_OP_N;+ if (hipblasLtMatmulDescCreate(&op, HIPBLAS_COMPUTE_32F, HIP_R_32F) != HIPBLAS_STATUS_SUCCESS ||+ hipblasLtMatmulDescSetAttribute(op, HIPBLASLT_MATMUL_DESC_TRANSA, &trans_a, sizeof(trans_a)) !=+ HIPBLAS_STATUS_SUCCESS ||+ hipblasLtMatmulDescSetAttribute(op, HIPBLASLT_MATMUL_DESC_TRANSB, &trans_b, sizeof(trans_b)) !=+ HIPBLAS_STATUS_SUCCESS ||+ hipblasLtMatrixLayoutCreate(&a, type, k, n, k) != HIPBLAS_STATUS_SUCCESS ||+ hipblasLtMatrixLayoutCreate(&b, type, k, t, k) != HIPBLAS_STATUS_SUCCESS ||+ hipblasLtMatrixLayoutCreate(&c, HIP_R_32F, n, t, ldy) != HIPBLAS_STATUS_SUCCESS) {+ return false;+ }+ return true;+ }+};++std::unique_ptr<HipLtState> create_hipblaslt_state(void* workspace, size_t workspace_bytes) {+ const char* path = std::getenv("STRATA_HIPBLASLT_TUNING");+ if (!path || !*path) return nullptr;++ auto state = std::make_unique<HipLtState>();+ state->workspace = workspace;+ state->workspace_bytes = workspace_bytes;+ if (hipblasLtCreate(&state->handle) != HIPBLAS_STATUS_SUCCESS) {+ std::fprintf(stderr, "prefill gemm: hipBLASLt handle creation failed; using hipBLASEx\n");+ return nullptr;+ }++ int version = 0;+ if (hipblasLtGetVersion(state->handle, &version) != HIPBLAS_STATUS_SUCCESS) {+ std::fprintf(stderr, "prefill gemm: hipBLASLt version query failed; using hipBLASEx\n");+ return nullptr;+ }+ int device = 0;+ hipDeviceProp_t properties{};+ if (hipGetDevice(&device) != hipSuccess || hipGetDeviceProperties(&properties, device) != hipSuccess) {+ std::fprintf(stderr, "prefill gemm: HIP device query failed; using hipBLASEx\n");+ return nullptr;+ }+ std::string arch(properties.gcnArchName);+ const auto suffix = arch.find(':');+ if (suffix != std::string::npos) arch.resize(suffix);++ std::string error;+ if (!state->table.load(path, arch, version, error)) {+ std::fprintf(stderr, "prefill gemm: %s; using hipBLASEx\n", error.c_str());+ return nullptr;+ }+ std::fprintf(stderr, "prefill gemm: hipBLASLt tuning enabled (%zu rows, %s, version %d)\n",+ state->table.rows().size(), arch.c_str(), version);+ return state;+}++HipLtCachedAlgo resolve_hipblaslt_algo(HipLtState& state, strata::prefill::hipblaslt::InputType type, int t,+ int n, int k, int ldy, float beta) {+ uint32_t beta_bits = 0;+ static_assert(sizeof(beta_bits) == sizeof(beta));+ std::memcpy(&beta_bits, &beta, sizeof(beta));+ const HipLtCallKey key{type, t, n, k, ldy, beta_bits};+ const auto cached = state.cache.find(key);+ if (cached != state.cache.end()) return cached->second;++ HipLtCachedAlgo resolved;+ const bool verbose = std::getenv("STRATA_HIPBLASLT_VERBOSE") != nullptr;+ const auto* row = state.table.closest(type, n, k, ldy, t);+ if (!row) {+ if (verbose) {+ std::fprintf(stderr, "prefill gemm: Lt fallback; no calibration for dtype=%s T=%d N=%d K=%d ldy=%d\n",+ type == strata::prefill::hipblaslt::InputType::bf16 ? "bf16" : "f16", t, n, k, ldy);+ }+ return state.cache.emplace(key, resolved).first->second;+ }++ HipLtDescriptors desc;+ const hipDataType input_type = type == strata::prefill::hipblaslt::InputType::bf16 ? HIP_R_16BF : HIP_R_16F;+ if (!desc.init(input_type, t, n, k, ldy)) {+ return state.cache.emplace(key, resolved).first->second;+ }++ std::vector<int> solution_ids{row->solution_id};+ std::vector<hipblasLtMatmulHeuristicResult_t> candidates;+ if (hipblaslt_ext::getAlgosFromIndex(state.handle, solution_ids, candidates) != HIPBLAS_STATUS_SUCCESS ||+ candidates.empty() || candidates.front().state != HIPBLAS_STATUS_SUCCESS ||+ hipblaslt_ext::getIndexFromAlgo(candidates.front().algo) != row->solution_id) {+ if (verbose) {+ std::fprintf(stderr, "prefill gemm: Lt fallback; solution %d unavailable for T=%d N=%d K=%d ldy=%d\n",+ row->solution_id, t, n, k, ldy);+ }+ return state.cache.emplace(key, resolved).first->second;+ }++ const float alpha = 1.0f;+ size_t required_workspace = 0;+ auto algo = candidates.front().algo;+ if (hipblaslt_ext::matmulIsAlgoSupported(state.handle, desc.op, &alpha, desc.a, desc.b, &beta, desc.c, desc.c,+ algo, required_workspace) != HIPBLAS_STATUS_SUCCESS) {+ if (verbose) {+ std::fprintf(stderr, "prefill gemm: Lt fallback; solution %d rejects actual T=%d N=%d K=%d ldy=%d beta=%.9g\n",+ row->solution_id, t, n, k, ldy, beta);+ }+ return state.cache.emplace(key, resolved).first->second;+ }++ resolved.supported = true;+ resolved.algo = algo;+ resolved.workspace_bytes = required_workspace;+ if (verbose) {+ std::fprintf(stderr,+ "prefill gemm: Lt solution=%d dtype=%s T=%d N=%d K=%d ldy=%d beta=%.9g workspace=%zu\n",+ row->solution_id, type == strata::prefill::hipblaslt::InputType::bf16 ? "bf16" : "f16", t, n,+ k, ldy, beta, required_workspace);+ }+ return state.cache.emplace(key, resolved).first->second;+}++bool try_hipblaslt(void* opaque_state, strata::prefill::hipblaslt::InputType type, const uint16_t* x,+ const uint16_t* w, float* y, int64_t t, int64_t n, int64_t k, int64_t ldy, float beta,+ void* stream) {+ auto* state = static_cast<HipLtState*>(opaque_state);+ if (!state || t <= 0 || n <= 0 || k <= 0 || t > INT_MAX || n > INT_MAX || k > INT_MAX || ldy > INT_MAX ||+ ldy < n) {+ return false;+ }+ const auto resolved = resolve_hipblaslt_algo(*state, type, (int) t, (int) n, (int) k, (int) ldy, beta);+ if (!resolved.supported) {+ ++state->fallbacks;+ state->fallback_shapes.emplace(type, (int) t, (int) n, (int) k, (int) ldy);+ return false;+ }+ if (resolved.workspace_bytes > state->workspace_bytes) {+ ++state->fallbacks;+ state->fallback_shapes.emplace(type, (int) t, (int) n, (int) k, (int) ldy);+ if (std::getenv("STRATA_HIPBLASLT_VERBOSE")) {+ std::fprintf(stderr, "prefill gemm: Lt fallback; solution needs %zu workspace bytes, have %zu\n",+ resolved.workspace_bytes, state->workspace_bytes);+ }+ return false;+ }++ HipLtDescriptors desc;+ const hipDataType input_type = type == strata::prefill::hipblaslt::InputType::bf16 ? HIP_R_16BF : HIP_R_16F;+ if (!desc.init(input_type, (int) t, (int) n, (int) k, (int) ldy)) return false;+ const float alpha = 1.0f;+ const hipblasStatus_t status = hipblasLtMatmul(state->handle, desc.op, &alpha, w, desc.a, x, desc.b, &beta, y,+ desc.c, y, desc.c, &resolved.algo, state->workspace,+ state->workspace_bytes, (hipStream_t) stream);+ if (status == HIPBLAS_STATUS_SUCCESS) {+ ++state->lt_launches;+ return true;+ }++ std::fprintf(stderr, "prefill gemm: hipBLASLt launch failed with status %d\n", (int) status);+ if (beta != 0.0f) {+ std::fprintf(stderr, "prefill gemm: refusing a fallback after hipBLASLt failed with nonzero beta\n");+ std::exit(1);+ }+ auto* mutable_state = static_cast<HipLtState*>(opaque_state);+ uint32_t beta_bits = 0;+ std::memcpy(&beta_bits, &beta, sizeof(beta_bits));+ auto cached = mutable_state->cache.find(HipLtCallKey{type, (int) t, (int) n, (int) k, (int) ldy, beta_bits});+ if (cached != mutable_state->cache.end()) cached->second.supported = false;+ ++mutable_state->fallbacks;+ mutable_state->fallback_shapes.emplace(type, (int) t, (int) n, (int) k, (int) ldy);+ return false;+}+#endif+} // namespaceGemm::~Gemm() {+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+ delete static_cast<HipLtState*>(hipblaslt_state_);+#endifif (handle_) delete ((dpct::blas::descriptor_ptr)handle_);if (!external_) {if (scratch_) sycl::free(scratch_, dpct::get_in_order_queue());@@ -44,12 +298,15 @@ bool Gemm::init_external(void *stream, uint16_t *scratch, int64_t scratch_elems,h->set_queue(strata::q_of(stream));workspace_ = workspace;/*- DPCT1026:1144: The call to cublasSetWorkspace was removed because this+ DPCT1026: The call to cublasSetWorkspace was removed because thisfunctionality is redundant in SYCL.*/h->set_math_mode(dpct::blas::math_mode::mm_default);scratch_ = scratch;scratch_elems_ = scratch_elems;+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+ hipblaslt_state_ = create_hipblaslt_state(workspace_, ws_bytes).release();+#endifreturn true;}catch (sycl::exception const &exc) {@@ -63,9 +320,16 @@ void Gemm::rebind(uint16_t* scratch, int64_t scratch_elems, void* workspace, sizscratch_elems_ = scratch_elems;workspace_ = workspace;/*- DPCT1026:1145: The call to cublasSetWorkspace was removed because this+ DPCT1026: The call to cublasSetWorkspace was removed because thisfunctionality is redundant in SYCL.*/+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+ if (hipblaslt_state_) {+ auto* state = static_cast<HipLtState*>(hipblaslt_state_);+ state->workspace = workspace_;+ state->workspace_bytes = ws_bytes;+ }+#endif}bool Gemm::init(void *stream, int64_t scratch_elems, std::string &err) try {@@ -83,10 +347,13 @@ bool Gemm::init(void *stream, int64_t scratch_elems, std::string &err) try {err = "prefill gemm: workspace"; return false;}/*- DPCT1026:1146: The call to cublasSetWorkspace was removed because this+ DPCT1026: The call to cublasSetWorkspace was removed because thisfunctionality is redundant in SYCL.*/h->set_math_mode(dpct::blas::math_mode::mm_default);+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+ hipblaslt_state_ = create_hipblaslt_state(workspace_, ws).release();+#endifif (scratch_elems > 0 &&DPCT_CHECK_ERROR(scratch_ = (uint16_t *)sycl::malloc_device(@@ -108,6 +375,12 @@ void Gemm::bf16(const uint16_t* X, const uint16_t* W, float* Y, int64_t T, int64if (T <= 0 || N <= 0) return;if (ldy <= 0) ldy = N;const float alpha = 1.0f;+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+ if (try_hipblaslt(hipblaslt_state_, strata::prefill::hipblaslt::InputType::bf16, X, W, Y, T, N, K, ldy,+ beta, stream_)) {+ return;+ }+#endif// Column-major view: Y^T[N, T] = W[N, K] (stored K x N col-major, transposed) . X^T[K, T].ck(DPCT_CHECK_ERROR(dpct::blas::gemm((dpct::blas::descriptor_ptr)handle_, oneapi::mkl::transpose::trans,@@ -124,6 +397,12 @@ void Gemm::f16(const uint16_t* X, const uint16_t* W, float* Y, int64_t T, int64_if (T <= 0 || N <= 0) return;if (ldy <= 0) ldy = N;const float alpha = 1.0f;+#if defined(__HIPCC__) && defined(STRATA_HIPBLASLT_AVAILABLE)+ if (try_hipblaslt(hipblaslt_state_, strata::prefill::hipblaslt::InputType::f16, X, W, Y, T, N, K, ldy,+ beta, stream_)) {+ return;+ }+#endifck(DPCT_CHECK_ERROR(dpct::blas::gemm((dpct::blas::descriptor_ptr)handle_, oneapi::mkl::transpose::trans,oneapi::mkl::transpose::nontrans, (int)N, (int)T, (int)K, &alpha, W,diff --git a/sycl/src/prefill/ggml_cuda_host.dp.cpp b/sycl/src/prefill/ggml_cuda_host.dp.cppindex 480a6addd..257d17847 100644--- a/sycl/src/prefill/ggml_cuda_host.dp.cpp+++ b/sycl/src/prefill/ggml_cuda_host.dp.cpp@@ -35,24 +35,24 @@ const ggml_cuda_device_info & ggml_cuda_info() {DPCT_CHECK_ERROR(dpct::get_device(id).get_device_info(prop)));auto & d = in.devices[id];/*- DPCT1005:790: The SYCL device version is different from CUDA Compute+ DPCT1005: The SYCL device version is different from CUDA ComputeCompatibility. You may need to rewrite this code.*/d.cc =100 * prop.get_major_version() + 10 * prop.get_minor_version();d.nsm(prop.set_max_compute_units);/*- DPCT1019:791: local_mem_size in SYCL is not a complete equivalent of+ DPCT1019: local_mem_size in SYCL is not a complete equivalent ofsharedMemPerBlock in CUDA. You may need to adjust the code.*/d.smpb(prop.set_local_mem_size);/*- DPCT1019:792: local_mem_size in SYCL is not a complete equivalent of+ DPCT1019: local_mem_size in SYCL is not a complete equivalent ofsharedMemPerBlockOptin in CUDA. You may need to adjust the code.*/d.smpbo(prop.set_local_mem_size);/*- DPCT1006:793: SYCL does not provide a standard API to differentiate+ DPCT1006: SYCL does not provide a standard API to differentiatebetween integrated and discrete GPU devices.*/d.integrated = prop.get_integrated() != 0;diff --git a/sycl/src/prefill/kernels.dp.cpp b/sycl/src/prefill/kernels.dp.cppindex 17a4fe8f6..81c0523da 100644--- a/sycl/src/prefill/kernels.dp.cpp+++ b/sycl/src/prefill/kernels.dp.cpp@@ -21,7 +21,7 @@ constexpr int S = 128, HK = 16, HV = 48, C = 10240;__dpct_inline__ float warp_sum(float v) {#pragma unroll/*- DPCT1108:247: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -34,7 +34,7 @@ __dpct_inline__ float warp_sum(float v) {__dpct_inline__ float warp_max(float v) {#pragma unroll/*- DPCT1108:248: '__shfl_xor_sync' was migrated with the experimental feature+ DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -64,14 +64,14 @@ inline float block_sum(float v, float *sh) {w = item_ct1.get_local_id(2) >> 5;v = warp_sum(v);/*- DPCT1065:986: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/item_ct1.barrier();if (lane == 0) sh[w] = v;/*- DPCT1065:987: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -82,7 +82,7 @@ inline float block_sum(float v, float *sh) {if (w == 0) t = warp_sum(t);if (item_ct1.get_local_id(2) == 0) sh[0] = t;/*- DPCT1065:988: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -91,13 +91,13 @@ inline float block_sum(float v, float *sh) {}void check(const char* what) {/*- DPCT1010:989: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/const dpct::err0 e = 0;/*- DPCT1009:990: SYCL reports errors using exceptions and does not use error+ DPCT1009: SYCL reports errors using exceptions and does not use errorcodes. Please replace the "get_error_string_dummy(...)" with a realerror-handling function.*/@@ -127,6 +127,85 @@ auto &sh = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(xn16[row * N + d] = bf(v);}}+// F-1: the row scale only (and the BF16 image); gr_mix_r_kernel recomputes r * rs * w itself, in the same order,+// so the FP32 copy of the normalized rows (T x 10240 floats) is neither written nor read+__dpct_inline__ void gr_norm_rs_kernel(const float *__restrict__ R,+ const float *__restrict__ w, float eps,+ float *__restrict__ rs_out,+ uint16_t *__restrict__ xn16) {+ auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();+auto &sh = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(+ sycl::ext::oneapi::this_work_item::get_work_group<3>());+ const int64_t row = item_ct1.get_group(2); // t * 4 + c+ const int c = (int) (row % HC);+ const float* r = R + row * N;+ float ss = 0.0f;+#pragma unroll+ for (int d = item_ct1.get_local_id(2); d < N;+ d += item_ct1.get_local_range(2)) ss += r[d] * r[d];+ const float rs = sycl::rsqrt(block_sum(ss, sh) / (float)N + eps);+ if (item_ct1.get_local_id(2) == 0) rs_out[row] = rs;+#pragma unroll+ for (int d = item_ct1.get_local_id(2); d < N;+ d += item_ct1.get_local_range(2))+ xn16[row * N + d] = bf(r[d] * rs * w[c * N + d]);+}+__dpct_inline__ void+gr_mix_r_kernel(const float *__restrict__ R, const float *__restrict__ rs,+ const float *__restrict__ w, const float *__restrict__ g,+ float *__restrict__ mixed, uint16_t *__restrict__ mixed16,+ int64_t T, uint16_t *__restrict__ mixed_h) {+ auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();+ const int64_t i =+ (int64_t)item_ct1.get_group(2) * item_ct1.get_local_range(2) ++ item_ct1.get_local_id(2);+ if (i >= T * N) return;+ const int64_t t = i / N, d = i % N;+ float s = 0.0f;+#pragma unroll+ for (int c = 0; c < HC; ++c) {+ const int64_t j = t * D + c * N + d;+ const float x = R[j] * rs[t * HC + c] * w[c * N + d]; // gr_norm_kernel's value, bit for bit+ s = sycl::fma((float)x, sigm(g[j]), s);+ }+ s /= (float) HC;+ mixed[i] = s;+ if (mixed16) mixed16[i] = bf(s);+ if (mixed_h) mixed_h[i] = hf(s);+}+// F-2: gr_write_kernel for one row (t, c), then gr_norm_rs_kernel's reduction over it with the next half's norm+// weights - the same thread-to-element mapping (256 threads, stride 256) and block_sum, so rs and the BF16 image are+// the same bits, and R is not read back+constexpr int GRW_PER = (N + 255) / 256;+__dpct_inline__ void gr_write_norm_rs_kernel(+ float *__restrict__ R, const float *__restrict__ bo,+ const float *__restrict__ inj, int64_t inj_ld, const float *__restrict__ w,+ float eps, float *__restrict__ rs_out, uint16_t *__restrict__ xn16) {+ auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();+auto &sh = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(+ sycl::ext::oneapi::this_work_item::get_work_group<3>());+ const int64_t row = item_ct1.get_group(2); // t * 4 + c+ const int64_t t = row / HC;+ const int c = (int) (row % HC);+ float* r = R + row * N;+ const float sc = 2.0f * sigm(inj[t * inj_ld + c] / (float) HC);+ float v[GRW_PER];+ float ss = 0.0f;+ int k = 0;+#pragma unroll+ for (int d = item_ct1.get_local_id(2); d < N; d += 256, ++k) {+ const float x = sycl::fma((float)(bo[t * N + d]), (float)sc, r[d]);+ r[d] = x;+ v[k] = x;+ ss += x * x;+ }+ const float rs = sycl::rsqrt(block_sum(ss, sh) / (float)N + eps);+ if (item_ct1.get_local_id(2) == 0) rs_out[row] = rs;+ k = 0;+#pragma unroll+ for (int d = item_ct1.get_local_id(2); d < N; d += 256, ++k)+ xn16[row * N + d] = bf(v[k] * rs * w[c * N + d]);+}__dpct_inline__ void gr_silu_kernel(const float *__restrict__ lo,uint16_t *__restrict__ lo16, int64_t n) {auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();@@ -271,7 +350,7 @@ __dpct_inline__ void gdn_l2_kernel(float *__restrict__ h, float eps) {if ((item_ct1.get_local_id(2) & 31) == 0)part[item_ct1.get_local_id(2) >> 5] = sq;/*- DPCT1065:991: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -281,7 +360,7 @@ __dpct_inline__ void gdn_l2_kernel(float *__restrict__ h, float eps) {}constexpr int RG = 4, RPG = S / RG;/*-DPCT1110:249: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongdn_rec_kernel exceeds 128 bytes and may cause high register pressure. Consultwith your hardware vendor to find the total register size available and adjustthe code, or use smaller sub-group size to avoid high register pressure.@@ -315,22 +394,22 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(for (int64_t t = 0; t < T; ++t) {const float* ht = h + t * C;/*- DPCT1118:250: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:992: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier();if (tid < S) { sq[tid] = ht[qh * S + tid]; sk[tid] = ht[HK * S + qh * S + tid]; }/*- DPCT1118:251: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:993: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -342,11 +421,11 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(kv = sycl::fma(s[r], sk[rg * RPG + r], kv);red[rg][col] = kv;/*- DPCT1118:252: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:994: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -360,22 +439,22 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(o = sycl::fma(s[r], sq[rg * RPG + r], o);}/*- DPCT1118:253: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:995: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier();red[rg][col] = o;/*- DPCT1118:254: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:996: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -389,11 +468,11 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(sp = warp_sum(sp);if ((tid & 31) == 0) wsum[tid >> 5] = sp;/*- DPCT1118:255: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:997: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -416,7 +495,7 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(// red[0] + red[1] + red[2] + red[3]; the norm's warp sums over the same 32-column warps): the same bits.constexpr int CB = 32, NCB = S / CB;/*-DPCT1110:256: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functiongdn_rec_cols_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -448,22 +527,22 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(for (int64_t t = 0; t < T; ++t) {const float* ht = h + t * C;/*- DPCT1118:257: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:998: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier();if (tid < S) { sq[tid] = ht[qh * S + tid]; sk[tid] = ht[HK * S + qh * S + tid]; }/*- DPCT1118:258: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:999: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -475,11 +554,11 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(kv = sycl::fma(s[r], sk[rg * RPG + r], kv);red[rg][c] = kv;/*- DPCT1118:259: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:1000: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -493,22 +572,22 @@ auto &sk = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[S]>(o = sycl::fma(s[r], sq[rg * RPG + r], o);}/*- DPCT1118:260: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:1001: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/item_ct1.barrier();red[rg][c] = o;/*- DPCT1118:261: SYCL group functions and algorithms must be encountered in+ DPCT1118: SYCL group functions and algorithms must be encountered inconverged control flow. You may need to adjust the code.*//*- DPCT1065:1002: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) forbetter performance if there is no access to global memory.*/@@ -534,7 +613,7 @@ auto &wsum = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[4]>(float sp = warp_sum(oc * oc);if ((col & 31) == 0) wsum[col >> 5] = sp;/*- DPCT1065:1003: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -549,7 +628,7 @@ auto &wsum = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[4]>(// ---------------------------------------------------------------- MoEtemplate <int REG>/*-DPCT1110:264: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionroute_kernel exceeds 128 bytes and may cause high register pressure. Consultwith your hardware vendor to find the total register size available and adjustthe code, or use smaller sub-group size to avoid high register pressure.@@ -590,7 +669,7 @@ __dpct_inline__ void route_kernel(const float *__restrict__ logits,#pragma unrollfor (int m = 16; m; m >>= 1) {/*- DPCT1108:262: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -598,7 +677,7 @@ __dpct_inline__ void route_kernel(const float *__restrict__ logits,0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),best, m);/*- DPCT1108:263: '__shfl_xor_sync' was migrated with the experimental+ DPCT1108: '__shfl_xor_sync' was migrated with the experimentalfeature masked sub_group function which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -617,7 +696,7 @@ __dpct_inline__ void route_kernel(const float *__restrict__ logits,// Strata blob: gate/up codes [1280][640 B], down codes [2560][160 B], gate/up scales [1280][40] f16, down scales [2560][10] f16template <bool HALF>/*-DPCT1110:265: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionblob_dequant_kernel exceeds 128 bytes and may cause high register pressure.Consult with your hardware vendor to find the total register size available andadjust the code, or use smaller sub-group size to avoid high register pressure.@@ -727,7 +806,7 @@ auto &sh = *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(c += item_ct1.get_local_range(2)) ss += r[c] * r[c];const float s = sycl::rsqrt(block_sum(ss, sh) / (float)cols + eps);/*- DPCT1065:1004: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -805,7 +884,7 @@ kv_append_kernel(const float *__restrict__ K, const float *__restrict__ V,}float a = sycl::fabs(x);/*-DPCT1108:266: '__shfl_xor_sync' was migrated with the experimental feature+DPCT1108: '__shfl_xor_sync' was migrated with the experimental featuremasked sub_group function which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -819,7 +898,7 @@ runtimes. You may need to adjust the code.if ((item_ct1.get_local_id(2) & 31) == 0)wm[item_ct1.get_local_id(2) >> 5] = a;/*- DPCT1065:1005: Consider replacing sycl::nd_item::barrier() with+ DPCT1065: Consider replacing sycl::nd_item::barrier() withsycl::nd_item::barrier(sycl::access::fence_space::local_space) for betterperformance if there is no access to global memory.*/@@ -908,7 +987,7 @@ void kv_append(const float* K, const float* V, int64_t T, int64_t pos0, const instage ? *stage : strata::kernels::KvHostPools{};cgh.parallel_for<- dpct_kernel_name<class kv_append_kernel_7ad9e6>>(+ dpct_kernel_name<class kv_append_kernel_c8a7c1>>(sycl::nd_range<3>(sycl::range(8, 2, (unsigned)T) *sycl::range(1, 1, 64),sycl::range(1, 1, 64)),@@ -932,7 +1011,7 @@ void to_f16(const float* x, uint16_t* y, int64_t n, void* stream) {sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class to_f16_kernel_a5739f>>(+ ->parallel_for<dpct_kernel_name<class to_f16_kernel_286314>>(sycl::nd_range<3>(sycl::range(1, 1,(unsigned)((n + 255) / 256 < 4096? (n + 255) / 256@@ -952,7 +1031,7 @@ void round_f16(const float* x, float* y, int64_t n, void* stream) {sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class round_f16_kernel_52fbb2>>(+ ->parallel_for<dpct_kernel_name<class round_f16_kernel_3fea66>>(sycl::nd_range<3>(sycl::range(1, 1,(unsigned)((n + 255) / 256 < 4096? (n + 255) / 256@@ -972,7 +1051,7 @@ void to_bf16(const float* x, uint16_t* y, int64_t n, void* stream) {sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class to_bf16_kernel_265df0>>(+ ->parallel_for<dpct_kernel_name<class to_bf16_kernel_b87029>>(sycl::nd_range<3>(sycl::range(1, 1,(unsigned)((n + 255) / 256 < 4096? (n + 255) / 256@@ -992,7 +1071,7 @@ void gr_norm(const float* R, const float* w_norm, float eps, float* xn, uint16_tsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gr_norm_kernel_f823fa>>(+ ->parallel_for<dpct_kernel_name<class gr_norm_kernel_7ac11f>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)(T * HC)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1004,6 +1083,63 @@ void gr_norm(const float* R, const float* w_norm, float eps, float* xn, uint16_t}check("gr_norm");}+void gr_norm_rs(const float* R, const float* w_norm, float eps, float* rs, uint16_t* xn16, int64_t T, void* stream) {+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};++ strata::q_of(stream)+ ->parallel_for<dpct_kernel_name<class gr_norm_rs_kernel_44cb02>>(+ sycl::nd_range<3>(sycl::range(1, 1, (unsigned)(T * HC)) *+ sycl::range(1, 1, 256),+ sycl::range(1, 1, 256)),+ exp_props,+ [=](sycl::nd_item<3> item_ct1)+ [[sycl::reqd_sub_group_size(32)]] {+ gr_norm_rs_kernel(R, w_norm, eps, rs, xn16);+ });+ }+ check("gr_norm_rs");+}+void gr_mix_r(const float* R, const float* rs, const float* w_norm, const float* gated, float* mixed, uint16_t* mixed16,+ int64_t T, void* stream, uint16_t* mixed_h) {+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};++ strata::q_of(stream)+ ->parallel_for<dpct_kernel_name<class gr_mix_r_kernel_c2a1de>>(+ sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * N)) *+ sycl::range(1, 1, 256),+ sycl::range(1, 1, 256)),+ exp_props, [=](sycl::nd_item<3> item_ct1) {+ gr_mix_r_kernel(R, rs, w_norm, gated, mixed, mixed16, T,+ mixed_h);+ });+ }+ check("gr_mix_r");+}+void gr_write_norm_rs(float* R, const float* bo, const float* inj, int64_t inj_ld, const float* w_norm_next, float eps,+ float* rs, uint16_t* xn16, int64_t T, void* stream) {+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};++ strata::q_of(stream)+ ->parallel_for<+ dpct_kernel_name<class gr_write_norm_rs_kernel_d03793>>(+ sycl::nd_range<3>(sycl::range(1, 1, (unsigned)(T * HC)) *+ sycl::range(1, 1, 256),+ sycl::range(1, 1, 256)),+ exp_props,+ [=](sycl::nd_item<3> item_ct1)+ [[sycl::reqd_sub_group_size(32)]] {+ gr_write_norm_rs_kernel(R, bo, inj, inj_ld, w_norm_next,+ eps, rs, xn16);+ });+ }+ check("gr_write_norm_rs");+}void gr_silu(const float* lo, uint16_t* lo16, int64_t T, void* stream) {{auto exp_props = sycl::ext::oneapi::experimental::properties{@@ -1013,7 +1149,7 @@ void gr_silu(const float* lo, uint16_t* lo16, int64_t T, void* stream) {->submit([&](sycl::handler &cgh) {auto T_LR_ct2 = T * LR;- cgh.parallel_for<dpct_kernel_name<class gr_silu_kernel_73e336>>(+ cgh.parallel_for<dpct_kernel_name<class gr_silu_kernel_61274c>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * LR)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1031,7 +1167,7 @@ void gr_mix(const float* xn, const float* gated, float* mixed, uint16_t* mixed16sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gr_mix_kernel_97138e>>(+ ->parallel_for<dpct_kernel_name<class gr_mix_kernel_9ba6d6>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * N)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1047,7 +1183,7 @@ void gr_write(float* R, const float* bo, const float* inj, int64_t inj_ld, int64sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gr_write_kernel_b029eb>>(+ ->parallel_for<dpct_kernel_name<class gr_write_kernel_24cfed>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * D)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1063,7 +1199,7 @@ void gr_broadcast(const float* e, float* R, int64_t T, void* stream) {sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gr_broadcast_kernel_a3b6f7>>(+ ->parallel_for<dpct_kernel_name<class gr_broadcast_kernel_73ae1d>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * D)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1079,7 +1215,7 @@ void gdn_gates(const float* ab, const float* dt, const float* ssm_a, float* gatesycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gdn_gates_kernel_7a43f1>>(+ ->parallel_for<dpct_kernel_name<class gdn_gates_kernel_850222>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * HV)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1096,7 +1232,7 @@ void gdn_conv(float* history, const float* qkv, const float* conv_w, float* h, isycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gdn_conv_kernel_2ae161>>(+ ->parallel_for<dpct_kernel_name<class gdn_conv_kernel_8fa65c>>(sycl::nd_range<3>(sycl::range(1, 1, C / 128) *sycl::range(1, 1, 128),sycl::range(1, 1, 128)),@@ -1110,7 +1246,7 @@ void gdn_conv(float* history, const float* qkv, const float* conv_w, float* h, istrata::q_of(stream)->parallel_for<- dpct_kernel_name<class gdn_conv_tiled_kernel_f8dcbd>>(+ dpct_kernel_name<class gdn_conv_tiled_kernel_915839>>(sycl::nd_range<3>(sycl::range(1,(unsigned)((T + CONV_TILE - 1) / CONV_TILE),@@ -1127,7 +1263,7 @@ void gdn_conv(float* history, const float* qkv, const float* conv_w, float* h, istrata::q_of(stream)->parallel_for<- dpct_kernel_name<class gdn_conv_hist_kernel_e10b4d>>(+ dpct_kernel_name<class gdn_conv_hist_kernel_1d17e3>>(sycl::nd_range<3>(sycl::range(1, 1, C / 128) *sycl::range(1, 1, 128),sycl::range(1, 1, 128)),@@ -1141,7 +1277,7 @@ void gdn_conv(float* history, const float* qkv, const float* conv_w, float* h, isycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gdn_l2_kernel_502355>>(+ ->parallel_for<dpct_kernel_name<class gdn_l2_kernel_877aa1>>(sycl::nd_range<3>(sycl::range(1, (unsigned)T, 2 * HK) *sycl::range(1, 1, S),sycl::range(1, 1, S)),@@ -1158,7 +1294,7 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const floatstatic const bool serial = std::getenv("STRATA_GDN_REC_HEADS") != nullptr; // the one-block-per-head kernel (A/B)if (serial || T <= 0) {/*- DPCT1049:267: The work-group size passed to the SYCL kernel may exceed+ DPCT1049: The work-group size passed to the SYCL kernel may exceedthe limit. To get the device limit, queryinfo::device::max_work_group_size. Adjust the work-group size if needed.*/@@ -1166,7 +1302,7 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const floatsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gdn_rec_kernel_8121c8>>(+ ->parallel_for<dpct_kernel_name<class gdn_rec_kernel_6a2bf0>>(sycl::nd_range<3>(sycl::range(1, 1, HV) * sycl::range(1, RG, S),sycl::range(1, RG, S)),exp_props,@@ -1182,7 +1318,7 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const floatstrata::q_of(stream)->parallel_for<- dpct_kernel_name<class gdn_rec_cols_kernel_fedac7>>(+ dpct_kernel_name<class gdn_rec_cols_kernel_64239d>>(sycl::nd_range<3>(sycl::range(1, 1, HV * NCB) *sycl::range(1, RG, CB),sycl::range(1, RG, CB)),@@ -1196,7 +1332,7 @@ void gdn_recurrence(float* state, const float* h, const float* gate, const floatstrata::q_of(stream)->parallel_for<- dpct_kernel_name<class gdn_out_norm_kernel_f960df>>(+ dpct_kernel_name<class gdn_out_norm_kernel_237731>>(sycl::nd_range<3>(sycl::range(1, HV, (unsigned)T) *sycl::range(1, 1, S),sycl::range(1, 1, S)),@@ -1216,7 +1352,7 @@ void route(const float* logits, int32_t* ids, float* weights, int64_t T, int64_tsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class route_kernel_f2ae57,+ ->parallel_for<dpct_kernel_name<class route_kernel_a33365,dpct_kernel_scalar<16>>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)((T + 7) / 8)) *sycl::range(1, 1, 256),@@ -1232,7 +1368,7 @@ void route(const float* logits, int32_t* ids, float* weights, int64_t T, int64_tsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class route_kernel_687f3a,+ ->parallel_for<dpct_kernel_name<class route_kernel_f9493d,dpct_kernel_scalar<8>>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)((T + 7) / 8)) *sycl::range(1, 1, 256),@@ -1252,7 +1388,7 @@ void blob_dequant(const uint8_t* blob, uint16_t* gu16, uint16_t* down16, void* ssycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class blob_dequant_kernel_b87029,+ ->parallel_for<dpct_kernel_name<class blob_dequant_kernel_1db2df,dpct_kernel_scalar<false>>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(1280LL * 640 + 2560LL * 160)) *@@ -1270,7 +1406,7 @@ void blob_dequant_f16(const uint8_t* blob, uint16_t* gu16, uint16_t* down16, voisycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class blob_dequant_kernel_3b1437,+ ->parallel_for<dpct_kernel_name<class blob_dequant_kernel_ee9bfb,dpct_kernel_scalar<true>>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(1280LL * 640 + 2560LL * 160)) *@@ -1289,7 +1425,7 @@ void swiglu_interleaved(const float* gu, uint16_t* h16, int64_t n, void* stream)sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class swiglu_il_kernel_44cb02>>(+ ->parallel_for<dpct_kernel_name<class swiglu_il_kernel_458d6e>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(n * 640)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1305,7 +1441,7 @@ void swiglu_pair(const float* g, const float* u, uint16_t* h16, int64_t n, void*sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class swiglu_pair_kernel_f34a2f>>(+ ->parallel_for<dpct_kernel_name<class swiglu_pair_kernel_ddbac5>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(n * 640)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1315,6 +1451,39 @@ void swiglu_pair(const float* g, const float* u, uint16_t* h16, int64_t n, void*}check("swiglu_pair");}+namespace {+__dpct_inline__ void copy_i32_kernel(int32_t *__restrict__ dst,+ const int32_t *__restrict__ src,+ int64_t n) {+ auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();+#pragma unroll+ for (int64_t i =+ (int64_t)item_ct1.get_group(2) * item_ct1.get_local_range(2) ++ item_ct1.get_local_id(2);+ i < n; i += (int64_t)item_ct1.get_group_range(2) *+ item_ct1.get_local_range(2))+ dst[i] = src[i];+}+} // namespace+void copy_i32(int32_t* dst, const int32_t* src, int64_t n, void* stream) {+ if (n <= 0) return;+ const int64_t b = (n + 255) / 256;+ {+ auto exp_props = sycl::ext::oneapi::experimental::properties{+ sycl::ext::oneapi::experimental::use_root_sync};++ strata::q_of(stream)+ ->parallel_for<dpct_kernel_name<class copy_i32_kernel_7676d1>>(+ sycl::nd_range<3>(+ sycl::range(1, 1, (unsigned)(b < 256 ? b : 256)) *+ sycl::range(1, 1, 256),+ sycl::range(1, 1, 256)),+ exp_props, [=](sycl::nd_item<3> item_ct1) {+ copy_i32_kernel(dst, src, n);+ });+ }+ check("copy_i32");+}void gather_rows16(const uint16_t* x16, const int32_t* src, uint16_t* dst16, int64_t n, int64_t width, void* stream) {if (n <= 0) return;{@@ -1322,7 +1491,7 @@ void gather_rows16(const uint16_t* x16, const int32_t* src, uint16_t* dst16, intsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gather_rows16_kernel_db6b85>>(+ ->parallel_for<dpct_kernel_name<class gather_rows16_kernel_225b7e>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(n * (width / 8))) *sycl::range(1, 1, 256),@@ -1340,7 +1509,7 @@ void moe_combine(const float* Dm, const int32_t* slot, const float* w, const flosycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class moe_combine_kernel_b1df11>>(+ ->parallel_for<dpct_kernel_name<class moe_combine_kernel_d82250>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * N)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1357,7 +1526,7 @@ void rms_rows(float* x, const float* w, int64_t rows, int64_t cols, int64_t ld,sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class rms_rows_kernel_38561f>>(+ ->parallel_for<dpct_kernel_name<class rms_rows_kernel_c94646>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)rows) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1380,7 +1549,7 @@ void rope(float* x, int64_t T, int64_t heads, int64_t dim, int64_t ld, int64_t pauto strata_kernels_mrope_table_ct6 =strata::kernels::mrope_table();- cgh.parallel_for<dpct_kernel_name<class rope_kernel_fa611b>>(+ cgh.parallel_for<dpct_kernel_name<class rope_kernel_dccc17>>(sycl::nd_range<3>(sycl::range(1, 1, (unsigned)(T * heads)) *sycl::range(1, 1, 32),sycl::range(1, 1, 32)),@@ -1398,7 +1567,7 @@ void split_q(const float* q_full, float* q, int64_t T, void* stream) {sycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class split_q_kernel_fdb2a0>>(+ ->parallel_for<dpct_kernel_name<class split_q_kernel_d499e3>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * 24 * 256)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),@@ -1414,7 +1583,7 @@ void gate_attn(const float* attn, const float* q_full, uint16_t* out16, int64_tsycl::ext::oneapi::experimental::use_root_sync};strata::q_of(stream)- ->parallel_for<dpct_kernel_name<class gate_attn_kernel_ee0b52>>(+ ->parallel_for<dpct_kernel_name<class gate_attn_kernel_f391fd>>(sycl::nd_range<3>(sycl::range(1, 1, blocks_for(T * 24 * 256)) *sycl::range(1, 1, 256),sycl::range(1, 1, 256)),diff --git a/sycl/src/prefill/moe_mmq.dp.cpp b/sycl/src/prefill/moe_mmq.dp.cppindex 3f5f31fb7..bf74e77b9 100644--- a/sycl/src/prefill/moe_mmq.dp.cpp+++ b/sycl/src/prefill/moe_mmq.dp.cpp@@ -55,7 +55,7 @@ __dpct_inline__ void copy1_kernel(const uint8_t *__restrict__ a, int64_t na,// [2560][10] f16 (the layout of prefill/kernels.cu's blob_dequant_kernel). A GGUF Q2_0 block is {f16 d; 16 code// bytes} with the same 2-bit codes in the same order, so a block is a scale and a 16-byte run of codes./*-DPCT1110:182: The total declared local variable size in device function+DPCT1110: The total declared local variable size in device functionstrata_q2_kernel exceeds 128 bytes and may cause high register pressure. Consultwith your hardware vendor to find the total register size available and adjustthe code, or use smaller sub-group size to avoid high register pressure.@@ -145,7 +145,7 @@ void quantize(const float* x, const int32_t* ids, void* xq, int t, int64_t cols,quantize_mmq_q8_1_cuda(x, ids, xq, (ggml_type) t, cols, ld, rows * ld, rows * ld, pad512(cols), rows, 1, 1,(cudaStream_t) stream);/*- DPCT1010:865: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -184,7 +184,7 @@ void Context::run(const Product& p, void* stream) {std::exit(1);}/*- DPCT1010:866: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -231,7 +231,7 @@ void gather_native(const void* gate, const void* up, size_t gu_half_bytes, const}}/*- DPCT1010:867: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -255,7 +255,7 @@ void gather_strata_q2(const uint8_t* blob, void* gu_dst, void* d_dst, void* stre});}/*- DPCT1010:868: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -278,7 +278,7 @@ void swiglu(const float* gu, float* h, int64_t rows, int64_t n_ff, bool interlea});}/*- DPCT1010:869: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/@@ -301,7 +301,7 @@ void iota(int32_t* dst, int64_t n, void* stream) {});}/*- DPCT1010:870: SYCL uses exceptions to report errors and does not use the+ DPCT1010: SYCL uses exceptions to report errors and does not use theerror codes. The cudaGetLastError function call was replaced with 0. Youneed to rewrite this code.*/diff --git a/sycl/src/prefill/prefill.cpp b/sycl/src/prefill/prefill.cppindex aee620fe7..b9d04cb28 100644--- a/sycl/src/prefill/prefill.cpp+++ b/sycl/src/prefill/prefill.cpp@@ -4,6 +4,7 @@#include <dpct/dpct.hpp>#include "strata/sycl_queue.hpp"#include "strata/prefill/prefill.hpp"+#include "strata/core/mtp.hpp"#include "strata/core/progress.hpp"#include "strata/core/on_device.hpp"@@ -88,6 +89,12 @@ inline int ring_slots(size_t T) {}constexpr int DQ = 2; // dequantized-expert ring (FP16 gate/up + down)+// F-1: STRATA_GR_UNFUSED=1 keeps the FP32 copy of the normalized rows (gr_norm + gr_mix), the A/B arm+inline bool gr_unfused() {+ static const bool v = [] { const char* e = std::getenv("STRATA_GR_UNFUSED"); return e && e[0] == '1'; }();+ return v;+}+double ms_since(Clock::time_point t) { return std::chrono::duration<double, std::milli>(Clock::now() - t).count(); }// Either cudaMalloc (owned, freed with the object) or a bump allocation from a borrowed region; with no base and@@ -160,7 +167,7 @@ struct Stager {pageable.resize(kRing);for (int i = 0; i < kRing; ++i) {/*- DPCT1048:14: The original value cudaHostAllocDefault is not+ DPCT1048: The original value cudaHostAllocDefault is notmeaningful in the migrated code and was removed or replaced with 0.You may need to check the migrated code.*/@@ -169,7 +176,7 @@ struct Stager {blob_bytes, dpct::get_in_order_queue())) == 0;if (!pinned[i]) {/*- DPCT1026:1009: The call to cudaGetLastError was removed because+ DPCT1026: The call to cudaGetLastError was removed becausethis functionality is redundant in SYCL.*/pageable[(size_t)i].resize(blob_bytes);@@ -195,7 +202,7 @@ struct Stager {}void work() {/*- DPCT1093:1010: The "device" device may be not the one intended for use.+ DPCT1093: The "device" device may be not the one intended for use.Adjust the selected device if needed.*/dpct::select_device(device);@@ -279,6 +286,7 @@ struct Prefill::Impl {std::vector<void*> owned;// chunk buffersfloat *emb = nullptr, *R = nullptr, *xn = nullptr, *lo = nullptr, *gated = nullptr, *inj = nullptr;+ float* grs = nullptr; // F-1: the hyper-connection read's row scales (T x 4)uint16_t *xn16 = nullptr, *lo16 = nullptr;float* mixed = nullptr;uint16_t *mixed_bf = nullptr, *mixed_h = nullptr;@@ -310,6 +318,13 @@ struct Prefill::Impl {std::vector<int32_t> bounds_host;std::unique_ptr<mmq::Context> mmq_ctx;std::vector<int32_t> ids_host, slot_host, src_host, cnt, off;+ // The grouping tables in mapped pinned memory, [ids | slot | src] of T_max * K each, then the MMQ bounds: kernels+ // read and write them in place. A cudaMemcpyAsync of them queues behind the expert blobs the copy stream already+ // holds (up to `ring` of them, ~70 us each), and the GPU idles meanwhile - measured 4.2 s of a 128K prompt's+ // 70 s at the default ring, 0.7 s with a 16-slot one. STRATA_GROUP_COPY=1: the copies (the A/B arm).+ int32_t* grp_host = nullptr;+ int32_t* grp_dev = nullptr; // its device alias+ size_t grp_n = 0, grp_tk = 0; // int32s allocated; T_max * K (the offset of slot, and of src past it)uint16_t* dq_gu[DQ] = {};uint16_t* dq_d[DQ] = {};uint8_t* stage_dev[RING_MAX] = {};@@ -380,6 +395,7 @@ Prefill::Prefill() : impl_(new Impl) {}Prefill::~Prefill() {if (!impl_) return;if (impl_->cs) impl_->cs->wait();+ if (impl_->copy) impl_->copy->wait();for (int i = 0; i < RING_MAX; ++i) {if (impl_->copied[i]) dpct::destroy_event(impl_->copied[i]);if (impl_->used[i]) dpct::destroy_event(impl_->used[i]);@@ -392,6 +408,8 @@ Prefill::~Prefill() {sycl::free(impl_->ple_emb_host[b], dpct::get_in_order_queue());}if (impl_->copy) dpct::get_current_device().destroy_queue(impl_->copy);+ if (impl_->grp_host)+ sycl::free(impl_->grp_host, dpct::get_in_order_queue());for (void *p : impl_->owned)DPCT_CHECK_ERROR(sycl::free(p, dpct::get_in_order_queue()));}@@ -493,7 +511,7 @@ bool Prefill::init(const core::WeightTable &wt, const core::ModelGeometry &g,}for (int b = 0; next_ != nullptr && b < 2; ++b)/*- DPCT1048:15: The original value cudaHostAllocPortable is not meaningful+ DPCT1048: The original value cudaHostAllocPortable is not meaningfulin the migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -515,7 +533,7 @@ bool Prefill::init(const core::WeightTable &wt, const core::ModelGeometry &g,m.tok_host.resize((size_t) chunk);}/*- DPCT1025:1011: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (DPCT_CHECK_ERROR(@@ -540,10 +558,40 @@ bool Prefill::init(const core::WeightTable &wt, const core::ModelGeometry &g,}m.steps_host.resize(T * strata::kernels::kStepCount);m.ids_host.resize(T * K); m.slot_host.resize(T * K); m.src_host.resize(T * K); m.cnt.resize(m.g->n_expert); m.off.resize(m.g->n_expert + 1);+ {+ const size_t need = 3 * T * K + (size_t) (2 * (m.g->n_expert + m.g->n_expert / MMQ_GROUP + 2));+ const char* gc = std::getenv("STRATA_GROUP_COPY");+ if (m.grp_n < need && !(gc && gc[0] == '1')) {+ if (m.grp_host) sycl::free(m.grp_host, dpct::get_in_order_queue());+ m.grp_host = m.grp_dev = nullptr;+ m.grp_n = m.grp_tk = 0;+ void *h = nullptr, *d = nullptr;+ /*+ DPCT1048: The original value cudaHostAllocMapped is not+ meaningful in the migrated code and was removed or replaced with 0.+ You may need to check the migrated code.+ */+ if (DPCT_CHECK_ERROR(h = (void *)sycl::malloc_host(+ need * 4, dpct::get_in_order_queue())) ==+ 0 &&+ DPCT_CHECK_ERROR(d = (void *)h) == 0) {+ m.grp_host = (int32_t*) h;+ m.grp_dev = (int32_t*) d;+ m.grp_n = need;+ m.grp_tk = T * K;+ } else { // the copies, as before+ if (h) sycl::free(h, dpct::get_in_order_queue());+ /*+ DPCT1026: The call to cudaGetLastError was removed because+ this functionality is redundant in SYCL.+ */+ }+ }+ }for (int b = 0; b < 2; ++b) {if (!m.ple_emb_host[b] &&/*- DPCT1048:16: The original value cudaHostAllocDefault is not+ DPCT1048: The original value cudaHostAllocDefault is notmeaningful in the migrated code and was removed or replaced with 0.You may need to check the migrated code.*/@@ -551,7 +599,7 @@ bool Prefill::init(const core::WeightTable &wt, const core::ModelGeometry &g,m.ple_emb_host[b] = (float *)sycl::malloc_host((size_t)T * N * 4, dpct::get_in_order_queue())) != 0) {/*- DPCT1026:1012: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/m.ple_pageable[b].resize(@@ -571,7 +619,7 @@ bool Prefill::init(const core::WeightTable &wt, const core::ModelGeometry &g,m.ident_table = (int32_t *)sycl::malloc_device(ident.size() * 4, dpct::get_in_order_queue())) != 0 ||/*- DPCT1114:1013: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -613,7 +661,9 @@ bool Prefill::carve(size_t T, void* alloc) {const core::ModelGeometry& g = *m.g;core::SessionState& ss = *m.ss;bool ok = true;- m.emb = o.take<float>(T * N, ok); m.R = o.take<float>(T * D, ok); m.xn = o.take<float>(T * D, ok);+ m.emb = o.take<float>(T * N, ok); m.R = o.take<float>(T * D, ok);+ m.xn = gr_unfused() ? o.take<float>(T * D, ok) : nullptr; // F-1: not needed (gr_mix_r reads R)+ m.grs = o.take<float>(T * HC, ok);m.xn16 = o.take<uint16_t>(T * D, ok); m.lo = o.take<float>(T * LR, ok); m.lo16 = o.take<uint16_t>(T * LR, ok);m.gated = o.take<float>(T * D, ok); m.inj = o.take<float>(T * HC, ok);m.mixed = o.take<float>(T * N, ok); m.mixed_bf = o.take<uint16_t>(T * N, ok);@@ -718,6 +768,181 @@ catch (sycl::exception const &exc) {}int64_t Prefill::chunk() const { return impl_->T; }++bool Prefill::draft_kv(core::MtpDrafter& mtp, const float* R_rows, const int32_t* next_tokens, int64_t n, int64_t cell0,+ std::string& err) {+ Impl& m = *impl_;+ static const bool off = [] { const char* v = std::getenv("STRATA_MTP_BATCH"); return v != nullptr && v[0] == '0'; }();+ core::QsaState& st = mtp.kv_state_rw();+ if (off || n <= 0 || m.g == nullptr || m.region == nullptr || st.kv_mode != 0 || st.kv_hybrid ||+ mtp.device() != m.device)+ return false;+ const auto t0 = Clock::now();+ const core::ModelGeometry& g = *m.g;+ const int64_t Nn = g.n_embd, HCN = g.hc * g.n_embd, KV = g.n_head_kv * g.head_dim;+ constexpr int kQ8_0 = 8; // GGML_TYPE_Q8_0+ const float* w_ne = mtp.tensor_f32("pre_fc_norm_embedding.weight");+ const void* w_fe = mtp.tensor_q8("fc_embedding.weight");+ const float* w_nh = mtp.tensor_f32("pre_fc_norm_hidden.weight");+ const void* w_fh = mtp.tensor_q8("fc_hidden.weight");+ const float* w_hn = mtp.tensor_f32("attn_hyper_connection.hc_norm.weight");+ const uint16_t* w_dn = mtp.tensor_bf16("attn_hyper_connection.input_mix_weight_down.weight");+ const uint16_t* w_up = mtp.tensor_bf16("attn_hyper_connection.input_mix_weight_up.weight");+ const void* w_k = mtp.tensor_q8("self_attn.k_proj.weight");+ const void* w_v = mtp.tensor_q8("self_attn.v_proj.weight");+ const float* w_kn = mtp.tensor_f32("self_attn.k_norm.weight");+ if (!w_ne || !w_fe || !w_nh || !w_fh || !w_hn || !w_dn || !w_up || !w_k || !w_v || !w_kn) return false;+ const core::NativeEmbed* nemb = core::native_embed();+ const core::WeightRef* wemb = nemb ? nullptr : m.wt->find("token_embd.weight");+ if (!nemb && (wemb == nullptr || wemb->codebook_iq4nl || wemb->ne0 != g.n_embd || wemb->group_elems <= 0 ||+ (wemb->code_bits != 2 && wemb->code_bits != 4 && wemb->code_bits != 8)))+ return false;+ // the cells the drafter's window can still reach+ const int64_t r0 = std::max<int64_t>(0, mtp.first_needed() - cell0);+ if (r0 >= n) return true;+ // per row: emb/e2 (N), en16 (N half), hn/h2/Rm/gated (HCN), hn16/xn16 (HCN half), lo (LR) + lo16, grs, mixed (N) ++ // mixed_h, K and V (KV each), the token id+ // E-9: the drafter's Q8_0 matrices through Q8_1 x Q8_0 MMQ - its own pass's integer dot products (mmvq), so+ // its K/V stay close to what the drafter computes itself; STRATA_MTP_BATCH_F16=1: FP16 GEMMs (the A/B)+ static const bool f16_only = [] { const char* v = std::getenv("STRATA_MTP_BATCH_F16"); return v && v[0] == '1'; }();+ const bool q8 = !f16_only && mmq::built() && mmq::supported(kQ8_0);+ const uint64_t per_row = 4 * (2 * Nn + 4 * HCN + LR + HC + Nn + 2 * KV + 1) + 2 * (Nn + 2 * HCN + LR + Nn) + 64 ++ (q8 ? (uint64_t) mmq::q8_bytes(g.hc, Nn) + 4 * g.hc : 0);+ const int64_t B = std::min<int64_t>(n - r0, (int64_t) (m.region_bytes / per_row) & ~(int64_t) 63);+ if (B < 64) return false;+ uint8_t* q = m.region;+ auto carve = [&](size_t bytes) { void* p = q; q += (bytes + 255) & ~(size_t) 255; return p; };+ float* emb = (float*) carve((size_t) B * Nn * 4);+ float* e2 = (float*) carve((size_t) B * Nn * 4);+ uint16_t* en16 = (uint16_t*) carve((size_t) B * Nn * 2);+ float* hn = (float*) carve((size_t) B * HCN * 4);+ float* h2 = (float*) carve((size_t) B * HCN * 4);+ float* Rm = (float*) carve((size_t) B * HCN * 4);+ float* gated = (float*) carve((size_t) B * HCN * 4);+ uint16_t* hn16 = (uint16_t*) carve((size_t) B * HCN * 2);+ uint16_t* xn16 = (uint16_t*) carve((size_t) B * HCN * 2);+ float* lo = (float*) carve((size_t) B * LR * 4);+ uint16_t* lo16 = (uint16_t*) carve((size_t) B * LR * 2);+ float* grs = (float*) carve((size_t) B * HC * 4);+ float* mixed = (float*) carve((size_t) B * Nn * 4);+ uint16_t* mixed_h = (uint16_t*) carve((size_t) B * Nn * 2);+ float* Kc = (float*) carve((size_t) B * KV * 4);+ float* Vc = (float*) carve((size_t) B * KV * 4);+ int32_t* tok = (int32_t*) carve((size_t) B * 4);+ void* xq = q8 ? carve(mmq::q8_bytes(B * g.hc, Nn)) : nullptr;+ int32_t* ident = q8 ? (int32_t*) carve((size_t) B * g.hc * 4) : nullptr;+ int32_t* bnd = q8 ? (int32_t*) carve(16) : nullptr;+ if ((uint64_t) (q - m.region) > m.region_bytes) return false;+ if (!mtp.idle(err)) return false; // the drafter's own stream (its graph uploads) before this writes its K/V+ strata::kernels::QsaShapes s = strata::kernels::qsa_real_shapes();+ s.n_head = g.n_head; s.n_head_kv = g.n_head_kv; s.head_dim = g.head_dim; s.idx_n_head = g.idx_q_heads;+ s.idx_dim = g.idx_key_dim;+ std::vector<int32_t> tk((size_t) B);+ if (q8) {+ if (!m.mmq_ctx) m.mmq_ctx = std::make_unique<mmq::Context>();+ mmq::iota(ident, B * g.hc, m.cs);+ }+ // y[rows, n_out] = x[rows, k] . w^T for a Q8_0 matrix: MMQ from the FP32 rows (bounds slot 0: rows, 1: rows*hc)+ auto proj = [&](const float* x, const uint16_t* x16, const void* w, float* y, int64_t rows, int64_t n_out,+ int64_t k, int slot) {+ if (!q8) { m.gemm.native(x16, kQ8_0, w, y, rows, n_out, k); return; }+ mmq::quantize(x, nullptr, xq, kQ8_0, k, k, rows, m.cs);+ mmq::Product p;+ p.w = w; p.type = kQ8_0; p.w_rows = n_out; p.w_cols = k; p.expert_bytes = mmq::matrix_bytes(kQ8_0, n_out, k);+ p.n = 1; p.xq = xq; p.bounds = bnd + 2 * slot; p.ids = ident; p.total_rows = rows; p.max_rows = rows;+ p.dst = y; p.ld_dst = n_out;+ m.mmq_ctx->run(p, m.cs);+ };+ for (int64_t b0 = r0; b0 < n; b0 += B) {+ const int64_t nb = std::min(B, n - b0), c0 = cell0 + b0;+ for (int64_t i = 0; i < nb; ++i) tk[(size_t) i] = next_tokens[b0 + i];+ const int32_t bh[4] = {0, (int32_t) nb, 0, (int32_t) (nb * g.hc)};+ /*+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ While the origin API might be synchronous, it depends on the type of+ operand memory, so you may need to call wait() on event return by memcpy+ API to ensure synchronization behavior.+ */+ if (q8 && DPCT_CHECK_ERROR(m.cs->memcpy(bnd, bh, sizeof bh)) != 0) {+ err = "prefill: the draft bounds' upload failed";+ return false;+ }+ /*+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ While the origin API might be synchronous, it depends on the type of+ operand memory, so you may need to call wait() on event return by memcpy+ API to ensure synchronization behavior.+ */+ if (DPCT_CHECK_ERROR(m.cs->memcpy(tok, tk.data(), (size_t)nb * 4)) !=+ 0) {+ err = "prefill: the draft tokens' upload failed";+ return false;+ }+ // the input branches: the next token's embedding, and this cell's final residual rows+ if (nemb) {+ nemb->gather_dev(tok, nb, emb, m.cs);+ } else {+ const auto* codes = (const uint8_t*) wemb->data;+ const auto* scales = (const float*) (codes + wemb->codes_bytes);+ const auto* offsets = wemb->has_offset ? (const float*) (codes + wemb->codes_bytes + wemb->scales_bytes)+ : nullptr;+ strata::kernels::embedding_gather_dev(codes, scales, offsets, tok, (int) nb, wemb->ne0, wemb->code_bits,+ wemb->code_bias, wemb->group_elems,+ (uint64_t) (wemb->ne0 / (8 / wemb->code_bits)),+ (uint64_t) (wemb->ne0 / wemb->group_elems), emb, m.cs);+ }+ rms_rows(emb, w_ne, nb, Nn, Nn, EPS, m.cs);+ if (!q8) to_f16(emb, en16, nb * Nn, m.cs);+ proj(emb, en16, w_fe, e2, nb, Nn, Nn, 0);+ /*+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ While the origin API might be synchronous, it depends on the type of+ operand memory, so you may need to call wait() on event return by memcpy+ API to ensure synchronization behavior.+ */+ m.cs->memcpy(hn, R_rows + (size_t)b0 * HCN, (size_t)nb * HCN * 4);+ rms_rows(hn, w_nh, nb, HCN, HCN, EPS, m.cs);+ if (!q8) to_f16(hn, hn16, nb * HCN, m.cs);+ proj(hn, hn16, w_fh, h2, nb * g.hc, Nn, Nn, 1); // every stream through fc_hidden+ strata::kernels::add_streams_broadcast(h2, e2, Rm, Nn, (int) g.hc, (int) nb, m.cs);+ // the attention hyper-connection's read (its mixed input only: this pass writes nothing back)+ gr_norm_rs(Rm, w_hn, EPS, grs, xn16, nb, m.cs);+ m.gemm.bf16(xn16, w_dn, lo, nb, LR, HCN);+ gr_silu(lo, lo16, nb, m.cs);+ m.gemm.bf16(lo16, w_up, gated, nb, HCN, LR);+ gr_mix_r(Rm, grs, w_hn, gated, mixed, nullptr, nb, m.cs, mixed_h);+ // K and V into the drafter's cache, as the prompt path's QSA layers append theirs+ proj(mixed, mixed_h, w_k, Kc, nb, KV, Nn, 0);+ proj(mixed, mixed_h, w_v, Vc, nb, KV, Nn, 0);+ rms_rows(Kc, w_kn, nb * g.n_head_kv, g.head_dim, g.head_dim, EPS, m.cs);+ rope(Kc, nb, g.n_head_kv, g.head_dim, KV, c0, (float) strata::kernels::qsa_freq_base(), m.cs);+ if (st.kv_q4) {+ strata::kernels::fwht256_inplace_cuda(Kc, nb * g.n_head_kv, m.cs);+ strata::kernels::fwht256_inplace_cuda(Vc, nb * g.n_head_kv, m.cs);+ strata::kernels::kv_append_q4(st.k_q4, st.v_q4, st.page_table, c0, nb, Kc, Vc, s, m.cs, &st.host);+ } else {+ kv_append(Kc, Vc, nb, c0, st.page_table, s.page_size, st.kv_int8 ? nullptr : st.k_pool,+ st.kv_int8 ? nullptr : st.v_pool, st.k_q, st.v_q, st.k_scale, st.v_scale, m.cs, &st.host);+ }+ }+ if (DPCT_CHECK_ERROR(m.cs->wait()) != 0) {+ /*+ DPCT1009: SYCL reports errors using exceptions and does not use+ error codes. Please replace the "get_error_string_dummy(...)" with a+ real error-handling function.+ */+ /*+ DPCT1010: SYCL uses exceptions to report errors and does not use+ the error codes. The cudaGetLastError function call was replaced with 0.+ You need to rewrite this code.+ */+ err = std::string("prefill: the draft layer's K/V: ") ++ dpct::get_error_string_dummy(0);+ return false;+ }+ mtp.ms_prefill += ms_since(t0);+ return true;+}void Prefill::set_pinned_share(double share) { g_pinned_share = share; }double Prefill::pinned_share() { return g_pinned_share; }@@ -837,7 +1062,8 @@ struct PfTimer {};} // namespace-bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& err) {+bool Prefill::run(const int64_t *tokens, int64_t n, int64_t pos0,+ std::string &err) try {Impl& m = *impl_;const core::OnDevice on_device(m.device);const core::ModelGeometry& g = *m.g;@@ -903,7 +1129,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e// previous stage handed onif (hand_in_ != nullptr) {/*- DPCT1124:1015: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -930,7 +1156,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e}if (batched) {/*- DPCT1124:1016: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -958,7 +1184,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& econst float* row = embd_rows ? embd_rows[p0 + t] : nullptr;if (row) {/*- DPCT1124:1017: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need to callwait() on event return by memcpy API to ensure synchronization@@ -984,7 +1210,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& ereturn false;}/*- DPCT1124:1018: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -1006,7 +1232,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e// ---- the QSA step records of every position in the chunkfor (int64_t t = 0; t < T; ++t) strata::kernels::qsa_step_fill(m.steps_host.data() + t * strata::kernels::kStepCount, p0 + t, s);/*- DPCT1124:1014: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -1061,7 +1287,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e{*m.used[sl]});if (en.job < 0) {/*- DPCT1124:1019: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -1072,7 +1298,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e} else {const uint8_t* hb = m.stager->wait(en.job);/*- DPCT1124:1020: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -1129,7 +1355,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e{*m.used[sl]});if (en.job < 0) {/*- DPCT1124:1021: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API might besynchronous, it depends on the type of operand memory,so you may need to call wait() on event return by memcpy@@ -1140,7 +1366,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e} else {const uint8_t* hb = m.stager->wait(en.job);/*- DPCT1124:1022: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API might besynchronous, it depends on the type of operand memory,so you may need to call wait() on event return by memcpy@@ -1169,6 +1395,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& eelse issue_until(upto + (size_t) m.ring);};host_setup_ms += ms_since(tsetup);+ bool normed = false; // F-2: the previous half's write already normed R for this half (grs, xn16)for (int64_t l = LB; l < LE; ++l) {core::progress_beat(); // the serve watchdog: a prompt chunk of 8192 tokens is still movingconst core::LayerView v(*m.wt, l);@@ -1233,12 +1460,15 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e*wu = need(v, su.c_str(), err), *wi = need(v, si.c_str(), err);if (!wn || !wd || !wu || !wi) return false;pt.mark(kPfHc, cs);- gr_norm(m.R, (const float*) wn->data, EPS, m.xn, m.xn16, T, m.cs);+ if (gr_unfused()) gr_norm(m.R, (const float*) wn->data, EPS, m.xn, m.xn16, T, m.cs);+ else if (!normed) gr_norm_rs(m.R, (const float*) wn->data, EPS, m.grs, m.xn16, T, m.cs);+ normed = false;if (!bf16_proj(m.gemm, wd, m.xn16, m.lo, T, sd, err)) return false;gr_silu(m.lo, m.lo16, T, m.cs);if (!bf16_proj(m.gemm, wu, m.lo16, m.gated, T, su, err)) return false;if (!bf16_proj(m.gemm, wi, m.xn16, m.inj, T, si, err)) return false;- gr_mix(m.xn, m.gated, m.mixed, m.mixed_bf, T, m.cs, m.mixed_h);+ if (gr_unfused()) gr_mix(m.xn, m.gated, m.mixed, m.mixed_bf, T, m.cs, m.mixed_h);+ else gr_mix_r(m.R, m.grs, (const float*) wn->data, m.gated, m.mixed, m.mixed_bf, T, m.cs, m.mixed_h);if (half == 0 && !core::is_qsa_layer(g, l)) {// ======================= GDN =======================@@ -1292,7 +1522,14 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e(p0 + s.page_size - 1) / s.page_size, s, m.cs);pt.mark(kPfQsa, cs);}- if (st.kv_q4) { // Q4_0 KV (kv_q4.hpp): rotated K and V, the queries below too, the output back+ if (st.kv_hybrid) { // K8V4: K INT8 unrotated, V rotated Q4_0 (only V and the output rotate)+ strata::kernels::fwht256_inplace_cuda(m.Vc, T * 2, m.cs);+ kv_append(m.Kc, m.Kc, T, p0, st.page_table, s.page_size, nullptr, nullptr,+ st.k_q, st.k_q, st.k_scale, st.k_scale, m.cs, nullptr, // mode 0: no host mirror+ staged ? &m.stage : nullptr);+ strata::kernels::kv_append_q4(st.v_q4, st.v_q4, st.page_table, p0, T, m.Vc, m.Vc, s, m.cs,+ nullptr, staged ? &m.stage : nullptr);+ } else if (st.kv_q4) { // Q4_0 KV (kv_q4.hpp): rotated K and V, the queries below too, the output backstrata::kernels::fwht256_inplace_cuda(m.Kc, T * 2, m.cs);strata::kernels::fwht256_inplace_cuda(m.Vc, T * 2, m.cs);strata::kernels::kv_append_q4(st.k_q4, st.v_q4, st.page_table, p0, T, m.Kc, m.Vc, s, m.cs,@@ -1350,7 +1587,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& eif (static const bool ovl = std::getenv("STRATA_SEL_OVERLAP") != nullptr; ovl && qsa_index == 0) {std::vector<int32_t> ids((size_t) (T * m.cap));/*- DPCT1124:1023: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API might besynchronous, it depends on the type of operand memory,so you may need to call wait() on event return by memcpy@@ -1410,7 +1647,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e}std::vector<int32_t> a((size_t) (T * m.cap)), b((size_t) (T * m.cap));/*- DPCT1124:1024: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API might besynchronous, it depends on the type of operand memory,so you may need to call wait() on event return by memcpy@@ -1418,7 +1655,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e*/m.cs->memcpy(a.data(), m.sel_ids, a.size() * 4);/*- DPCT1124:1025: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API might besynchronous, it depends on the type of operand memory,so you may need to call wait() on event return by memcpy@@ -1451,7 +1688,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& eif (p0 + T > pos0 + n - last) {std::vector<int32_t> h((size_t) (T * m.cap));/*- DPCT1124:1026: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API mightbe synchronous, it depends on the type of operandmemory, so you may need to call wait() on event@@ -1473,7 +1710,8 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& ept.mark(kPfQsaAttn, cs);// perf-review D-1: the whole chunk on tensor cores, one block per (query, KV head), FP32-level// accuracy but not bitwise (qsa_prompt_attn.hpp). Q4_0 KV, or STRATA_PROMPT_ATTN_OLD=1: the- // decode kernel, 32 queries at a time+ // decode kernel, 32 queries at a time (K8V4 runs the tensor kernel's mode 3: INT8 K,+ // V dequantized from its q4_0 blocks to fp16 at gather)static const bool old_attn = std::getenv("STRATA_PROMPT_ATTN_OLD") != nullptr;if (old_attn || !strata::kernels::qsa_prompt_attn_batch(m.q, pools, m.sel_ids, m.steps_dev, m.cap, s,m.attn, T, m.cs))@@ -1483,7 +1721,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& em.steps_dev + t0 * strata::kernels::kStepCount, m.cap,s, m.attn_scratch, m.attn + t0 * ZV, nb, m.cs);}- if (st.kv_q4) strata::kernels::fwht256_inplace_cuda(m.attn, T * 24, m.cs);+ if (st.kv_q4 || st.kv_hybrid) strata::kernels::fwht256_inplace_cuda(m.attn, T * 24, m.cs);pt.mark(kPfQsa, cs);gate_attn(m.attn, m.Qf, m.attn_h, T, m.cs);if (!native_proj(m.gemm, wo, m.attn_h, m.bo, T, v.name("attn_output.weight"), err)) return false;@@ -1508,19 +1746,27 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& em.gemm.bf16(m.mixed_bf, (const uint16_t*) wgi->data, m.sg, T, 1, N);// group the (token, k) pairs by expert on the hostpt.mark(kPfHostGroup, cs);+ // (the sync below also orders this layer's writes of slot/src/bounds after the previous+ // layer's kernels that read them)+ const bool grp_mapped = m.grp_host != nullptr;+ int32_t* ids_h = grp_mapped ? m.grp_host : m.ids_host.data();+ int32_t* slot_h = grp_mapped ? m.grp_host + m.grp_tk : m.slot_host.data();+ int32_t* src_h = grp_mapped ? m.grp_host + 2 * m.grp_tk : m.src_host.data();+ if (grp_mapped) copy_i32(m.grp_dev, m.ids, T * K, m.cs);/*- DPCT1124:1027: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensuresynchronization behavior.*/- m.cs->memcpy(m.ids_host.data(), m.ids, (size_t)T * K * 4);+ else m.cs->memcpy(m.ids_host.data(), m.ids,+ (size_t)T * K * 4);m.cs->wait();pt.fold();std::fill(m.cnt.begin(), m.cnt.end(), 0);for (int64_t i = 0; i < T * K; ++i) {- const int32_t e = m.ids_host[(size_t) i];+ const int32_t e = ids_h[(size_t) i];if (e < 0 || e >= m.g->n_expert) { err = "prefill: routed id out of range"; return false; }++m.cnt[(size_t) e];}@@ -1528,29 +1774,34 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& efor (int64_t e = 0; e < m.g->n_expert; ++e) m.off[(size_t) e + 1] = m.off[(size_t) e] + m.cnt[(size_t) e];std::vector<int32_t> fill(m.off.begin(), m.off.end() - 1);for (int64_t i = 0; i < T * K; ++i) {- const int32_t e = m.ids_host[(size_t) i];+ const int32_t e = ids_h[(size_t) i];const int32_t p = fill[(size_t) e]++;- m.slot_host[(size_t) i] = p;- m.src_host[(size_t) p] = (int32_t) (i / K);+ slot_h[(size_t) i] = p;+ src_h[(size_t) p] = (int32_t) (i / K);+ }+ if (grp_mapped) {+ copy_i32(m.slot_dev, m.grp_dev + m.grp_tk, T * K, m.cs);+ copy_i32(m.src_dev, m.grp_dev + 2 * m.grp_tk, T * K, m.cs);+ } else {+ /*+ DPCT1124: cudaMemcpyAsync is migrated to+ asynchronous memcpy API. While the origin API might be+ synchronous, it depends on the type of operand memory,+ so you may need to call wait() on event return by memcpy+ API to ensure synchronization behavior.+ */+ m.cs->memcpy(m.slot_dev, m.slot_host.data(),+ (size_t)T * K * 4);+ /*+ DPCT1124: cudaMemcpyAsync is migrated to+ asynchronous memcpy API. While the origin API might be+ synchronous, it depends on the type of operand memory,+ so you may need to call wait() on event return by memcpy+ API to ensure synchronization behavior.+ */+ m.cs->memcpy(m.src_dev, m.src_host.data(),+ (size_t)T * K * 4);}- /*- DPCT1124:1028: cudaMemcpyAsync is migrated to asynchronous- memcpy API. While the origin API might be synchronous, it- depends on the type of operand memory, so you may need to- call wait() on event return by memcpy API to ensure- synchronization behavior.- */- m.cs->memcpy(m.slot_dev, m.slot_host.data(),- (size_t)T * K * 4);- /*- DPCT1124:1029: cudaMemcpyAsync is migrated to asynchronous- memcpy API. While the origin API might be synchronous, it- depends on the type of operand memory, so you may need to- call wait() on event return by memcpy API to ensure- synchronization behavior.- */- m.cs->memcpy(m.src_dev, m.src_host.data(),- (size_t)T * K * 4);// the experts, in id order: resident ones from VRAM, the others through the staging ringstd::vector<int32_t> order;for (int32_t e = 0; e < m.g->n_expert; ++e) if (m.cnt[(size_t) e] > 0) order.push_back(e);@@ -1574,15 +1825,22 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& efor (size_t i = 0; i <= MMQ_GROUP; ++i)m.bounds_host[n + 1 + g * (MMQ_GROUP + 1) + i] =m.bounds_host[std::min(n, g * MMQ_GROUP + i)] - m.bounds_host[g * MMQ_GROUP];- /*- DPCT1124:1030: cudaMemcpyAsync is migrated to- asynchronous memcpy API. While the origin API might be- synchronous, it depends on the type of operand memory,- so you may need to call wait() on event return by memcpy- API to ensure synchronization behavior.- */- m.cs->memcpy(m.bounds_dev, m.bounds_host.data(),- m.bounds_host.size() * 4);+ if (grp_mapped) {+ int32_t* bh = m.grp_host + 3 * m.grp_tk;+ std::memcpy(bh, m.bounds_host.data(), m.bounds_host.size() * 4);+ copy_i32(m.bounds_dev, m.grp_dev + 3 * m.grp_tk, (int64_t) m.bounds_host.size(), m.cs);+ } else {+ /*+ DPCT1124: cudaMemcpyAsync is migrated to+ asynchronous memcpy API. While the origin API might+ be synchronous, it depends on the type of operand+ memory, so you may need to call wait() on event+ return by memcpy API to ensure synchronization+ behavior.+ */+ m.cs->memcpy(m.bounds_dev, m.bounds_host.data(),+ m.bounds_host.size() * 4);+ }} else {gather_rows16(m.mixed_h, m.src_dev, m.Xs, T * K, N, m.cs);}@@ -1620,7 +1878,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& eif (m.stage_live[sl])(m.copy)->ext_oneapi_submit_barrier({*m.used[sl]});/*- DPCT1124:1031: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API mightbe synchronous, it depends on the type of operandmemory, so you may need to call wait() on event@@ -1636,7 +1894,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& eif (m.stage_live[sl])(m.copy)->ext_oneapi_submit_barrier({*m.used[sl]});/*- DPCT1124:1032: cudaMemcpyAsync is migrated to+ DPCT1124: cudaMemcpyAsync is migrated toasynchronous memcpy API. While the origin API mightbe synchronous, it depends on the type of operandmemory, so you may need to call wait() on event@@ -1828,8 +2086,24 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e}}}- // ---- the hyper-connection write of this half- gr_write(m.R, m.bo, m.inj, HC, T, m.cs);+ // ---- the hyper-connection write of this half; F-2: fused with the next half's norm when nothing else+ // touches R in between (not the stage's last half, not before the PLE block of layer 1, not under a+ // control vector)+ const int64_t nl = half == 0 ? l : l + 1;+ const bool fuse = !gr_unfused() && nl < LE && !(half == 1 && nl == 1 && ple_on) &&+ !(half == 1 && strata::kernels::cvec().covers(l));+ const core::WeightRef* wnn = nullptr;+ if (fuse) {+ const core::LayerView vn(*m.wt, nl);+ wnn = need(vn, half == 0 ? "hc_ffn_norm.weight" : "hc_attn_norm.weight", err);+ if (!wnn) return false;+ }+ if (wnn) {+ gr_write_norm_rs(m.R, m.bo, m.inj, HC, (const float*) wnn->data, EPS, m.grs, m.xn16, T, m.cs);+ normed = true;+ } else {+ gr_write(m.R, m.bo, m.inj, HC, T, m.cs);+ }if (half == 1 && strata::kernels::cvec().covers(l)) // --control-vector-scaledstrata::kernels::cvec_apply(m.R, l, T, D, nullptr, 0, nullptr, 0, false, m.cs);}@@ -1846,7 +2120,7 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e// the rows to the host buffer the next stage read two chunks ago (it has finished: waited below)float* h = m.hand[hand_buf];/*- DPCT1124:1033: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends on thetype of operand memory, so you may need to call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -1855,13 +2129,13 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e0 ||DPCT_CHECK_ERROR(m.cs->wait()) != 0) {/*- DPCT1009:1034: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:1035: SYCL uses exceptions to report errors and does+ DPCT1010: SYCL uses exceptions to report errors and doesnot use the error codes. The cudaGetLastError function call wasreplaced with 0. You need to rewrite this code.*/@@ -1898,13 +2172,13 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& econst auto toc = Clock::now();if (DPCT_CHECK_ERROR(m.cs->wait()) != 0) {/*- DPCT1009:1036: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:1037: SYCL uses exceptions to report errors and does+ DPCT1010: SYCL uses exceptions to report errors and doesnot use the error codes. The cudaGetLastError function call wasreplaced with 0. You need to rewrite this code.*/@@ -1951,18 +2225,36 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e}if (DPCT_CHECK_ERROR(m.cs->wait()) != 0) {/*- DPCT1009:1038: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1010:1039: SYCL uses exceptions to report errors and does not use+ DPCT1010: SYCL uses exceptions to report errors and does not usethe error codes. The cudaGetLastError function call was replaced with 0.You need to rewrite this code.*/err = std::string("prefill: ") + dpct::get_error_string_dummy(0);return false;}+ // (PR #121) an expert copy that failed on the copy stream surfaces here, not in the next request+ /*+ DPCT1000: Error handling if-stmt was detected but could not be+ rewritten.+ */+ if (const dpct::err0 cst = DPCT_CHECK_ERROR(m.copy->wait()); cst != 0) {+ /*+ DPCT1009: SYCL reports errors using exceptions and does not use+ error codes. Please replace the "get_error_string_dummy(...)" with a+ real error-handling function.+ */+ /*+ DPCT1001: The statement could not be removed.+ */+ err = std::string("prefill: expert copy stream: ") ++ dpct::get_error_string_dummy(cst);+ return false;+ }stats_.ms_total += ms_since(t_start);if (pt.on) {pt.fold();@@ -2000,5 +2292,10 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e}return true;}+catch (sycl::exception const &exc) {+ std::cerr << exc.what() << "Exception caught at file:" << __FILE__+ << ", line:" << __LINE__ << std::endl;+ std::exit(1);+}} // namespace strata::prefilldiff --git a/sycl/src/program/generate.cpp b/sycl/src/program/generate.cppindex 49f7d05db..6f89035c9 100644--- a/sycl/src/program/generate.cpp+++ b/sycl/src/program/generate.cpp@@ -80,9 +80,11 @@#include <mutex>#include <charconv>#include <cmath>+#include <limits>#include <cstdio>#include <cstdlib>#include <cstring>+#include <filesystem>#include <fstream>#include <sstream>#include <string>@@ -183,6 +185,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 resident_cpu_experts = false; ///< mmap-backed static-cache misses copied into ordinary RAMbool 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@@ -330,6 +333,8 @@ void usage() {" VRAM; default fp16 until gate G-C accepts int8\n"" --kv q4_0 4-bit K/V after a Hadamard rotation (PR #21): half of int8's memory,\n"" slightly lower precision (see bench/results/2026-09-27-kv-q4)\n"+ " --kv k8v4 hybrid: INT8 K (exact attention scores) + rotated Q4_0 V, 816 B/cell\n"+ " (vs int8's 1,056); not with --kv-resident\n"" --kv-resident N KV streaming: keep N cells of each QSA layer in VRAM (min 20480) and the\n"" whole K/V in pinned RAM; the freed VRAM goes to expert slots. 0 (default):\n"" all of it in VRAM. A context of N cells or fewer is not streamed\n"@@ -435,7 +440,9 @@ void usage() {" --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");+ " 34 GB, and measured 71.97 vs 34.78 ms/token cold vs warm.\n"+ " --resident-cpu-experts with mmap and a static profile, keep CPU misses resident in ordinary RAM.\n"+ " Borrowed GPU-cache entries may read from mmap during prompt prefill.\n");}/// All shards of a split GGUF, from shard 1's path ("...-00001-of-00002.gguf"); just the path when it is not split.@@ -684,7 +691,7 @@ void mem_mark(const char* where) {if (!on) return;size_t free_b = 0, total_b = 0;/*- DPCT1106:666: 'cudaMemGetInfo' was migrated with the Intel extensions for+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensions fordevice information which may not be supported by all compilers or runtimes.You may need to adjust the code.*/@@ -780,7 +787,7 @@ bool checkpoint_restore(const ConvCheckpoint &c, strata::core::SessionState &ss,const ConvStateSizes z = conv_state_sizes(g);if (c.gdn.size() != z.gdn || c.tails.size() != z.tail * (size_t) g.n_qsa_layers()) return false;/*- DPCT1114:667: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -788,7 +795,7 @@ bool checkpoint_restore(const ConvCheckpoint &c, strata::core::SessionState &ss,if (DPCT_CHECK_ERROR(dpct::get_in_order_queue().memcpy(ss.gdn_state, c.gdn.data(), z.gdn).wait()) != 0) return false;/*- DPCT1114:668: cudaMemcpy is migrated to asynchronization memcpy, assuming in+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy, assuming inthe original code the source host memory is pageable memory. If the memoryis not pageable, call wait() on event return by memcpy API to ensuresynchronization behavior.@@ -798,7 +805,7 @@ bool checkpoint_restore(const ConvCheckpoint &c, strata::core::SessionState &ss,return false;for (int64_t i = 0; i < g.n_qsa_layers(); ++i)/*- DPCT1114:669: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageable memory.If the memory is not pageable, call wait() on event return by memcpy APIto ensure synchronization behavior.@@ -914,7 +921,7 @@ double probe_pcie_h2d_gbps() try {}std::memset(h, 0, kBytes); // fault the pages in before timing/*- DPCT1124:670: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -923,7 +930,7 @@ double probe_pcie_h2d_gbps() try {d, h, kBytes).wait(); // warmup: context up, copy engine primeddpct::sync_barrier(ev0);/*- DPCT1124:671: cudaMemcpyAsync is migrated to asynchronous memcpy API. While+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API. Whilethe origin API might be synchronous, it depends on the type of operandmemory, so you may need to call wait() on event return by memcpy API toensure synchronization behavior.@@ -1144,6 +1151,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 == "--resident-cpu-experts") o.resident_cpu_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;@@ -1175,7 +1183,7 @@ int main(int argc, char** argv) {if (DPCT_CHECK_ERROR(n_dev = dpct::device_count()) != 0 || n_dev < 1)n_dev = 1;/*- DPCT1026:672: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/auto ints = [](const std::string &str, auto &out) -> bool {@@ -1217,6 +1225,16 @@ int main(int argc, char** argv) {}}const bool multi_gpu = !split_devs.empty() && !split_same;+ if (o.resident_cpu_experts && (!o.mmap_experts || o.expert_profile.empty() || o.adapt_every != 0)) {+ std::fprintf(stderr, "strata generate: --resident-cpu-experts requires --mmap-experts, a static --expert-profile and --adapt-every 0\n");+ return 2;+ }+ if (o.resident_cpu_experts &&+ (!o.layer_split.empty() || o.expert_cache_remote[0] > 0 || o.expert_cache_remote[1] > 0 ||+ o.expert_cache_remote[2] > 0)) {+ std::fprintf(stderr, "strata generate: --resident-cpu-experts does not support layer splits or remote expert caches\n");+ return 2;+ }// the helper-GPU expert caches (--expert-cache-remote, docs/SECOND_GPU.md): CUDA1..3 on one GPU; with a layer// split, the visible GPUs no stage runs on, in orderint remote_dev[3] = {1, 2, 3};@@ -1230,7 +1248,7 @@ int main(int argc, char** argv) {if (DPCT_CHECK_ERROR(n_vis = dpct::device_count()) != 0 || n_vis < 1)n_vis = 1;/*- DPCT1026:673: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/int next_free = 1;@@ -1273,16 +1291,21 @@ int main(int argc, char** argv) {return 2;}if (o.kv == "q4") o.kv = "q4_0";- if (o.kv != "fp16" && o.kv != "int8" && o.kv != "q4_0") {- std::fprintf(stderr, "strata generate: --kv must be fp16, int8 or q4_0\n");+ if (o.kv != "fp16" && o.kv != "int8" && o.kv != "q4_0" && o.kv != "k8v4") {+ std::fprintf(stderr, "strata generate: --kv must be fp16, int8, q4_0 or k8v4\n");return 2;}strata::core::qsa_set_kv_int8(o.kv == "int8");strata::core::qsa_set_kv_q4(o.kv == "q4_0"); // PR #21: 4-bit codes after a Hadamard rotation (kv_q4.hpp)+ strata::core::qsa_set_kv_hybrid(o.kv == "k8v4"); // K8V4: INT8 K + rotated Q4_0 V, 816 B/cellif (o.kv_resident < 0) {std::fprintf(stderr, "strata generate: --kv-resident must be >= 0\n");return 2;}+ if (o.kv == "k8v4" && o.kv_resident > 0) {+ std::fprintf(stderr, "strata generate: --kv k8v4 does not support --kv-resident streaming (yet)\n");+ return 2;+ }strata::core::qsa_set_kv_resident(o.kv_resident);// Prompt lookup (the suffix drafter, on by default): the MTP keeps its --spec windows and a lookup window may be// up to 2 tokens longer; the draft policy (strata/spec/draft_policy.hpp) takes one only where it pays. Code@@ -1526,7 +1549,7 @@ int main(int argc, char** argv) {d_mrope = sycl::malloc_device<int32_t>(mrope_host.size(), dpct::get_in_order_queue())) != 0 ||/*- DPCT1114:674: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -1587,7 +1610,7 @@ int main(int argc, char** argv) {// 0.805 us inside a graph. **That is an ~8x penalty on every launch in the engine.**dpct::queue_ptr main_stream = &dpct::get_in_order_queue();/*- DPCT1025:675: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (DPCT_CHECK_ERROR(@@ -1623,7 +1646,7 @@ int main(int argc, char** argv) {}const size_t n = (size_t) g.n_layers * (size_t) half_stride;/*- DPCT1048:2: The original value cudaHostAllocDefault is not meaningful in+ DPCT1048: The original value cudaHostAllocDefault is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -1683,7 +1706,7 @@ int main(int argc, char** argv) {ss.ple.w.key_scales = (const float*) ((const uint8_t*) wk->data + wk->codes_bytes);}if (o.native_ple_key && wk->quantized()) {- if (!wk->native_data || wk->native_type != 42 || !wk->native_q8_1) {+ if (!wk->native_data || (wk->native_type != 42 && wk->native_type != 18 && wk->native_type != 23) || !wk->native_q8_1) {std::fprintf(stderr, "strata generate: native PLE key is absent or incompatible\n");return 1;}@@ -1774,14 +1797,14 @@ int main(int argc, char** argv) {strata::core::session_init(g, o.max_context, K, sbuf_s, st.ss) ==0 ||/*- DPCT1025:677: The SYCL queue is created ignoring the flag and+ DPCT1025: The SYCL queue is created ignoring the flag andpriority options.*/DPCT_CHECK_ERROR(st.stream = dpct::get_current_device().create_queue(true)) !=0 ||/*- DPCT1025:678: The SYCL queue is created ignoring the flag and+ DPCT1025: The SYCL queue is created ignoring the flag andpriority options.*/DPCT_CHECK_ERROR(@@ -1810,7 +1833,7 @@ int main(int argc, char** argv) {st.mrope = sycl::malloc_device<int32_t>(mrope_host.size(), dpct::get_in_order_queue())) != 0 ||/*- DPCT1114:679: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -1833,7 +1856,7 @@ int main(int argc, char** argv) {}size_t fb = 0, tb = 0;/*- DPCT1106:676: 'cudaMemGetInfo' was migrated with the Intel extensions+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensionsfor device information which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -1896,9 +1919,14 @@ int main(int argc, char** argv) {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- std::fprintf(stderr, "strata generate: --mmap-experts needs a canonical pack (experts.bin); %s is a native "- "(IQ) pack, whose experts are loaded into the arena\n", o.pack.c_str());+ // FileExpertSource maps the pack's experts.bin: a canonical pack has it; a native (IQ) pack has it when+ // built with `tools/iq_pack.py --experts-bin` (the per-layer blob sizes of its layout, PR #121). The low-RAM+ // mode: the experts come from the file through the OS cache instead of a pinned copy in RAM, for a PC whose+ // GPU holds most of them but whose RAM cannot hold them all.+ if (native_pack && !std::filesystem::exists(std::filesystem::path(o.pack) / "experts.bin")) {+ std::fprintf(stderr, "strata generate: --mmap-experts needs the pack's experts.bin; %s is a native (IQ) pack "+ "built without it: python tools/iq_pack.py --gguf <shard 1> --out %s --experts-bin\n",+ o.pack.c_str(), o.pack.c_str());return 2;}if (!src.open(o.pack, g.n_layers, g.n_expert, err)) {@@ -1994,7 +2022,7 @@ int main(int argc, char** argv) {const strata::core::OnDevice on(dev);size_t fb = 0, tb = 0;/*- DPCT1106:680: 'cudaMemGetInfo' was migrated with the Intel extensions+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensionsfor device information which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -2023,7 +2051,7 @@ int main(int argc, char** argv) {0 ||khz <= 0) khz = 1800000;/*- DPCT1026:682: The call to cudaGetLastError was removed because this+ DPCT1026: The call to cudaGetLastError was removed because thisfunctionality is redundant in SYCL.*/const double speed =@@ -2149,7 +2177,7 @@ int main(int argc, char** argv) {if (o.expert_cache < 0) {size_t free_b = 0, total_b = 0;/*- DPCT1106:683: 'cudaMemGetInfo' was migrated with the Intel extensions+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensionsfor device information which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -2170,7 +2198,7 @@ int main(int argc, char** argv) {// for them and the reserve, or the first prompt fails with "device buffers ... do not fit"size_t free_b = 0, total_b = 0;/*- DPCT1106:684: 'cudaMemGetInfo' was migrated with the Intel extensions+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensionsfor device information which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -2191,7 +2219,7 @@ int main(int argc, char** argv) {if (native_pack && o.expert_cache > 0 && !profile.empty()) {size_t free_b = 0, total_b = 0;/*- DPCT1106:685: 'cudaMemGetInfo' was migrated with the Intel extensions+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intel extensionsfor device information which may not be supported by all compilers orruntimes. You may need to adjust the code.*/@@ -2283,7 +2311,7 @@ int main(int argc, char** argv) {dpct::get_current_device().queues_wait_and_throw();size_t free_b = 0, total_b = 0;/*- DPCT1106:686: 'cudaMemGetInfo' was migrated with the Intel+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intelextensions for device information which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -2363,6 +2391,14 @@ int main(int argc, char** argv) {(long long) prefilled, (long long) want);}+ if (o.resident_cpu_experts) {+ if (!src.pin_cache_complement(xcache, err, /*pin=*/false)) {+ std::fprintf(stderr, "strata generate: CPU expert residency: %s\n", err.c_str());+ return 1;+ }+ std::fprintf(stderr, "strata generate: steady-state CPU cache misses are resident in ordinary RAM; borrowed cache entries may use mmap during prompt prefill\n");+ }+for (auto& stp : stages) {GpuStage& st = *stp;const auto& lay = strata::kernels::cpu::expert_layout();@@ -2721,7 +2757,7 @@ int main(int argc, char** argv) {} else {for (int64_t c = 0; c < g.hc; ++c)/*- DPCT1124:687: cudaMemcpyAsync is migrated to asynchronous memcpy+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpyAPI. While the origin API might be synchronous, it depends onthe type of operand memory, so you may need to call wait() onevent return by memcpy API to ensure synchronization behavior.@@ -2803,7 +2839,7 @@ int main(int argc, char** argv) {return 1;}/*- DPCT1048:3: The original value cudaHostAllocDefault is not meaningful in+ DPCT1048: The original value cudaHostAllocDefault is not meaningful inthe migrated code and was removed or replaced with 0. You may need tocheck the migrated code.*/@@ -3011,12 +3047,12 @@ int main(int argc, char** argv) {if (DPCT_CHECK_ERROR(dpct::get_current_device().queues_wait_and_throw()) != 0) {/*- DPCT1009:688: SYCL reports errors using exceptions and does not use+ DPCT1009: SYCL reports errors using exceptions and does not useerror codes. Please replace the "get_error_string_dummy(...)" with areal error-handling function.*//*- DPCT1010:689: SYCL uses exceptions to report errors and does not use+ DPCT1010: SYCL uses exceptions to report errors and does not usethe error codes. The cudaGetLastError function call was replacedwith 0. You need to rewrite this code.*/@@ -3058,13 +3094,13 @@ int main(int argc, char** argv) {stderr,"strata generate: gpu-only-full layers faulted: %s\n",/*- DPCT1009:690: SYCL reports errors using exceptions and does+ DPCT1009: SYCL reports errors using exceptions and doesnot use error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:691: SYCL uses exceptions to report errors and does+ DPCT1010: SYCL uses exceptions to report errors and doesnot use the error codes. The cudaGetLastError function callwas replaced with 0. You need to rewrite this code.*/@@ -3080,13 +3116,13 @@ int main(int argc, char** argv) {std::fprintf(stderr, "strata generate: gpu-only-full head faulted: %s\n",/*- DPCT1009:692: SYCL reports errors using exceptions and does+ DPCT1009: SYCL reports errors using exceptions and doesnot use error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:693: SYCL uses exceptions to report errors and does+ DPCT1010: SYCL uses exceptions to report errors and doesnot use the error codes. The cudaGetLastError function callwas replaced with 0. You need to rewrite this code.*/@@ -3157,7 +3193,7 @@ int main(int argc, char** argv) {DPCT_CHECK_ERROR(d_hit_count = sycl::malloc_device<int32_t>(1, dpct::get_in_order_queue())) != 0 ||/*- DPCT1114:694: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on event returnby memcpy API to ensure synchronization behavior.@@ -3176,7 +3212,7 @@ int main(int argc, char** argv) {st->d_res = sycl::malloc_device<int32_t>(host_res.size(), dpct::get_in_order_queue())) != 0 ||/*- DPCT1114:695: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -3274,6 +3310,13 @@ int main(int argc, char** argv) {: (uint64_t) (xcache.slots() - first) *(uint64_t) strata::kernels::cpu::expert_layout().max_blob;};+ auto request_chunk = [](int64_t tokens, int64_t max_chunk) -> int64_t {+ if (tokens <= 0 || max_chunk <= 0) return 0;+ const int64_t rounded = tokens > std::numeric_limits<int64_t>::max() - 255+ ? tokens+ : ((tokens + 255) / 256) * 256;+ return std::min(max_chunk, rounded);+ };// The prompt path's chunk and the slots it borrows for its buffers: the requested chunk halved until it fits,// or with --prefill auto the largest of kAutoChunks whose buffers take at most kAutoLendPct % of the slots (a// lent slot's expert is streamed during the prompt and refilled after it; measured on a 12 GB card, 32K Q2_0@@ -3404,12 +3447,12 @@ int main(int argc, char** argv) {for (float*& h : hand) {float* hh = nullptr;/*- DPCT1048:4: The original value cudaHostAllocMapped is not+ DPCT1048: The original value cudaHostAllocMapped is notmeaningful in the migrated code and was removed or replaced with0. You may need to check the migrated code.*//*- DPCT1048:5: The original value cudaHostAllocPortable is not+ DPCT1048: The original value cudaHostAllocPortable is notmeaningful in the migrated code and was removed or replaced with0. You may need to check the migrated code.*/@@ -3564,7 +3607,9 @@ int main(int argc, char** argv) {sp.on_chunk = [&](const float* R_rows, int64_t T, int64_t p0, std::string& e) -> bool {std::vector<int32_t> nxt((size_t) T);for (int64_t t = 0; t < T; ++t) nxt[(size_t) t] = (int32_t) cur[(size_t) (p0 + t + 1)];- if (!mtp.prefill(R_rows, nxt.data(), T, p0, e)) return false;+ // E-9: batched through the prompt path when it can (one GPU: a layer split's drafter is on the last stage)+ const bool batched = !multi_gpu && sp.draft_kv(mtp, R_rows, nxt.data(), T, p0, e);+ if (!e.empty() || (!batched && !mtp.prefill(R_rows, nxt.data(), T, p0, e))) return false;// progress for the server window: PP <position reached> <prompt tokens> <ms> <fresh tokens/s>const int64_t done = p0 + T;const double ms = std::chrono::duration<double, std::milli>(Clock::now() - pp_t0).count();@@ -3618,7 +3663,7 @@ int main(int argc, char** argv) {if (o.adapt_every > 0 && o.adapt_swaps > 0) drive.d.usage.assign((size_t) (g.n_layers * g.n_expert), 0.0f);dpct::queue_ptr adapt_stream = &dpct::get_in_order_queue();/*- DPCT1025:696: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (DPCT_CHECK_ERROR(@@ -3636,7 +3681,7 @@ int main(int argc, char** argv) {try {if (d_res != nullptr)/*- DPCT1114:697: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -3720,7 +3765,7 @@ int main(int argc, char** argv) {const strata::core::OnDevice on(gs ? gs->dev : -1);if (slot < 0 || b == nullptr ||/*- DPCT1124:698: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensure@@ -3817,7 +3862,7 @@ int main(int argc, char** argv) {// and a page-in while the verify graph spins on a host flag stalls the request for goodsize_t free_b = 0, total_b = 0;/*- DPCT1106:699: 'cudaMemGetInfo' was migrated with the Intel+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intelextensions for device information which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -3837,7 +3882,7 @@ int main(int argc, char** argv) {{size_t free_b = 0, total_b = 0;/*- DPCT1106:700: 'cudaMemGetInfo' was migrated with the Intel+ DPCT1106: 'cudaMemGetInfo' was migrated with the Intelextensions for device information which may not be supported by allcompilers or runtimes. You may need to adjust the code.*/@@ -4273,12 +4318,21 @@ int main(int argc, char** argv) {auto lend = [&](int64_t tokens, std::string &e) -> bool {try {if (lend_first < 0) return true; // its own buffers: nothing to lend- const int64_t want = std::min<int64_t>(o.prefill_chunk, (tokens + 255) / 256 * 256);+ const int64_t want = request_chunk(tokens, o.prefill_chunk);+ if (want <= 0) {+ e = "prefill: cannot lend buffers for an empty request segment";+ return false;+ }if (!lent_now.empty()) {if (want <= lent_chunk) return true;if (!refill(e)) return false;}- const int32_t first = std::max<int32_t>(lend_first, (int32_t) (xcache.slots() - lend_slots(want)));+ const int64_t slots = lend_slots(want);+ if (slots <= 0 || slots > xcache.slots() - lend_first) {+ e = "prefill: request-sized buffers exceed the configured lend region";+ return false;+ }+ const int32_t first = std::max<int32_t>(lend_first, (int32_t) (xcache.slots() - slots));if (want != sp.chunk() || first != lend_first_now) {if (!sp.relayout(want, xcache.device_slot(first), lend_bytes(first), e)) return false;lend_first_now = first;@@ -4608,6 +4662,10 @@ int main(int argc, char** argv) {if (st.kv_q4) {const int64_t q4b = (int64_t) strata::kernels::kv_q4_bytes_per_head((int) qs.head_dim);a = {{h ? st.host.k_q4 : st.k_q4, q4b}, {h ? st.host.v_q4 : st.v_q4, q4b}};+ } else if (st.kv_hybrid) {+ const int64_t q4b = (int64_t) strata::kernels::kv_q4_bytes_per_head((int) qs.head_dim);+ a = {{h ? st.host.k_q : st.k_q, kvb}, {h ? st.host.v_q4 : st.v_q4, q4b},+ {h ? st.host.k_scale : st.k_scale, scb}};} else {a = {{h ? st.host.k_q : st.k_q, kvb}, {h ? st.host.v_q : st.v_q, kvb},{h ? st.host.k_scale : st.k_scale, scb}, {h ? st.host.v_scale : st.v_scale, scb}};@@ -4707,19 +4765,22 @@ int main(int argc, char** argv) {std::FILE* final_r = o.dump_final_r.empty() ? nullptr : std::fopen(o.dump_final_r.c_str(), "wb");std::vector<float> final_r_host(final_r ? (size_t) (g.hc * g.n_embd) : 0);std::vector<std::pair<int32_t, int32_t>> lent; // (residency index, slot) lent to the prompt path+ const int64_t n_batched = (o.prefill_until > 0 && o.prefill_until < n_prompt - 1) ? o.prefill_until : n_prompt - 1;if (o.prefill_chunk > 0 && n_prompt > 1) {void* borrow = nullptr;uint64_t borrow_bytes = 0;if (!o.no_prefill_borrow && !host_res.empty() && d_res != nullptr) {int64_t chunk = o.prefill_chunk;int64_t k = plan_lend(chunk); // auto: the largest chunk that fits; fixed: halved to fit- if (k > 0 && chunk > (n_prompt - 1 + 255) / 256 * 256) { // no bigger than the prompt needs- chunk = std::max<int64_t>(256, (n_prompt - 1 + 255) / 256 * 256);+ const int64_t request_sized = request_chunk(n_batched, chunk);+ if (k > 0 && request_sized < chunk) { // no bigger than this prompt segment needs+ chunk = request_sized;k = lend_slots(chunk);+ if (k + 128 > xcache.slots()) k = 0;if (!o.prefill_auto) o.prefill_chunk = chunk;}if (o.prefill_auto) {- o.prefill_chunk = k > 0 ? chunk : 1024;+ o.prefill_chunk = k > 0 ? chunk : request_chunk(n_batched, 1024);std::fprintf(stderr, "strata generate: prompt chunk auto: %lld tokens\n", (long long) o.prefill_chunk);} else if (chunk != o.prefill_chunk) {k = 0; // a fixed chunk that does not fit: its own buffers, as before@@ -4760,11 +4821,11 @@ int main(int argc, char** argv) {// cell i pairs R_i with the token at i + 1 (every such token is in the prompt)std::vector<int32_t> nxt((size_t) T);for (int64_t t = 0; t < T; ++t) nxt[(size_t) t] = (int32_t) o.tokens[(size_t) (p0 + t + 1)];- return mtp.prefill(R_rows, nxt.data(), T, p0, e);+ if (prefill.draft_kv(mtp, R_rows, nxt.data(), T, p0, e)) return true; // E-9+ return e.empty() && mtp.prefill(R_rows, nxt.data(), T, p0, e);};}const Clock::time_point tp0 = Clock::now();- const int64_t n_batched = (o.prefill_until > 0 && o.prefill_until < n_prompt - 1) ? o.prefill_until : n_prompt - 1;if (!prefill.run(o.tokens.data(), n_batched, 0, err)) {std::fprintf(stderr, "strata generate: %s\n", err.c_str());return 1;@@ -4930,13 +4991,13 @@ int main(int argc, char** argv) {"strata generate: the device faulted in lm_head at position ""%lld: %s\n",/*- DPCT1009:701: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:702: SYCL uses exceptions to report errors and does not+ DPCT1010: SYCL uses exceptions to report errors and does notuse the error codes. The cudaGetLastError function call wasreplaced with 0. You need to rewrite this code.*/@@ -4952,7 +5013,7 @@ int main(int argc, char** argv) {strata::program::logits_selection::selected(pos, dump_positions, o.logits_stride);const bool read_logits = !o.stream_token || o.check_logits || emit_logits;/*- DPCT1124:703: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -4994,7 +5055,7 @@ int main(int argc, char** argv) {sp.counter = (uint64_t) pos;strata::kernels::sample_tokens(d_logits, 1, (int) n_vocab, nullptr, 0, sp, d_next, token_stream);/*- DPCT1124:704: cudaMemcpyAsync is migrated to asynchronous memcpy API.+ DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.While the origin API might be synchronous, it depends on the type ofoperand memory, so you may need to call wait() on event return by memcpyAPI to ensure synchronization behavior.@@ -5006,13 +5067,13 @@ int main(int argc, char** argv) {stderr,"strata generate: reading the sampled token back failed: %s\n",/*- DPCT1009:705: SYCL reports errors using exceptions and does not+ DPCT1009: SYCL reports errors using exceptions and does notuse error codes. Please replace the"get_error_string_dummy(...)" with a real error-handlingfunction.*//*- DPCT1010:706: SYCL uses exceptions to report errors and does not+ DPCT1010: SYCL uses exceptions to report errors and does notuse the error codes. The cudaGetLastError function call wasreplaced with 0. You need to rewrite this code.*/@@ -5125,7 +5186,7 @@ int main(int argc, char** argv) {double ms_adapt = 0;dpct::queue_ptr adapt_stream = &dpct::get_in_order_queue();/*- DPCT1025:707: The SYCL queue is created ignoring the flag and priority+ DPCT1025: The SYCL queue is created ignoring the flag and priorityoptions.*/if (!drive.d.usage.empty() &&@@ -5150,7 +5211,7 @@ int main(int argc, char** argv) {pending.clear();if (d_res != nullptr)/*- DPCT1114:708: cudaMemcpy is migrated to asynchronization memcpy,+ DPCT1114: cudaMemcpy is migrated to asynchronization memcpy,assuming in the original code the source host memory is pageablememory. If the memory is not pageable, call wait() on eventreturn by memcpy API to ensure synchronization behavior.@@ -5201,7 +5262,7 @@ int main(int argc, char** argv) {// asynchronous: the copies run while the MTP drafts; the next window waits for themif (slot < 0 || b == nullptr ||/*- DPCT1124:709: cudaMemcpyAsync is migrated to asynchronous+ DPCT1124: cudaMemcpyAsync is migrated to asynchronousmemcpy API. While the origin API might be synchronous, itdepends on the type of operand memory, so you may need tocall wait() on event return by memcpy API to ensurediff --git a/sycl/tools/fixups.py b/sycl/tools/fixups.pyindex f46dc1507..3a75c1a56 100644--- a/sycl/tools/fixups.py+++ b/sycl/tools/fixups.py@@ -185,6 +185,7 @@ ON = "#if 1 // SYCL: the scalar path (the PTX one above is not ported yet)"for rel in ["src/kernels/cuda/qsa_prompt_attn.dp.cpp", "src/kernels/cuda/qsa_select.dp.cpp","src/kernels/cuda/native_qsa_score.dp.cpp"]:edit(rel, lambda s: s.replace("#if !defined(DPCT_COMPATIBILITY_TEMP) || DPCT_COMPATIBILITY_TEMP >= 800", OFF)+ .replace("#elif !defined(DPCT_COMPATIBILITY_TEMP) || DPCT_COMPATIBILITY_TEMP >= 800", OFF.replace("#if 0", "#elif 0")) # after upstream's __HIPCC__ guard (0.1.27).replace("#if defined(DPCT_COMPATIBILITY_TEMP) && DPCT_COMPATIBILITY_TEMP < 800", ON).replace(" __trap();", " /* unreachable on SYCL: the launcher refuses this device */"))for rel in ["src/kernels/cuda/qsa_prompt_attn.dp.cpp", "src/kernels/cuda/qsa_select.dp.cpp"]:@@ -195,7 +196,7 @@ for rel in ["src/kernels/cuda/qsa_prompt_attn.dp.cpp", "src/kernels/cuda/qsa_sel# which the shared multi-column kernel cannot call. A constexpr copy of the table restores the 2-argument form.def mmvq(s):if "kIq4nlTable" in s: return s # already applied (the table is the marker)- m = re.search(r"iq4nl_values\(sycl::range\(16\), \{([^}]*)\}", s, re.S)+ m = re.search(r"iq4nl_values[^;{]*\(sycl::range\(16\), \{([^}]*)\}", s, re.S) # also after 8c's heap allocationvals = " ".join(m.group(1).split())table = "static constexpr int8_t kIq4nlTable[16] = {%s};\n" % valss = s.replace("__dpct_inline__ sycl::int2 iq4_table_lookup(", table + "__dpct_inline__ sycl::int2 iq4_table_lookup(", 1)diff --git a/sycl/tools/normalize.sh b/sycl/tools/normalize.shnew file mode 100755index 000000000..4d248897c--- /dev/null+++ b/sycl/tools/normalize.sh@@ -0,0 +1,26 @@+#!/usr/bin/env bash+# normalize.sh <dpct-out-dir> <upstream-commit>: a fresh migrate.sh output in the port's shape, for a 3-way merge.+# - dpct's `X.cpp.dp.cpp` becomes `X.cpp` (the .cu -> .dp.cpp names stay), its .yaml/report files go+# - files dpct left byte-identical to the upstream original go too (sycl/CMakeLists.txt falls back to them)+# - the DPCTnnnn:<serial> message numbers are dropped (they renumber on every run and would be pure noise)+# - fixups.py runs on the result+# Updating the port after an upstream merge (docs/INTEL.md "Keeping up with upstream"):+# migrate the OLD upstream tree to sycl-base and the merged tree to sycl-new, normalize both with their+# commits, then for every file in both: git merge-file sycl/F sycl-base/F sycl-new/F+set -euo pipefail+d=$(cd "$1" && pwd); rev=$2; repo=$(cd "$(dirname "$0")/../.." && pwd)+cd "$d"+find . -name '*.yaml' -delete; rm -f dpct_report.*+find . -name '*.cpp.dp.cpp' | while read -r f; do mv "$f" "${f%.cpp.dp.cpp}.cpp"; done+n=0+while read -r f; do+ rel=${f#./}; orig=$rel; [[ $rel == *.dp.cpp ]] && orig=${rel%.dp.cpp}.cu+ if git -C "$repo" cat-file -e "$rev:$orig" 2>/dev/null && cmp -s "$f" <(git -C "$repo" show "$rev:$orig"); then+ rm "$f"; n=$((n+1))+ fi+done < <(find src include third_party -type f 2>/dev/null)+find . -type d -empty -delete+find src include -type f -exec sed -i -E 's/DPCT([0-9]{4}):[0-9]+:/DPCT\1:/' {} ++mkdir -p tools && cp "$repo/sycl/tools/fixups.py" tools/+python3 tools/fixups.py > fixups.log 2>&1 || { tail -5 fixups.log; exit 1; }+echo "$d: dropped $n unchanged files, $(find src include -type f | wc -l) remain, fixups applied: $(grep -c fixed fixups.log)"