qsa: skip score/select where no attention reads them; select once per pass below the exact bound

Architecture-only (no kernel, op schema or graph change). The attention block tells the indexer
whether it reads the selection (AttnGatedFP8::qsa_use): dense steps (<= 1024 tokens of context)
issue no query norm, qsa_score or qsa_select; single-row-per-sequence steps under the exact bound
read the block table; multi-row steps under the bound select once per pass (the selection is
layer-invariant there, every complete block in block order) and the other QSA layers reuse it.
Block keys and tail run every step. The exact host bound (RadBatch::kv_used_max_h) decides which
side of the bound a step is on and keys the pass. RADIANCE_DEBUG_QSA_EAGER=1 restores the old
issue pattern.

arch_test: the pinned step hashes of qwen4exp_fp8 move (graphs unchanged) and two tests pin the
new issue pattern; ref_test pins the equalities it rests on (qsa_select below the bound).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 authored and StillDeadcode committed 2026-11-17 18:41:16 +01:00
1 parent 315aea7db9
commit cfec01ec8d
8 files changed
+515 -30

No files matched your search

+23
View File
@@ -1466,6 +1466,29 @@ inline void batch_split(const RadBatch* b, int64_t* n_seq_dec, int64_t* n_tok_de
}
}
/* What a step's attention reads of the QSA selection (AttnGatedFP8::qsa_use), which decides what
* the indexer issues for the layer (QsaIndexer::step, docs/QSA.md "Below the bound"):
*
* kQsaSelect score and select, per layer: a step past the exactness bound, a streamed group,
* and every step of a block that did not ask for the forms below;
* kQsaUnread nothing reads the selection: the step is entirely at or below the bound and its
* attention is the dense one, or the sparse row over the sequence's own block table
* (one row a sequence), which is what the selection would be. The indexer stores its
* keys and tail and issues no query, score or select;
* kQsaOnce the attention reads a selection (the sparse row a query) on a step entirely at or
* below the bound: every complete block is taken whatever it scores, so the
* selection depends on the positions and the block table alone and is the same
* bytes at every layer. The first full-attention layer of the pass issues it as
* always; no later layer issues a query, a score or a select. */
enum QsaUse : int { kQsaSelect = 0, kQsaUnread = 1, kQsaOnce = 2 };
/* RADIANCE_DEBUG_QSA_EAGER: every step is kQsaSelect, the issue sequence before the forms above
* existed. An instrument for comparing the two (the text must not move); read once. */
inline bool qsa_eager() {
static const bool on = std::getenv("RADIANCE_DEBUG_QSA_EAGER") != nullptr;
return on;
}
/* The step batch's entry for one declared KV group (built once per step by the core, spec §8). */
inline const RadKVGroupBatch* kv_batch(const RadBatch* b, rad_kvgroup group) {
for (int i = 0; i < b->n_kv_groups; ++i)
+68 -7
View File
@@ -79,6 +79,21 @@ struct AttnGatedFP8 {
/* `sel`'s row pitch is `topk + 1`; the extra slot is the partial page
* (r4d_qsa_select_bf16.hip). */
int64_t qsa_topk = 0;
/* The architecture's word that a sequence with one row in the step has that row at its
* context's last position (`seqused - 1`: a plain decode row, a serial head's round), so at or
* below `qsa_exact_to` such a row's selection is the head of the sequence's block table and its
* `seqused` the sequence's (qsa_select: every complete block in block order, then the partial
* page, and `pos + 1`). The sparse row is then issued over the table and the indexer selects
* nothing (qsa_use). Off: such a step keeps the selection. */
bool qsa_table_rows = false;
/* The architecture's pass key carries whether this group's exact host bound
* (RadBatch::kv_used_max_h, the furthest context any row of the step can read) is within
* `qsa_exact_to`, so that bound may say whether the step needs scores (qsa_within) in place of
* the rounded `max_ctx_len + max_q_len`, which a 4-row step leaves at 1025 tokens. It never
* moves the choice between the dense and the sparse kernel, which stays the rounded bound's:
* the two agree on the keys, not on the last bit of the sum. Off: the rounded bound, which the
* core's key holds. */
bool qsa_exact_host = false;
/* Query rows per sparse attention launch, a scratch budget. The decode kernel's split-KV
* partials are sized at declare from `max_seqs` and `q_len`, so issuing more rows than
* `max_seqs` means declaring a larger value, which grows the scratch arena (the maximum over
@@ -185,6 +200,41 @@ struct AttnGatedFP8 {
* components agree, so plane 0 of an M-RoPE batch's positions is each token's position) and
* the gate quantised by gate_quant_fp8. A streamed group never takes it: the pieces path's
* plain store never writes the host mirror. */
/* The rounded host bound of the furthest context a row of the step reads; by it a step of
* several rows a sequence takes the dense or the sparse kernel (step(), `sparse`). */
int64_t qsa_reach(const RadBatch* batch) const {
return (int64_t)batch->max_ctx_len + batch->max_q_len;
}
/* Whether every row of the step is at or below the exactness bound, by the tightest host
* ceiling there is: the group's exact one where the pass key holds its side of the bound
* (qsa_exact_host), else the rounded one. Every row's position + 1 is at most either. */
bool qsa_within(const RadBatch* batch, const RadKVGroupBatch* kvb) const {
if (qsa_exact_to <= 0) return false;
int64_t reach = qsa_reach(batch);
if (qsa_exact_host && kvb && batch->kv && batch->kv_used_max_h) {
const int64_t tight = batch->kv_used_max_h[kvb - batch->kv];
if (tight > 0 && tight < reach) reach = tight;
}
return reach <= qsa_exact_to;
}
/* What this step's attention reads of the selection (QsaUse, rad_arch.h); the architecture
* hands it to the indexer, which runs first, and step() takes its path by the same call. */
int qsa_use(const RadBatch* batch) const {
if (!qsa_sel || !qsa_sequ || op_fill || qsa_eager()) return kQsaSelect;
const RadKVGroupBatch* kvb = kv_batch(batch, kv);
/* A streamed group may be ring-bound, where every pass is sparse and the resolve rewrites
* the selection; it keeps the selection at every context. */
if (!kvb || kvb->stream || !kvb->block_table || !kvb->seqused) return kQsaSelect;
if (!qsa_within(batch, kvb)) return kQsaSelect;
/* One row a sequence is the sparse row at every context: over the table where the
* architecture vouches for it, else over a selection. */
if (batch->n_tok == batch->n_seq)
return (qsa_table_rows && batch->max_q_len == 1) ? kQsaUnread : kQsaOnce;
/* Several rows a sequence: the dense attention, which reads the table, where the rounded
* bound is within the budget too, else the sparse row a query over a selection. */
return qsa_reach(batch) <= qsa_exact_to ? kQsaUnread : kQsaOnce;
}
bool takes_pieces(const RadBatch* batch, const ArPieces* pieces) const {
const int64_t T = batch->n_tok;
const RadKVGroupBatch* kvb = kv_batch(batch, kv);
@@ -694,7 +744,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
* Launches are chunked because the split-KV scratch is sized at declare from `max_seqs` and
* `q_len` (rows = max_seqs * q_len_max * heads); more rows are refused as RAD_E_SCRATCH at
* issue. Rows of q_len 1 up to the declared max_seqs always fit. */
const int64_t reach = (int64_t)batch->max_ctx_len + batch->max_q_len;
const int64_t reach = qsa_reach(batch);
/* A pass on a streamed group's ring (a ring smaller than the id space, and not staged) must
* take the sparse path: on the ring a block id is not a pool address, so the dense path would
* read ring slots as pages. `T == n_seq` alone misses a verify pass, whose T is
@@ -708,6 +758,19 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
const bool sparse = qsa_sel && qsa_sequ &&
(ring_bound || T == batch->n_seq || qsa_exact_to <= 0 ||
reach > qsa_exact_to);
/* At or below the bound a step of one row a sequence has no selection (qsa_use): the sparse
* row reads the sequence's own block table and length, which is what qsa_select would have
* written for it (the field says why), so the launch, its kernel and its bytes are the sparse
* row's. */
const bool by_table = sparse && T == batch->n_seq && qsa_use(batch) == kQsaUnread;
const int64_t tpitch = kvb ? kvb->block_table_pitch : 0;
auto sel_rows = [&](int64_t off, int64_t rows) {
return by_table ? praw2(table + off * tpitch, RAD_I32, rows, tpitch)
: brow_slice(qsa_sel, off, rows, qsa_topk + 1);
};
auto sequ_rows = [&](int64_t off, int64_t rows) {
return by_table ? praw(used + off, RAD_I32, rows) : brow_slice(qsa_sequ, off, rows, 1);
};
const bool gated = sparse && op_attn_gq;
/* A streamed group's selection, per launch: make the rows' blocks resident and rewrite `sel`
* as ring slots, after this layer's store (a block copied in from the mirror must carry this
@@ -715,6 +778,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
* and never resolves, so a prefill cannot overflow the ring. */
const KVStreamLayer res_l = op_resolve ? kv_stream_layer(c, kv, layer, kvb) : KVStreamLayer{};
auto resolve_sel = [&](int64_t off, int64_t rows) {
if (by_table) return; /* never a streamed group (qsa_use) */
if (kv_stage_layer(c, kv, kvb, layer)) return;
if (!res_l.host || res_l.blocks <= 0 || res_l.slots <= 0 || rows <= 0) return;
kv_resolve_issue(c, op_resolve, res_l, brow_slice(qsa_sel, off, rows, qsa_topk + 1),
@@ -736,8 +800,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
RAD_ISSUE_N(c, op_attn_gq, 1,
brow_slice(w.q, off, rows, qw),
kv_cache(kv, layer),
brow_slice(qsa_sel, off, rows, qsa_topk + 1),
brow_slice(qsa_sequ, off, rows, 1),
sel_rows(off, rows), sequ_rows(off, rows),
RAD_NONE, RAD_NONE, RAD_NONE,
brow_slice(w.attn.x, off, rows, qw),
bcol_at(w.qg, off, g.n_head * 2 * hd, hd, hd, rows),
@@ -760,8 +823,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
RAD_ISSUE_N(c, op_attn_gq, 1,
brow_slice(w.q, off, rows, qw),
kv_cache(kv, layer),
brow_slice(qsa_sel, off, rows, qsa_topk + 1),
brow_slice(qsa_sequ, off, rows, 1),
sel_rows(off, rows), sequ_rows(off, rows),
RAD_NONE, RAD_NONE, RAD_NONE,
brow_slice(w.attn.x, off, rows, qw),
bcol_at(w.qg, off, g.n_head * 2 * hd, hd, hd, rows),
@@ -777,8 +839,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
RAD_ISSUE_N(c, op_attn, 1,
brow_slice(w.q, off, rows, qw),
kv_cache(kv, layer),
brow_slice(qsa_sel, off, rows, qsa_topk + 1),
brow_slice(qsa_sequ, off, rows, 1),
sel_rows(off, rows), sequ_rows(off, rows),
RAD_NONE, RAD_NONE, RAD_NONE,
brow_slice(w.attn.x, off, rows, qw));
}
+1 -1
View File
@@ -552,7 +552,7 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const {
/* The indexer runs first because the attention reads its selection; `w.h` is already final,
* written by the connection above. */
qsa.step(c, attn.w.h, batch, qsa_win_cu);
qsa.step(c, attn.w.h, batch, qsa_win_cu, attn.qsa_use(batch));
attn.step(c, batch);
hc_attn.write(c, T, 0, T);
+37 -5
View File
@@ -9,7 +9,8 @@
* Contents: the projection and query path, the block-key path with its two states, and the score
* and selection. Below `budget + ratio - 1` tokens of context every visible block is selected, so
* the sparse path must reproduce the dense path's text byte for byte; that is the test for any
* change here.
* change here. A step entirely at or below that bound therefore needs no selection at all, and
* step() issues only the block-key path for it (its `use`; docs/QSA.md, "Below the bound").
*/
#ifndef RAD_QSA_H
#define RAD_QSA_H
@@ -121,9 +122,16 @@ struct QsaIndexer {
int declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const Config& cfg,
const Wire& wire, const ActFP8& in, rad_kvgroup* bk);
/* `win_cu`, device: {0, plane_rows}, the one sequence of a window of a step wider than the
* score plane (Config::plane_rows); null where no step is. */
* score plane (Config::plane_rows); null where no step is.
*
* `use` is what the layer's attention reads of the selection this step (QsaUse, rad_arch.h;
* AttnGatedFP8::qsa_use): the default issues the query, the scores and the selection as every
* step did before. `first` is whether this is the first full-attention layer the pass issues:
* at or below the bound the selection is made there once and read by every layer after it (the
* buffers are the model's, live across its layers, and nothing else writes them). The default
* makes it at every layer. */
void step(RadCtx* c, const ActFP8& in, const RadBatch* batch,
const int32_t* win_cu = nullptr) const;
const int32_t* win_cu = nullptr, int use = kQsaSelect, bool first = true) const;
/* Stores the pass's block keys and tail exactly as step() does, with no query, score or
* selection (see AttnGatedFP8::store_kv). */
void store(RadCtx* c, const ActFP8& in, const RadBatch* batch) const;
@@ -319,13 +327,31 @@ inline void QsaIndexer::store(RadCtx* c_, const ActFP8& in, const RadBatch* batc
}
inline void QsaIndexer::step(RadCtx* c_, const ActFP8& in, const RadBatch* batch,
const int32_t* win_cu) const {
const int32_t* win_cu, int use, bool first) const {
if (!on()) return;
const int64_t T = batch->n_tok, S = batch->n_seq;
const int64_t qw = c.heads * c.head_dim;
const int64_t nw = (c.heads + 1) * c.head_dim;
/* What the attention reads this step (QsaUse); anything asked of a step that cannot give it is
* the full issue, which every reader accepts.
*
* kQsaOnce: the attention reads a selection on a step entirely at or below the exactness
* bound. A row there has at most `topk` complete blocks, so qsa_select takes every one whose
* key is not 0 -- every block with a page and a score that is a number, whatever the number --
* and what it writes (the pages in block order, the partial page, their count, seqused) is a
* function of the positions and the block table: the same bytes from every layer's scores. So
* the pass's first full-attention layer issues the selection exactly as it always did, and
* every later layer reads that one and issues none of its own: no query, no score. */
if (use == kQsaOnce) use = first ? kQsaSelect : kQsaUnread;
if (use != kQsaUnread) use = kQsaSelect;
/* RADIANCE_DEBUG_QSA_EAGER: the issue sequence as it was, every layer its own. */
if (qsa_eager()) use = kQsaSelect;
/* The projection always: its raw-key head is the block keys' and the tail's. */
proj.step(c_, in, w.qk, T);
/* The query heads are read by the score alone. */
if (use == kQsaSelect) {
/* One fused launch or `heads` + 1 unfused. The fused form takes the whole projection at its
* row pitch and writes the query heads contiguous and rotated. `n_head` 0 is the k-only form:
* no q_gate, q_w or q_out, and `gate_out` absent. `T <= qprep_rows` is a correctness bound
@@ -342,8 +368,10 @@ inline void QsaIndexer::step(RadCtx* c_, const ActFP8& in, const RadBatch* batch
bcol_at(w.q, 0, qw, h * c.head_dim, c.head_dim, T));
RAD_ISSUE_N(c_, op_rope, T, brows(w.q, T), rope_posmc(g, batch, T));
}
}
/* The keys first: the selection below reads the blocks they complete. */
/* The keys first: the selection below reads the blocks they complete. The stateful half runs
* whatever the attention reads: later steps score the block keys and build on the tail. */
const RadKVGroupBatch* bkb = kv_batch(batch, kv_bk);
const RadKVGroupBatch* atb = kv_batch(batch, c.kv_attn);
if (!atb || !store_keys(c_, batch)) return;
@@ -352,6 +380,10 @@ inline void QsaIndexer::step(RadCtx* c_, const ActFP8& in, const RadBatch* batch
* is a query row, so each query of a prefill chunk selects from the shared history, as the
* checkpoint does. */
if (!c.emit_sel) return;
/* Nothing reads a selection of this layer's: the step is at or below the exactness bound and
* its attention reads the block table, or the selection the pass's first full-attention layer
* made (AttnGatedFP8::qsa_use). */
if (use == kQsaUnread) return;
/* Narrow the score columns to the live history. Both kernels size their grid from the
* operand's width (the live count is device data), so the full `max_ctx` width would make a
+51 -9
View File
@@ -1172,10 +1172,17 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
lay.attn.qsa_nsel = m.qsaw.nsel;
lay.attn.qsa_sequ = m.qsaw.sequ;
lay.attn.qsa_topk = m.qsacfg.topk;
/* The exactness bound, below which prefill issues the cheaper dense attention.
* Decode ignores it and always takes the sparse path, keeping that path exercised
* on every step. */
/* The exactness bound, at or below which a step of several rows a sequence
* (prefill, a verify) issues the cheaper dense attention. Plain decode keeps the
* sparse row's launch at every context, so that kernel is exercised on every
* step. */
lay.attn.qsa_exact_to = m.qsacfg.budget + m.qsacfg.ratio - 1;
/* At or below that bound the indexer scores nothing (AttnGatedFP8::qsa_use): a
* row alone in its sequence is at the context's last position on this model (a
* plain decode row; the core's and the card's `seqused` is its position + 1), and
* pass_key() carries the exact bound's side of it. */
lay.attn.qsa_table_rows = true;
lay.attn.qsa_exact_host = true;
}
RAD_ARCH_TRY(rad_bind_layer_kv(b, (int)l, m.kv_full));
/* An attention-zero rank keeps no attention cache: its block is a fill of zeros
@@ -1485,6 +1492,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
m.mtp.attn.qsa_sequ = m.qsaw.sequ;
m.mtp.attn.qsa_topk = m.qsacfg.topk;
m.mtp.attn.qsa_exact_to = m.qsacfg.budget + m.qsacfg.ratio - 1;
/* As the trunk's layers: a round's row is the head's context's last position
* (ADV_ROUND), and the history pass is one row only where it commits one. */
m.mtp.attn.qsa_table_rows = true;
m.mtp.attn.qsa_exact_host = true;
ts.qsa = m.qsacfg;
ts.qsa.mode = m.mtp.attn.mode;
ts.qsa.qk_proj = nm.ckpt("%s.layers.0.self_attn.indexer.index_qk_proj.weight", mpre);
@@ -1666,6 +1677,9 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int
if (m.ple_layer == 0) m.ple.step(c, batch);
for (int64_t p = 0; p < K; ++p) m.layers[0].hc_mix.read(c, T, r0(p), rn(p));
}
/* The pass's first full-attention layer with an indexer makes what every such layer shares of
* its step (QsaIndexer::step, `first`). */
bool qsa_first = true;
for (int64_t li = 0; li < n; ++li) {
const Layer& l = m.layers[(size_t)li];
/* The mixer finishes its output a piece at a time where its last stages are per row and
@@ -1674,7 +1688,11 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int
MixAr ms{c, &l};
ArPieces pc{};
pc.rows = R; pc.done = mix_ar_piece; pc.u = &ms; pc.cu = gcu;
if (l.full) { l.qsa.step(c, l.attn.w.h, batch, pcu); l.attn.step(c, batch, false, &pc); }
if (l.full) {
l.qsa.step(c, l.attn.w.h, batch, pcu, l.attn.qsa_use(batch), qsa_first);
if (l.qsa.on()) qsa_first = false;
l.attn.step(c, batch, false, &pc);
}
else l.gdn.step(c, batch, false, &pc);
auto ar_mix = [&](int64_t p) {
if (l.full) l.attn.issue_ar(c, r0(p), rn(p));
@@ -1739,6 +1757,9 @@ static void step_serial(RadCtx* c, const RadBatch* batch, Model& m, const int32_
if (m.op_rope_cs && T <= qk_fuse_rows(g) && !rope_mixed(batch))
RAD_ISSUE_N(c, m.op_rope_cs, T, rope_pos1(batch, T), RAD_B(m.b_rope_cs));
/* The pass's first full-attention layer with an indexer makes what every such layer shares of
* its step (QsaIndexer::step, `first`). */
bool qsa_first = true;
for (int64_t li = 0; li < (int64_t)m.layers.size(); ++li) {
const Layer& l = m.layers[(size_t)li];
/* Before the attention connection reads the stream, which is where the reference puts it. */
@@ -1749,7 +1770,11 @@ static void step_serial(RadCtx* c, const RadBatch* batch, Model& m, const int32_
if (l.cs_in >= 0) m.calib.tap(c, (size_t)l.cs_in, T);
/* The indexer runs first, since the attention reads its selection. The block's input is
* already normed and quantised by the connection (`ext_in`), so `w.h` is final. */
if (l.full) { l.qsa.step(c, l.attn.w.h, batch, pcu); l.attn.step(c, batch); }
if (l.full) {
l.qsa.step(c, l.attn.w.h, batch, pcu, l.attn.qsa_use(batch), qsa_first);
if (l.qsa.on()) qsa_first = false;
l.attn.step(c, batch);
}
else l.gdn.step(c, batch);
if (l.cs_o >= 0) m.calib.tap(c, (size_t)l.cs_o, T);
l.hc_mix.write(c, T, 0, T);
@@ -1827,23 +1852,37 @@ static void step(RadCtx* c, const RadBatch* batch) {
uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) {
if (!c || !batch) return 0;
if (batch->enc) return 1;
Model& m = g_model[rad_slot(c)];
/* Which side of the indexer's exactness bound the step is on by the attention group's exact
* host bound, by which the full-attention layers and the indexer decide whether the step
* needs scores (AttnGatedFP8::qsa_within, qsa_exact_host). The core's key holds only the
* rounded context bound, so the side is keyed here: one more recording of each pass kind as a
* request crosses the bound. `sel` is 2 within the bound and 0 past it or where it is
* unknown, which is where the blocks fall back to the rounded bound the core keys. */
uint64_t sel = 0;
if (used_max_h && batch->kv && m.kv_full && m.qsacfg.budget > 0 && m.qsacfg.ratio > 0)
for (int i = 0; i < batch->n_kv_groups; ++i)
if (batch->kv[i].group == m.kv_full) {
if (used_max_h[i] > 0 &&
used_max_h[i] <= m.qsacfg.budget + m.qsacfg.ratio - 1) sel = 2;
break;
}
/* A decode pass, a speculative verify or an MTP draft included, issues every launch at the
* step's keyed context bound (RadArgs::kv_used_max_h), never the live maximum, so the core's
* key holds its geometry. */
if (batch->phase == RAD_PHASE_DECODE) return 1;
if (batch->phase == RAD_PHASE_DECODE) return 1 | sel;
/* Mixed batches split the query rows into decode and prefill subsets before attention, which
* read the live maximum. The whole-batch host summary cannot key those subset geometries
* exactly, nor a drafter's or a verify's rows inside a prefill pass. */
if (batch->phase == RAD_PHASE_MIXED || batch->draft_pass != 0 || batch->n_spec > 0) return 0;
Model& m = g_model[rad_slot(c)];
bool has_full_attention = false;
for (const Layer& layer : m.layers) {
if (!layer.full) continue;
if (layer.attn.kv_block != 4) return 0;
has_full_attention = true;
}
if (!has_full_attention) return 1;
if (!has_full_attention) return 1 | sel;
if (m.g.head_dim != 256 || (m.g.gqa() != 6 && m.g.gqa() != 12) || !m.kv_full ||
!used_max_h || !batch->kv || batch->n_kv_groups <= 0)
return 0;
@@ -1869,7 +1908,10 @@ uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) {
const int bq = nwarps * 16 / m.g.gqa();
const int splits = rad_prefill_splits_for_live(bq, tile, q_len, total_q, num_seqs,
kv_heads, m.g.max_ctx, used, wgps);
return rad_prefill_grid_key(q_len, bq, splits, kv_heads, num_seqs, nwarps * 32);
const uint64_t grid = rad_prefill_grid_key(q_len, bq, splits, kv_heads, num_seqs, nwarps * 32);
/* 0 stays "unknown"; the side of the bound rides in a bit the grid key's mix does not leave
* meaningful, so two sides are two keys. */
return grid ? ((grid << 2) | 1 | sel) : 0;
}
static int probe(const RadModelMeta* meta, RadArchProbe* out) {