From 9a8563b80ab4a21ee175446a0a9663bb749e3c2c Mon Sep 17 00:00:00 2001 From: sarashin Date: Sun, 4 Oct 2026 23:37:13 +0900 Subject: [PATCH] sycl: follow #626 (ThreadAffinity) and #559 (NativeDense::load layer range) so v0.1.39 compiles The sycl port went in as 5047172 ("sycl: port 0.1.39"). Two engine-side changes were merged into the release branch after it (cb97e6c, 1189218) and nothing in sycl/ was updated for them, so the v0.1.39 tag does not compile: - #626 (ec35cf0) made the thread affinity a value: pin_current_thread() returns strata::kernels::cpu::ThreadAffinity and restore_thread_affinity() takes it. sycl/include/strata/core/session.hpp still stored a `long long` (no conversion exists, and it did not include the header that names the type); sycl/src/core/session.cpp still assigned the returned struct to it and passed the `long long` back. - #559 (ba707d8) added the two layer-range arguments to NativeDense::load. The sycl out-of-line definition was still the 4-argument one and no longer matched the declaration in include/strata/core/native_dense.hpp. Both are fixed by mirroring the CUDA sources: the same member type, the same `outside()` predicate, and the same place it is applied in the tensor loop. `pinned` now follows CUDA as well: it is pinned_core.valid, so a pin that failed is not "restored". Nothing changes when the pin succeeds. No caller passes layer_lo/layer_hi yet, so `outside()` is never true today: this restores the build and does not change what the engine computes. Measured here: Arch Linux, Intel oneAPI DPC++ 2026.0.0 + oneMKL 2026.0, SPIR-V (JIT), cmake -S sycl -B build-sycl -G Ninja -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx, then `cmake --build build-sycl --target strata -- -k 0` -> 0 errors, links. The two errors are a type and a declaration mismatch, so the compiler version does not matter. Not built here: the other targets (kernel parity tests, benches) and the AOT path. Not run on an Arc in this change. --- sycl/include/strata/core/session.hpp | 3 ++- sycl/src/core/native_dense.cpp | 9 +++++++-- sycl/src/core/session.cpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sycl/include/strata/core/session.hpp b/sycl/include/strata/core/session.hpp index af9cbfc777a..3bb6e9d41a2 100644 --- a/sycl/include/strata/core/session.hpp +++ b/sycl/include/strata/core/session.hpp @@ -18,6 +18,7 @@ #include #include "strata/core/hit_hook.hpp" #include "strata/core/layer.hpp" +#include "strata/kernels/cpu/pool.hpp" #include #include @@ -375,7 +376,7 @@ struct SessionLoopScratch { float* y_miss = nullptr; ///< pinned host staging for the pool's answer, `parts_bytes` long size_t parts_bytes = 0; dpct::event_ptr probe = nullptr; - long long pinned_core = -1; ///< the affinity to restore, or -1 if the host was never pinned + strata::kernels::cpu::ThreadAffinity pinned_core{}; ///< affinity to restore, or invalid if the host was not pinned bool pinned = false; /// Allocates the buffers and pins the host thread. Call ONCE, at session setup. diff --git a/sycl/src/core/native_dense.cpp b/sycl/src/core/native_dense.cpp index 4007db4b86c..af95caaff56 100644 --- a/sycl/src/core/native_dense.cpp +++ b/sycl/src/core/native_dense.cpp @@ -86,7 +86,12 @@ NativeDense::~NativeDense() { bool NativeDense::load(const std::vector &shards, WeightTable &table, std::string &err, - bool include_ple_key) try { + bool include_ple_key, int64_t layer_lo, int64_t layer_hi) try { + auto outside = [&](const std::string &name) { // a blk.. tensor of another stage's layers + if (layer_hi < 0 || name.rfind("blk.", 0) != 0) return false; + const long l = std::strtol(name.c_str() + 4, nullptr, 10); + return l < layer_lo || l >= layer_hi; + }; if (scratch_ || !weights_.empty()) { err = "native dense: already loaded"; return false; } if (shards.empty()) { err = "native dense: at least one GGUF shard is required"; return false; } try { @@ -155,7 +160,7 @@ bool NativeDense::load(const std::vector &shards, } } for (const auto& tensor : gguf.tensors()) { - if (!eligible(tensor, include_ple_key)) continue; + if (!eligible(tensor, include_ple_key) || outside(tensor.name)) continue; if (!in_range(tensor.name) && tensor.name.find("ple") == std::string::npos) continue; if (!seen.insert(tensor.name).second) { err = "native dense: duplicate tensor " + tensor.name; return false; diff --git a/sycl/src/core/session.cpp b/sycl/src/core/session.cpp index 2c75bde594c..30854049388 100644 --- a/sycl/src/core/session.cpp +++ b/sycl/src/core/session.cpp @@ -784,7 +784,7 @@ bool SessionLoopScratch::init(size_t parts_bytes_in, std::string &err) try { const std::vector cores = strata::kernels::cpu::physical_cores(false); if (!cores.empty()) { pinned_core = strata::kernels::cpu::pin_current_thread(cores[0]); - pinned = true; + pinned = pinned_core.valid; } return true; } @@ -800,7 +800,7 @@ void SessionLoopScratch::free() { if (pinned) { strata::kernels::cpu::restore_thread_affinity(pinned_core); pinned = false; - pinned_core = -1; + pinned_core = {}; } if (probe != nullptr) { dpct::destroy_event(probe); probe = nullptr; } if (y_miss != nullptr) {