attn gated fp8: issue a mixed step's dense attention once per band

A step that mixes decoding sequences with a prefill chunk issued the dense attention once, at band
max_q_len, so the decode rows ran through the prefill kernel: one workgroup per KV head walking the
decoder's whole context. With a decoder at 188k beside a 2048-row chunk that tail set the step time.

In a MIXED step the attention is now issued twice:
- the decode half at the decode band (served by the split-KV decode row); at most max_seqs - 1
  sequences of at most the decode band's rows, which its declared scratch covers;
- the prefill half always at the op's top band, which selects the query-tiled prefill row built for
  launches over part of a step (absolute cu from entry D, as the GDN block issues its prefill half and
  as ArPieces issues its pieces); the kernels read exact lengths from cu. At its own query length a
  chunk of 10 rows or fewer would select the decode row, which sizes its partials from the whole
  step's rows and has no cu span.
A chunk no longer than the verify blocks beside it keeps the single launch (the step is decode-
shaped). Pure decode and pure prefill steps issue exactly as before (graph pins unchanged; only the
pinned steps that contain a mixed step move).

RADIANCE_ATTN_BAND_SPLIT=0 restores the single issue.

Measured on 2x Radeon AI PRO R9700, Qwen3.8-27B MXFP4, TP 2: one sequence decoding after a 188k
prompt while a fresh 25k prompt arrives (2 rounds each):
- mixed step 510 / 508 ms -> 211 / 211 ms
- the new prompt's prefill 11.3 / 11.3 s -> 5.0 / 5.0 s (the same as beside a 0.7k decoder)
- the decoder's rate over the window 85 / 82 -> 109 / 103 tok/s
30 minutes of mixed serving load (12 decoding streams with speculation, fresh 25k / 41k prompts,
cached re-sends that prefill a few-row suffix, TranslateGemma beside): 0 errors, 0 restarts.

Tests: arch_test qwen35_fp8_issues_a_mixed_steps_attention_once_per_band (both halves' operands, the
prefill half at the top band for a short chunk, the single launch when the chunk is not longer than
the verify blocks, one issue per layer for pure steps); r4d_selftest attn_mixed_step (production
per-rank geometry, scratch bound exactly as the engine binds it per band, 15 decode sequences of 8-10
rows beside chunks of 1 to 640 rows).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-26 09:20:22 +01:00
1 parent 6a7824a837
commit 5c1c71b147
4 files changed
+316 -12

No files matched your search

+3 -3
View File
@@ -189,9 +189,9 @@ typedef struct RadBatch {
/* The longest query in each half. max_q_len over a mixed step is the prefill chunk's, and
* banding the decode half with it would give eight rows a thousand-row GEMM's band.
*
* Only the decode value is currently read (by the GDN blocks). The prefill value is for a
* block whose prefill path bands on a per-sequence query length; the GDN prefill ops band on
* the step's total tokens, taken from their operands. */
* The decode value is read by the GDN blocks and the fp8 gated attention's per-band issue
* (rad_block_attn_gated_fp8.h), which also bands its prefill half on the prefill value; the
* GDN prefill ops band on the step's total tokens, taken from their operands. */
int32_t max_q_len_decode;
int32_t max_q_len_prefill;