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++
metal: the quant yardstick on Metal - window_logprobs from the window's head logits; head logits in every window under STRATA_LOGPOS
Niko122131f26683c21c
diff --git a/metal/src/engine/window.cpp b/metal/src/engine/window.cppindex 3f96ef60a..03f227d75 100644--- a/metal/src/engine/window.cpp+++ b/metal/src/engine/window.cpp@@ -2367,7 +2367,10 @@ bool window_ensure(const strata::core::ModelGeometry& g, strata::core::SessionStreturn window_init(window_create(), g, ss, MAXT, max_cells, &nv, err);}bool window_run(void* w, int T, const int32_t* tokens, int64_t pos0, bool head, int32_t* out, std::string& err) {- return ((Window*) w)->run(T, tokens, pos0, head, out, err);+ // STRATA_LOGPOS (the quant yardstick, the KL harness): every window's head logits are read, also the prompt's+ // windows that sample nothing (head_sampling off)+ static const bool logpos = std::getenv("STRATA_LOGPOS") != nullptr;+ return ((Window*) w)->run(T, tokens, pos0, head || logpos, out, err);}void window_reset() {if (g_the_window != nullptr && g_the_window->ready()) g_the_window->reset();diff --git a/src/core/verify.cpp b/src/core/verify.cppindex ca9876f58..e141418e3 100644--- a/src/core/verify.cpp+++ b/src/core/verify.cpp@@ -2467,6 +2467,19 @@ bool Verifier::window_logprobs(const int32_t* targets, int T, int64_t pos0, int3std::string& err) {if (next_ != nullptr) return next_->window_logprobs(targets, T, pos0, extra_id, out, err);const OnDevice on_device(device_);+#if defined(STRATA_GPU_METAL)+ // the head logits are the Metal window's (window_copy_logits, row by row)+ if (n_vocab_ <= 0 || T <= 0 || targets == nullptr || out == nullptr) {+ err = "window_logprobs: no head logits for this window";+ return false;+ }+ std::vector<float> h((size_t) T * (size_t) n_vocab_);+ for (int t = 0; t < T; ++t)+ if (!strata::metal_engine::window_copy_logits(metal_, t, h.data() + (size_t) t * (size_t) n_vocab_)) {+ err = "window_logprobs: the head logits copy failed";+ return false;+ }+#elseif (head_logits_ == nullptr || n_vocab_ <= 0 || T <= 0 || targets == nullptr || out == nullptr) {err = "window_logprobs: no head logits for this window";return false;@@ -2477,6 +2490,7 @@ bool Verifier::window_logprobs(const int32_t* targets, int T, int64_t pos0, int3err = "window_logprobs: the head logits copy failed";return false;}+#endiffor (int t = 0; t < T; ++t) {const float* row = h.data() + (size_t) t * (size_t) n_vocab_;const int32_t tgt = targets[t];