Skip to content

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: follow #626 (ThreadAffinity) and #559 (NativeDense::load layer range) so v0.1.39 compiles

sarashin9661ecb8822e
diff --git a/sycl/include/strata/core/session.hpp b/sycl/include/strata/core/session.hpp
index af9cbfc77..3bb6e9d41 100644
--- a/sycl/include/strata/core/session.hpp
+++ b/sycl/include/strata/core/session.hpp
@@ -18,6 +18,7 @@
#include <dpct/dpct.hpp>
#include "strata/core/hit_hook.hpp"
#include "strata/core/layer.hpp"
+#include "strata/kernels/cpu/pool.hpp"
#include <cstdint>
#include <string>
@@ -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 4007db4b8..af95caaff 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<std::string> &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.<l>. 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<std::string> &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 2c75bde59..308540493 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<int> 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) {