Files
Strata/engine
Niko1221 fd203ddf6a fix(inkling2/cuda): do not reuse a stale converted X buffer between mixed-format attention projections (#6788)
From PR #6788 by @paperniuk.

On Inkling-2-Mini-SQ-15 the attention weights of one layer are in two formats (wq_du and gate_attn
Q8_ROW; wr_du, wk_dv and wv_dv BF16). linear_multi() ran them one by one with reuse_x_bf16 = (i > 0),
which assumes the first projection already converted X into d_x_bf16; the Q8_ROW GEMV never does, so the
BF16 GEMMs read whatever an earlier GEMM had left there. The same prompt then answered differently
depending on what ran before it (prefill M = 4..16).

linear_x_cache_fmt() says which format linear() converts X into for a weight, linear_cached() reuses the
buffer only when it already holds that format; used in the linear_multi() fallback and in the M > 16 QKV
block. The pre-quantized Q8_ROW path checks cur_moe_ws and the xq_sk capacity like linear() does.

Checked here on three cards: SQ-15, prompts of 15, 19, 15 (and more) tokens, greedy, --draft off. On
origin/main the 15-token prompt answers with one token repeated (6648, 24757, 68911 ... depending on the card)
or a different text on every repeat; with this change every run gives the same right answer
(140215, 68014, 68025, 220, 16, 13 ...), 4 and 2 repeats identical.
- Tesla V100 16 GB (sm_70, the FP16 attention path), so the PR fixes Volta too, not only sm_120.
- RTX 3060 12 GB (sm_86), 9 prompts of 8..19 tokens, 4 repeats of the 15-token one.
- RTX 4090 24 GB (sm_89), 25000 and 40000 token prompts give the same tokens as origin/main.
2026-11-23 11:19:41 +01:00
..