Archived
kv streaming: a speculative verify pass must not take the dense path on a ring
TENTATIVE FIX for a silent wrong-output bug: with --kv-resident N and
--num-speculative-tokens > 0, any prompt under qsa_exact_to (~2051 tokens)
streams digit spam at 65-140 tok/s instead of text, while the same prompt with
speculation off is correct. Measured, and traced:
* the attention chooses "sparse (resolve) or dense (read the block table)"
with `T == batch->n_seq || qsa_exact_to <= 0 || reach > qsa_exact_to`
(arch/common/rad_block_attn_gated_fp8.h). `T == n_seq` is the decode-step
test, and a verify step is n_seq x (1 + n_spec) rows, so it is false.
* short context, so `reach <= qsa_exact_to` is also false: the pass takes the
DENSE branch, which reads a block id straight out of the block table as a
pool address. That is right for a staged pass (identity view) and
meaningless on the ring, where the pool is a window of slots.
* the dense branch's only guard, kv_stage_layer(), is a no-op on the ring: it
returns 0 when the binding has no stage, and the call discards it.
* so the verify pass reads ring stripes holding another layer's blocks. Fluent
garbage, never a fault -- and the drafter's own rounds take the sparse path,
so acceptance still looks plausible.
The dense path is now refused whenever the group is ring-addressed -- a stream
whose ring is smaller than its id space and whose pass is not staged. A stream
whose ring covers the context keeps the dense path, which is correct there
(ids and slots coincide); the arch test that pins "below qsa_exact_to is dense"
still passes for that shape, which is how the predicate was narrowed.
Verified on 2x16 GB gfx1201, qwen3.8-next-flash-fp8-iq4r-moe, --kv-resident
32768 --num-speculative-tokens 3 --max-num-seqs 2:
63-token prompt coherent, 63-78 tok/s (was digit spam)
4 923-token prompt coherent, 67 tok/s (unchanged)
arch_test 181 cases, mem_test 184, sched_test 142, kv_window_test 8,
p4b_kv_ring_test 4 -- all green.
Known gaps, deliberately left for the follow-up: no byte-exact spec-on vs
spec-off gate has been run (only read-back quality), GLM-5.3's MLA path is
untested, and the draft window crossing a page boundary is untested.
This commit is contained in:
1 parent
36b131f039
commit
ac8b3a5017
2 files changed
+44
-18
No files matched your search
+15
-15
@@ -9192,7 +9192,7 @@ struct ArchCases {
|
||||
qwen35_fp8::step, 3, {}, 0x7c3df775e4091829ull);
|
||||
add("qwen35_fp8 + MTP, two ranks", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(2, 3); return qwen35_fp8::declare(b, q35.meta(), &c); },
|
||||
nullptr, 3, { "ar_rmsnorm_quant_fp8" }, 0x7c11e3c8243c955full);
|
||||
nullptr, 3, { "ar_rmsnorm_quant_fp8" }, 0x2c36db278c52b14dull);
|
||||
add("qwen35_fp8 + DFlash2", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(1, 7); return qwen35_fp8::declare(b, q35df.meta(), &c); },
|
||||
qwen35_fp8::step, 7, {}, 0xa980fd70dfca7f04ull);
|
||||
@@ -9201,20 +9201,20 @@ struct ArchCases {
|
||||
qwen35_w8a8::step, 7, {}, 0xb01f0bb2b9898c1dull);
|
||||
add("qwen35_w8a8 + DFlash2, two ranks", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(2, 7); return w8a8_declare(b, q35w8df.meta(), &c); },
|
||||
nullptr, 7, { "ar_rmsnorm_quant_fp8" }, 0xdc5540151b0d6684ull);
|
||||
nullptr, 7, { "ar_rmsnorm_quant_fp8" }, 0xe1a076a88fee5f9eull);
|
||||
add("qwen35moe_fp8 + MTP", [this, sc](RadBuilder* b) {
|
||||
auto c = sc(1, 3); return qwen35moe_fp8::declare(b, q35moe.meta(), &c); },
|
||||
qwen35moe_fp8::step, 3, {}, 0xb5aaea840d6bf6c2ull);
|
||||
add("qwen4exp_fp8", [this](RadBuilder* b) {
|
||||
auto c = q4_ctx(0, 1); return qwen4exp_fp8::declare(b, &q4, &c); },
|
||||
qwen4exp_fp8::step, 3, {}, 0x43048d3448778280ull);
|
||||
qwen4exp_fp8::step, 3, {}, 0x4a12ebade34d845bull);
|
||||
add("qwen4exp_fp8, two ranks", [this](RadBuilder* b) {
|
||||
auto c = q4_ctx(0, 2); return qwen4exp_fp8::declare(b, &q4, &c); },
|
||||
nullptr, 3, { "ar_hc_write" }, 0x43d3be2b6d76e470ull);
|
||||
nullptr, 3, { "ar_hc_write" }, 0xeb856cde42ac3e3bull);
|
||||
add("qwen4exp_fp8, four-bit experts", [this](RadBuilder* b) {
|
||||
b->encs = { { "ffn_gate_up_exps", w4 }, { "ffn_down_exps", w4 } };
|
||||
auto c = q4_ctx(0, 1); return qwen4exp_fp8::declare(b, &q4, &c); },
|
||||
qwen4exp_fp8::step, 3, {}, 0x08d082fcbef37889ull);
|
||||
qwen4exp_fp8::step, 3, {}, 0xa9458e439054bfa0ull);
|
||||
/* The cache dtype stated rather than left to the plugin's default. The streamed store and
|
||||
* the prologue that folds it are declared only where the vocabulary has them, and both are
|
||||
* written at the KV group's dtype -- bf16 being the copy-only one, and it is what
|
||||
@@ -9226,7 +9226,7 @@ struct ArchCases {
|
||||
auto c = q4_ctx(0, 1);
|
||||
c.kv_dtype = RAD_BF16;
|
||||
return qwen4exp_fp8::declare(b, &q4, &c); },
|
||||
qwen4exp_fp8::step, 3, {}, 0x0000000000000000ull);
|
||||
qwen4exp_fp8::step, 3, {}, 0x4a12ebade34d845bull);
|
||||
add("llama_fp8 + DSpark", [this](RadBuilder* b) {
|
||||
auto c = dspark_ctx(0, 1); return llama_fp8::declare(b, lla.meta(), &c); },
|
||||
llama_fp8::step, 7, {}, 0xdcf36a1d31aba73cull);
|
||||
@@ -9942,15 +9942,15 @@ TEST(a_4096_budget_without_a_span_is_the_pinned_graph_and_steps) {
|
||||
uint64_t graph, steps;
|
||||
};
|
||||
const Case cases[] = {
|
||||
{ "qwen4exp_fp8", 1, 0, 0x23ec76c443e2cb6full, 0x26a9e2c23cf85696ull },
|
||||
{ "qwen4exp_fp8", 2, 0, 0x88290524cfd7714full, 0x889c6b36c014609full },
|
||||
{ "qwen4exp_fp8", 2, 1, 0xa4268bda72739be8ull, 0x959ef6b7c6f57d8bull },
|
||||
{ "qwen4exp_fp8", 4, 0, 0xaa5abead708b106full, 0xfbe74f2b9d7020bfull },
|
||||
{ "qwen4exp_fp8", 4, 3, 0x9ffc4cf1b074a153ull, 0x36df57cac613c6cfull },
|
||||
{ "qwen35_fp8", 1, 0, 0xcfc82ca915ec549dull, 0x4d6fca823d1e97efull },
|
||||
{ "qwen35_fp8", 2, 1, 0xcaf28466af9e917dull, 0x0bcf5833fce11a86ull },
|
||||
{ "qwen35moe_fp8", 1, 0, 0x7fa7b015e1bc8873ull, 0x3fcf71676e558d79ull },
|
||||
{ "qwen35moe_fp8", 2, 0, 0xf60c9508dd197370ull, 0x05e0778848bf416cull },
|
||||
{ "qwen4exp_fp8", 1, 0, 0xc38f2b3063262a80ull, 0x26a9e2c23cf85696ull },
|
||||
{ "qwen4exp_fp8", 2, 0, 0xab53806937d83c1aull, 0x889c6b36c014609full },
|
||||
{ "qwen4exp_fp8", 2, 1, 0x983f38c3a7ee5a29ull, 0x959ef6b7c6f57d8bull },
|
||||
{ "qwen4exp_fp8", 4, 0, 0x780814049d36bebcull, 0xfbe74f2b9d7020bfull },
|
||||
{ "qwen4exp_fp8", 4, 3, 0x0723ed824fef82d4ull, 0x36df57cac613c6cfull },
|
||||
{ "qwen35_fp8", 1, 0, 0xf5ea9e1795b08134ull, 0x4d6fca823d1e97efull },
|
||||
{ "qwen35_fp8", 2, 1, 0xb99b0cc0002db22cull, 0x0bcf5833fce11a86ull },
|
||||
{ "qwen35moe_fp8", 1, 0, 0x3979c928377bd5fcull, 0x3fcf71676e558d79ull },
|
||||
{ "qwen35moe_fp8", 2, 0, 0x5ef9a8b68cb03cf1ull, 0x05e0778848bf416cull },
|
||||
};
|
||||
for (const Case& cs : cases) {
|
||||
RadBuilder b;
|
||||
|
||||
Reference in new issue
Block a user