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++

prefill: look up the APR sign vectors at the layout's widths, not 640 / N

Laurent Zuijdwijkdd32704d4d76
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp
index 881d1c88e..ddd7288a0 100644
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -1232,6 +1232,16 @@ bool Prefill::init(const core::WeightTable& wt, const core::ModelGeometry& g, co
if (g.n_embd != N || g.hc != HC || g.hc_lr != LR || g.n_expert < 1 || ss.k != K) {
err = "prefill: geometry differs from the artifact's"; return false;
}
+ { // a native pack's experts: this path's expert buffers and products (and so their Hadamard rotations) are
+ // N wide in and 640 wide in the middle; the sign vectors are looked up at the layout's own widths
+ const strata::kernels::cpu::ExpertLayout& lay = strata::kernels::cpu::expert_layout();
+ for (size_t l = 0; lay.native && l < lay.fmt.size(); ++l)
+ if (lay.fmt[l].n_embd != N || lay.fmt[l].n_ff != 640) {
+ err = "prefill: layer " + std::to_string(l) + "'s experts are " + std::to_string(lay.fmt[l].n_embd) +
+ " x " + std::to_string(lay.fmt[l].n_ff) + ", not the artifact's 2560 x 640";
+ return false;
+ }
+ }
cudaGetDevice(&m.device);
if (stage_le_ < 0) stage_le_ = g.n_layers;
if (stage_lb_ < 0 || stage_lb_ >= stage_le_ || stage_le_ > g.n_layers || (stage_le_ < g.n_layers) != (next_ != nullptr)) {
@@ -3240,8 +3250,8 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
const bool had_d = lay.native && lay.fmt[(size_t) l].had_d;
const bool use_mmq = mmq_plan().any && mmq_plan().layer[(size_t) l];
const int had_block = lay.native ? lay.fmt[(size_t) l].had_block : 0;
- const float* had_sx = had_gu ? strata::kernels::hadamard_device_signs(lay.fmt[(size_t) l].gu_signs, N) : nullptr;
- const float* had_sh = had_d ? strata::kernels::hadamard_device_signs(lay.fmt[(size_t) l].d_signs, 640) : nullptr;
+ const float* had_sx = had_gu ? strata::kernels::hadamard_device_signs(lay.fmt[(size_t) l].gu_signs, (int) lay.fmt[(size_t) l].n_embd) : nullptr;
+ const float* had_sh = had_d ? strata::kernels::hadamard_device_signs(lay.fmt[(size_t) l].d_signs, (int) lay.fmt[(size_t) l].n_ff) : nullptr;
const int mmq_gt = lay.native ? lay.fmt[(size_t) l].gu_type : 42;
const int mmq_dt = lay.native ? lay.fmt[(size_t) l].d_type : 42;
// --peer-device: MMQ only, whether or not the peer took the prompt path (set_peer can decline), as