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

verify: the batched K/V append writes a streamed K8V4 state's host copy (#1188, #1169)

Benjamin Larsson35435e3d2680
diff --git a/src/core/verify.cpp b/src/core/verify.cpp
index 2811c9cf1..0acea637d 100644
--- a/src/core/verify.cpp
+++ b/src/core/verify.cpp
@@ -947,10 +947,15 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
const float* kc_b = kcur_ + tb * NKV * HD;
const float* vc_b = vcur_ + tb * NKV * HD;
if (st.kv_hybrid) { // K8V4: the unused half's lanes folded onto the used pool (layer.cpp)
+ // #1188: a streamed state's host copy gets the window's cells too, as the per-token path below
+ // writes them - without it a block that was not resident when its cells were appended came
+ // back from the host copy without them, and free generation degenerated into repetition
+ const KvHostPools hk = kv_hybrid_k_half(st.host), hv = kv_hybrid_v_half(st.host);
+ const bool mirror = st.host.present();
kv_append_q8_steps(st.k_q, st.k_q, st.k_scale, st.k_scale, st.page_table, step_b, kStepCount,
- kc_b, kc_b, (int) (NKV * HD), n, s, cs, nullptr);
+ kc_b, kc_b, (int) (NKV * HD), n, s, cs, mirror ? &hk : nullptr);
kv_append_q4_steps(st.v_q4, st.v_q4, st.page_table, step_b, kStepCount, n, vc_b, vc_b, s, cs,
- nullptr);
+ mirror ? &hv : nullptr);
} else if (st.kv_q4)
kv_append_q4_steps(st.k_q4, st.v_q4, st.page_table, step_b, kStepCount, n, kc_b, vc_b, s, cs,
&st.host);