okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
98d1c8d4f
main
1--- a/sycl/src/kernels/cuda/verify_kernels.dp.cpp 2+++ b/sycl/src/kernels/cuda/verify_kernels.dp.cpp 3@@ -802,7 +802,9 @@ 4 } 5 6 void gdn_conv_l2_multi(const float* history, const float* qkv, const float* conv_w, float* h, int channels, 7- int qk_heads, float eps, int n_tok, void* stream, int t_begin) { 8+ int qk_heads, float eps, int n_tok, void* stream, int t_begin, bool commit) { 9+ if (commit) { std::fprintf(stderr, "gdn_conv_l2_multi: new optional path is not ported to SYCL\n"); std::exit(1); } 10+ 11 if (!history || !qkv || !conv_w || !h || channels % S != 0 || n_tok < 1 || n_tok > kVerifyMaxT) { 12 std::fprintf(stderr, "gdn_conv_l2_multi: invalid arguments\n"); 13 std::exit(1); 14@@ -876,7 +878,9 @@ 15 16 void gdn_step_norm_multi(float* state, const float* h, int conv_channels, const float* gate, const float* beta, 17 const float* z, const float* gamma, float eps, float* y, int h_k, int h_v, int n_tok, 18- const int32_t* n_keep, void* stream, int t_out_begin) { 19+ const int32_t* n_keep, void* stream, int t_out_begin, void* xq_out) { 20+ if (xq_out != nullptr) { std::fprintf(stderr, "gdn_step_norm_multi: new optional path is not ported to SYCL\n"); std::exit(1); } 21+ 22 if (!state || !h || !gate || !beta || !z || !gamma || !y || h_k <= 0 || h_v % h_k || n_tok < 1 || 23 n_tok > kVerifyMaxT) { 24 std::fprintf(stderr, "gdn_step_norm_multi: invalid arguments\n"); 25@@ -1120,7 +1124,9 @@ 26 } 27 void resident_plan(const int32_t* ids, int n_entries, int k, const int32_t* res_layer, int n_expert, 28 const uint8_t* cache_base, const unsigned long long* slot_off, long long blob, int32_t* plan, 29- long long capx, uint32_t* skip, uint32_t ring, void* stream) { 30+ long long capx, uint32_t* skip, uint32_t ring, void* stream, uint32_t* plan_err) { 31+ if (plan_err != nullptr) { std::fprintf(stderr, "resident_plan: new optional path is not ported to SYCL\n"); std::exit(1); } 32+ 33 const unsigned long long* mir = nullptr; // SYCL port: the layer's slice of the host-mirror table, if any 34 if (g_mirror_table != nullptr && g_mirror_res != nullptr && res_layer >= g_mirror_res) 35 mir = g_mirror_table + (res_layer - g_mirror_res); 36--- a/sycl/src/kernels/cuda/shared_expert.dp.cpp 37+++ b/sycl/src/kernels/cuda/shared_expert.dp.cpp 38@@ -230,7 +230,9 @@ 39 40 void shared_expert_multi(int n_tok, const float* x, const uint16_t* x_bf16, const NativeSharedWeights& nw, 41 const uint16_t* gate_inp_bf16, float* gate, float* up, float* g, float* out, int64_t n_embd, 42- int64_t n_ff, void* stream) { 43+ int64_t n_ff, void* stream, const void* x_q8_1_ready, int lfuse) { 44+ if (x_q8_1_ready != nullptr || lfuse != 0) { std::fprintf(stderr, "shared_expert_multi: new optional path is not ported to SYCL\n"); std::exit(1); } 45+ 46 if (n_tok < 1 || n_tok > 8 || !nw.q8_1 || !nw.gate_data || !nw.up_data || !nw.down_data || !stream) 47 throw std::invalid_argument("shared_expert_multi: needs 1..8 tokens, native weights, scratch and a stream"); 48 dpct::queue_ptr cs = strata::q_of(stream); 49--- a/sycl/src/prefill/kernels.dp.cpp 50+++ b/sycl/src/prefill/kernels.dp.cpp 51@@ -1501,7 +1501,9 @@ 52 check("gr_norm"); 53 } 54 void gr_norm_rs(const float* R, const float* w_norm, float eps, float* rs, uint16_t* xn16, int64_t T, void* stream, 55- uint16_t* xn16_lo) { 56+ uint16_t* xn16_lo, int64_t ldx) { 57+ if (ldx != 0) { std::fprintf(stderr, "gr_norm_rs: new optional path is not ported to SYCL\n"); std::exit(1); } 58+ 59 { 60 auto exp_props = sycl::ext::oneapi::experimental::properties{ 61 sycl::ext::oneapi::experimental::use_root_sync}; 62@@ -1538,7 +1540,9 @@ 63 check("gr_mix_r"); 64 } 65 void gr_write_norm_rs(float* R, const float* bo, const float* inj, int64_t inj_ld, const float* w_norm_next, float eps, 66- float* rs, uint16_t* xn16, int64_t T, void* stream, uint16_t* xn16_lo) { 67+ float* rs, uint16_t* xn16, int64_t T, void* stream, uint16_t* xn16_lo, int64_t ldx) { 68+ if (ldx != 0) { std::fprintf(stderr, "gr_write_norm_rs: new optional path is not ported to SYCL\n"); std::exit(1); } 69+ 70 { 71 auto exp_props = sycl::ext::oneapi::experimental::properties{ 72 sycl::ext::oneapi::experimental::use_root_sync}; 73@@ -1709,7 +1713,9 @@ 74 check("gdn_conv"); 75 } 76 void gdn_recurrence(float* state, const float* h, const float* gate, const float* beta, const float* z, 77- const float* gamma, float eps, float* y, uint16_t* y16, int64_t T, void* stream) { 78+ const float* gamma, float eps, float* y, uint16_t* y16, int64_t T, void* stream, int64_t ld16) { 79+ if (ld16 != 0) { std::fprintf(stderr, "gdn_recurrence: new optional path is not ported to SYCL\n"); std::exit(1); } 80+ 81 static const bool serial = std::getenv("STRATA_GDN_REC_HEADS") != nullptr; // the one-block-per-head kernel (A/B) 82 if (serial || T <= 0) { 83 /* 84@@ -2062,7 +2068,9 @@ 85 } 86 check("split_q"); 87 } 88-void gate_attn(const float* attn, const float* q_full, uint16_t* out16, int64_t T, void* stream) { 89+void gate_attn(const float* attn, const float* q_full, uint16_t* out16, int64_t T, void* stream, int64_t ld16) { 90+ if (ld16 != 0) { std::fprintf(stderr, "gate_attn: new optional path is not ported to SYCL\n"); std::exit(1); } 91+ 92 { 93 auto exp_props = sycl::ext::oneapi::experimental::properties{ 94 sycl::ext::oneapi::experimental::use_root_sync}; 95--- a/sycl/src/core/pinned.dp.cpp 96+++ b/sycl/src/core/pinned.dp.cpp 97@@ -499,7 +499,10 @@ 98 } 99 100 LoadStats load_experts_direct(const std::string& path, uint8_t* dst, const std::vector<uint64_t>& layer_off, 101- const std::vector<uint64_t>& layer_bytes, int threads, uint64_t chunk) { 102+ const std::vector<uint64_t>& layer_bytes, int threads, uint64_t chunk, const std::atomic<int>* ready) { 103+ // Current SYCL arena registers synchronously; deferred registration is not enabled. 104+ if (ready != nullptr) { LoadStats st; st.ok=false; st.error="SYCL deferred reader is not supported"; return st; } 105+ 106 LoadStats st; 107 st.ok = false; 108 #ifdef _WIN32 109@@ -640,7 +643,10 @@ 110 } 111 112 LoadStats load_experts_ranges(const std::string& path, uint8_t* dst, const std::vector<uint64_t>& layer_off, 113- const std::vector<uint64_t>& layer_bytes, int threads, uint64_t chunk) { 114+ const std::vector<uint64_t>& layer_bytes, int threads, uint64_t chunk, const std::atomic<int>* ready) { 115+ // Current SYCL arena registers synchronously; deferred registration is not enabled. 116+ if (ready != nullptr) { LoadStats st; st.ok=false; st.error="SYCL deferred reader is not supported"; return st; } 117+ 118 LoadStats st; 119 const uint64_t layers = (uint64_t) layer_off.size(); 120 st.layers = layers; 121--- a/sycl/src/core/expert_source.cpp 122+++ b/sycl/src/core/expert_source.cpp 123@@ -863,6 +863,28 @@ 124 } 125 } 126 fill_many(todo); 127+} 128+ 129+bool FileExpertSource::advise_pairs(const std::pair<int32_t, int32_t>* pairs, int64_t n) const { 130+ if (base_ == nullptr || !direct_.empty() || !strata::platform::read_ahead_enabled()) return false; 131+ for (int64_t i = 0; pairs != nullptr && i < n; ++i) { 132+ const int64_t l = pairs[i].first, e = pairs[i].second; 133+ if (l < 0 || e < 0 || l >= n_layers_ || e >= n_expert_) continue; 134+ if (role_ptr_.empty()) { // experts.bin: the blob is one contiguous range 135+ if (const uint8_t* b = mapped_blob(l, e)) strata::platform::advise_willneed(b, layer_blob_bytes_[(size_t) l]); 136+ continue; 137+ } 138+ for (int r = 0; r < 3; ++r) { 139+ const size_t k = (size_t) (3 * l + r); 140+ strata::platform::advise_willneed(role_ptr_[k] + (size_t) ((uint64_t) e * role_bytes_[k]), role_bytes_[k]); 141+ } 142+ } 143+ return true; 144+} 145+ 146+uint64_t FileExpertSource::release(int64_t layer, int64_t expert) { 147+ // File-page trimming is Windows-only upstream; Linux keeps its existing mapping. 148+ (void)layer; (void)expert; return 0; 149 } 150 151 void FileExpertSource::fill_many(const std::vector<Fill>& todo) { 152--- a/sycl/src/core/vmm_stub.cpp 153+++ b/sycl/src/core/vmm_stub.cpp 154@@ -0,0 +1,16 @@ 155+#include "strata/core/vmm.hpp" 156+// SYCL has no CUDA VMM; elastic KV remains unavailable, as on HIP. 157+namespace strata::core { 158+bool vmm_available() { return false; } 159+uint64_t vmm_granularity() { return 0; } 160+VmmChunk vmm_chunk_new() { return 0; } 161+void vmm_chunk_free(VmmChunk) {} 162+bool VmmRange::reserve(uint64_t) { return false; } 163+void VmmRange::release() {} 164+int64_t VmmRange::mapped_count() const { return 0; } 165+bool VmmRange::map_one(int64_t, VmmChunk) { return false; } 166+bool VmmRange::set_access(int64_t, int64_t) { return false; } 167+bool VmmRange::commit_run(int64_t, int64_t) { return false; } 168+VmmChunk VmmRange::unmap(int64_t) { return 0; } 169+} // namespace strata::core 170+ 171--- a/sycl/CMakeLists.txt 172+++ b/sycl/CMakeLists.txt 173@@ -135,7 +135,7 @@ 174 # --- the GPU engine ------------------------------------------------------------------------------------------------ 175 strata_resolve(_core src/core/device.cu src/core/pinned.cu src/platform/memory.cpp src/core/graph.cpp 176 src/core/weights.cpp src/core/layout.cpp) 177-add_library(strata_core STATIC ${_core}) 178+add_library(strata_core STATIC ${_core} ${CMAKE_CURRENT_SOURCE_DIR}/src/core/vmm_stub.cpp) 179 target_link_libraries(strata_core PUBLIC strata_includes) 180 181 set(_kernel_cu dequant_s2 s2_gemv s_gemv s2_gemv_quads s2_gemv_fast router_top10 quantize_act rope sampler s2_gemv_q8