Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sycl/include/strata/core/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions sycl/src/core/native_dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions sycl/src/core/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down