From 743b7e1a6a2dfc004d9d350ebf96721019ce0de2 Mon Sep 17 00:00:00 2001 From: Ashlyn Date: Sun, 11 Oct 2026 15:25:46 -0500 Subject: [PATCH] arch/gemma4: the DFlash head reads a block-fp8 copy of the table where the container holds one The drafter's head was `gemm_nt` over the target's bf16 table -- 352 MiB a rank at tp 4, every draft pass, 566 us of a 26B-A4B decode step under --profile-ops on 4x R9700: the widest read on the draft path, and the "first thing to change once the model runs" its own comment named. A container may now hold the table a second time as `dflash.draft_head.weight`, block fp8 -- one checkpoint tensor, two logical weights, as rad_block_dflash2.h does it -- made by the recipe line dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 which the three gemma4-26b-a4b -df recipes now carry. Where the copy is there, the head is quant_act_fp8 over the gathered rows and gemm_nt_q over the copy at fp8a8: half the bytes, for 176 MiB a rank more. The copy is row-sharded exactly as the table, so a rank's rows are the same vocabulary slice and row_topk's vocab_off, the all_gather and pair_argmax are unchanged. Drafts are verified, so the coarser logits change what is proposed and never what is accepted -- draft_n_accepted says whether they propose worse; there is no rerank against the bf16 table yet. Where the copy is not there -- every container converted before this, or one whose recipe made it something other than block fp8 -- the head reads the bf16 table exactly as before. The decision is the stored encoding's (weight_enc on the copy's name), and the copy's name map entry alone writes nothing: rad-convert walks the declared weights. The startup note names the head in use. The block-fp8 test moves to one helper, which the routed experts' encoding check now uses too. arch_test: with the copy's encoding block fp8, the copy is declared and the head is gemm_nt_q over it from the quantised rows; without, nothing is declared and the head is gemm_nt over the table; a draft pass issues the head once either way. ARCHITECTURES.md says so. Not yet run on the cards; it needs a container converted with the new recipe line. Co-Authored-By: Claude Opus 5.5 --- arch/gemma4/gemma4.cpp | 17 ++-- arch/gemma4/gemma4_dflash.h | 87 +++++++++++++++++--- data/recipes/gemma4-26b-a4b-df-bf16x.recipe | 6 ++ data/recipes/gemma4-26b-a4b-df-pad768.recipe | 6 ++ data/recipes/gemma4-26b-a4b-df.recipe | 6 ++ docs/ARCHITECTURES.md | 9 ++ tests/arch_test.cpp | 46 +++++++++++ 7 files changed, 157 insertions(+), 20 deletions(-) diff --git a/arch/gemma4/gemma4.cpp b/arch/gemma4/gemma4.cpp index f258f44c..dcd735ba 100644 --- a/arch/gemma4/gemma4.cpp +++ b/arch/gemma4/gemma4.cpp @@ -293,6 +293,7 @@ struct Model { Dflash1::Wire dfw{}; rad_kvgroup kv_draft = 0; bool have_df = false; + const char* tok_src = nullptr; /* the checkpoint's table, which the fp8 draft head copies */ std::vector layers; }; @@ -515,7 +516,8 @@ static int declare_dflash(RadBuilder* b, const RadModelMeta* meta, const RadBuil * pitch of `steps` -- and the engine reads it by the declaration below. */ dw.tokens = decl_b(b, nm.f("dflash_tokens"), RAD_I32, {sr, 1}); - RAD_ARCH_TRY(m.df.declare(b, nm, dg, dc, base_layer, m.kv_draft, m.w_tok, "draft", dw)); + RAD_ARCH_TRY(m.df.declare(b, nm, dg, dc, base_layer, m.kv_draft, m.w_tok, "draft", dw, + m.tok_src)); m.have_df = true; RadDrafterDecl drf{}; @@ -539,11 +541,14 @@ static int declare_dflash(RadBuilder* b, const RadModelMeta* meta, const RadBuil rad_note(b, "the DFlash drafter is declared: %lld layers at absolute %d..%d (%d full, %lld " "sliding over %lld causal), %lld heads / %lld kv x %lld, ffn %lld, reading the " "trunk at %d tap(s). ONE forward over %lld rows proposes %lld tokens; the head is " - "the target's tied bf16 table, argmax %s", + "%s, argmax %s", (long long)dg.n_layer, base_layer, base_layer + (int)dg.n_layer - 1, nfull, (long long)(dg.n_layer - nfull), (long long)dc.window, (long long)dg.n_head, (long long)dg.n_head_kv, (long long)dg.head_dim, (long long)dg.n_ff, m.n_taps, (long long)dc.block, (long long)dc.steps(), + m.df.fp8_head + ? "the container's block-fp8 copy of the target's table (dflash.draft_head)" + : "the target's tied bf16 table", Dflash1::head_sharded(dg) ? "per vocab shard, merged" : "over the whole vocabulary"); return RAD_OK; } @@ -561,10 +566,7 @@ static int expert_format(RadBuilder* b, const char* wn, int* fmt) { *fmt = EXP_BF16; if (!weight_enc(b, wn, &e)) return RAD_OK; if (rad_enc_is(&e, "plain") && e.n_planes == 1 && e.plane[0].dtype == RAD_BF16) return RAD_OK; - const RadEncPlane* sc = rad_enc_plane(&e, "scale"); - if (rad_enc_is(&e, "affine") && e.n_planes == 2 && !e.transform[0] && - e.plane[0].dtype == RAD_F8E4M3 && sc && sc->dtype == RAD_BF16 && - sc->block[0] == RAD_FP8_BLOCK && sc->block[1] == RAD_FP8_BLOCK) { + if (block_fp8_128(e)) { *fmt = EXP_FP8; return RAD_OK; } @@ -916,7 +918,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c /* ---- the vocabulary edges: ONE table, row-sharded with the vocabulary, read as the embedding * by `embed_lookup` and as the head by `logits_gemm` -- Gemma ties them, so storing the head * a second time would be 1.4 GiB for nothing. */ - RAD_ARCH_TRY(map_copy(b, nm.f("token_embd.weight"), nm.ckpt("%s.embed_tokens.weight", L))); + m.tok_src = nm.ckpt("%s.embed_tokens.weight", L); + RAD_ARCH_TRY(map_copy(b, nm.f("token_embd.weight"), m.tok_src)); RAD_ARCH_TRY(map_copy(b, nm.f("output_norm.weight"), nm.ckpt("%s.norm.weight", L))); m.w_tok = decl_w(b, nm.f("token_embd.weight"), RAD_BF16, {g.n_vocab, E}, RAD_ACCESS_VOCAB, RAD_SHARD_ROW, grp_model()); diff --git a/arch/gemma4/gemma4_dflash.h b/arch/gemma4/gemma4_dflash.h index cc29dad8..348c1bdd 100644 --- a/arch/gemma4/gemma4_dflash.h +++ b/arch/gemma4/gemma4_dflash.h @@ -49,9 +49,19 @@ * `pair_argmax`; R = 2 because the gather moves 16-byte rows, see kTopR). * * Reading the bf16 head every draft pass is the expensive way to do it -- 262144 x 2816 x 2 bytes - * over the ranks. The cheaper way is the 2-bit copy plus an exact rerank that DFlash2 uses, and - * that needs the trunk's head in fp8 or int8, which a tied Gemma head is not. Stated rather than - * hidden: it is the first thing to change once the model runs. + * over the ranks, 566 us of a 26B-A4B decode step at tp 4 (--profile-ops, 4x R9700), the widest + * read on the draft path. So where the CONTAINER holds a block-fp8 copy of the table under a name + * of its own -- `dflash.draft_head.weight`, one checkpoint tensor and two logical weights, as + * rad_block_dflash2.h does it, made by a recipe line + * + * dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + * + * -- the head is `gemm_nt_q` over that copy at fp8a8, half the bytes, and the argmax is taken over + * its coarser logits. Every draft is still verified, so the copy can change what is proposed and + * never what is accepted; draft_n_accepted is what says whether it proposes worse. A container + * without it, or with it in any other encoding, reads the bf16 table as before. The copy costs + * half the table's bytes again, 176 MiB a rank at tp 4. No rerank against the bf16 table yet: + * DFlash2's needs the target's head in fp8 or int8, which a tied Gemma head is not. * * ============================== THE LINEARS ARE FP8 ============================== * @@ -72,6 +82,15 @@ namespace gemma4 { using namespace rad::arch; +/* Block fp8 as libr4d's fp8a8 GEMMs read it: fp8_e4m3 codes, a bf16 scale a 128x128 block, no + * transform -- a recipe's `rtn codes=fp8_e4m3 block=128x128 scale=bf16`. */ +inline bool block_fp8_128(const RadEncoding& e) { + const RadEncPlane* sc = rad_enc_plane(&e, "scale"); + return rad_enc_is(&e, "affine") && e.n_planes == 2 && !e.transform[0] && + e.plane[0].dtype == RAD_F8E4M3 && sc && sc->dtype == RAD_BF16 && + sc->block[0] == RAD_FP8_BLOCK && sc->block[1] == RAD_FP8_BLOCK; +} + struct Dflash1 { enum { MAX_LAYERS = 8 }; @@ -97,6 +116,7 @@ struct Dflash1 { rad_buf ffn = 0, ffq = 0, ffs = 0; /* [qrows, n_ff] */ /* the head, one row a draft position */ rad_buf sel_h = 0; /* [srows, n_embd] */ + rad_buf selq = 0, sels = 0; /* [srows, n_embd] e4m3 | f32, the fp8 head's */ rad_buf dlog = 0; /* [srows, n_vocab on this rank] bf16 */ rad_buf cand = 0, unary = 0; /* [srows, kTopR] i32 | f32 -- this rank's best */ rad_buf dpair = 0, dgath = 0; /* [srows, kTopR, 2] | [srows, world * kTopR, 2] f32 */ @@ -114,6 +134,8 @@ struct Dflash1 { DenseFP8 w_fc{}; rad_weight w_hnorm = 0, w_norm = 0; rad_weight w_tok = 0; /* the TARGET's table: embedding AND head */ + DenseFP8 w_dh{}; /* its block-fp8 copy, the head where it is stored */ + bool fp8_head = false; rad_weight w_anorm[MAX_LAYERS] = {}, w_fnorm[MAX_LAYERS] = {}; DenseFP8 w_q[MAX_LAYERS]{}, w_k[MAX_LAYERS]{}, w_v[MAX_LAYERS]{}, w_o[MAX_LAYERS]{}; rad_weight w_qn[MAX_LAYERS] = {}, w_kn[MAX_LAYERS] = {}; @@ -129,7 +151,7 @@ struct Dflash1 { rad_op op_gu[MAX_LAYERS] = {}, op_gug[MAX_LAYERS] = {}, op_dn[MAX_LAYERS] = {}; rad_op op_qrope = 0, op_krope = 0, op_store = 0, op_attn_swa = 0, op_attn_full = 0; rad_op op_act = 0, op_ar = 0, op_add = 0, op_final = 0; - rad_op op_gather = 0, op_head = 0, op_topk = 0, op_dgather = 0, op_pick = 0; + rad_op op_gather = 0, op_qsel = 0, op_head = 0, op_topk = 0, op_dgather = 0, op_pick = 0; /* CANDIDATES A RANK CONTRIBUTES under a sharded head. The draft needs one, but the gather moves * whole 16-byte words a row and an (int32 id, f32 value) pair is 8 bytes, so R = 1 is refused at @@ -140,7 +162,8 @@ struct Dflash1 { static bool head_sharded(const Geom& g) { return vocab_head_sharded(g); } int declare(RadBuilder* b, Names& nm, const Geom& geom, const Config& c, int base_layer, - rad_kvgroup group, rad_weight tok_embd, const char* ck, const Wire& wire); + rad_kvgroup group, rad_weight tok_embd, const char* ck, const Wire& wire, + const char* tok_src); void context(RadCtx* c, const RadBatch* batch) const; void step(RadCtx* c, const RadBatch* batch) const; @@ -168,9 +191,9 @@ private: inline int Dflash1::declare(RadBuilder* b, Names& nm, const Geom& geom, const Config& c, int base_layer, rad_kvgroup group, rad_weight tok_embd, - const char* ck, const Wire& wire) { + const char* ck, const Wire& wire, const char* tok_src) { g = geom; cfg = c; w = wire; first_layer = base_layer; kv = group; w_tok = tok_embd; - if (!ck || !w_tok) return RAD_E_INVAL; + if (!ck || !w_tok || !tok_src) return RAD_E_INVAL; if (g.n_layer <= 0 || g.n_layer > MAX_LAYERS) { fprintf(stderr, "radiance: gemma4: the drafter has %lld layers; this block carries at most " "%d\n", (long long)g.n_layer, MAX_LAYERS); @@ -443,11 +466,43 @@ inline int Dflash1::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co RAD_STR("dtype", g.dtype)), RAD_NOWEIGHTS), {w.h}, {w.sel_h}); - op_head = rw(b, RAD_OP(b, "gemm_nt", - RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("N", g.n_vocab), - RAD_INT("K", g.n_embd), RAD_STR("dtype", g.dtype)), - RAD_WEIGHTS(w_tok)), - {w.sel_h}, {w.dlog}); + /* THE FP8 COPY, where the container holds one (see the top of this file). The name map comes + * first -- it is how the encoding is looked up -- and a map whose weight is never declared is + * written by nothing: rad-convert walks the declared weights. The copy is row-sharded exactly + * as the table is, so this rank's rows are the same vocabulary slice and `vocab_off` holds. */ + const char* dhn = nm.f("dflash.draft_head.weight"); + RAD_ARCH_TRY(map_copy(b, dhn, tok_src)); + RadEncoding he{}; + fp8_head = weight_enc(b, dhn, &he) && block_fp8_128(he); + if (fp8_head) { + if (g.n_vocab % RAD_FP8_BLOCK || g.n_embd % RAD_FP8_BLOCK) { + fprintf(stderr, "radiance: gemma4: the fp8 draft head is %lldx%lld a rank, which " + "is not whole %d-row scale blocks\n", + (long long)g.n_vocab, (long long)g.n_embd, RAD_FP8_BLOCK); + return RAD_E_INVAL; + } + const int shard = g.world > 1 ? RAD_SHARD_ROW : RAD_SHARD_NONE; + w_dh.w = decl_view(b, dhn, nullptr, "codes", RAD_F8E4M3, { g.n_vocab, g.n_embd }, + RAD_ACCESS_PER_TOKEN, shard, grp_model()); + w_dh.s = decl_view(b, nm.f("dflash.draft_head.scale"), dhn, "scale", RAD_BF16, + { fp8_blocks(g.n_vocab), fp8_blocks(g.n_embd) }, RAD_ACCESS_PER_TOKEN, + shard, grp_model()); + if (!w_dh.w || !w_dh.s) return RAD_E_INVAL; + w.selq = decl_b(b, nm.f("df_selq"), RAD_F8E4M3, {srows, g.n_embd}); + w.sels = decl_b(b, nm.f("df_sels"), RAD_F32, {srows, fp8_blocks(g.n_embd)}); + op_qsel = rw(b, RAD_OP(b, "quant_act_fp8", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n", g.n_embd), + RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", g.dtype)), + RAD_NOWEIGHTS), + {w.sel_h}, {w.selq, w.sels}); + op_head = w_dh.gemm(b, srows, g.n_vocab, g.n_embd, {w.selq, w.sels}, {w.dlog}); + } else { + op_head = rw(b, RAD_OP(b, "gemm_nt", + RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("N", g.n_vocab), + RAD_INT("K", g.n_embd), RAD_STR("dtype", g.dtype)), + RAD_WEIGHTS(w_tok)), + {w.sel_h}, {w.dlog}); + } if (sharded) { op_topk = rw(b, RAD_OP(b, "row_topk", RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("N", g.n_vocab), @@ -575,7 +630,13 @@ inline void Dflash1::step(RadCtx* c, const RadBatch* batch) const { const int64_t S = batch->n_out; if (S <= 0) return; RAD_ISSUE_N(c, op_gather, S, RAD_B(w.h), praw(batch->out_ids, RAD_I32, S), brows(w.sel_h, S)); - RAD_ISSUE_N(c, op_head, S, brows(w.sel_h, S), RAD_W(w_tok), brows(w.dlog, S)); + if (fp8_head) { + RAD_ISSUE_N(c, op_qsel, S, brows(w.sel_h, S), brows(w.selq, S), brows(w.sels, S)); + RAD_ISSUE_N(c, op_head, S, brows(w.selq, S), brows(w.sels, S), RAD_W(w_dh.w), + RAD_W(w_dh.s), brows(w.dlog, S), RAD_NONE, w_dh.bref()); + } else { + RAD_ISSUE_N(c, op_head, S, brows(w.sel_h, S), RAD_W(w_tok), brows(w.dlog, S)); + } if (sharded) { RAD_ISSUE_N(c, op_topk, S, brows(w.dlog, S), brows(w.cand, S), brows(w.unary, S), brows(w.dpair, S)); diff --git a/data/recipes/gemma4-26b-a4b-df-bf16x.recipe b/data/recipes/gemma4-26b-a4b-df-bf16x.recipe index 204ae3bb..90cd1f37 100644 --- a/data/recipes/gemma4-26b-a4b-df-bf16x.recipe +++ b/data/recipes/gemma4-26b-a4b-df-bf16x.recipe @@ -15,3 +15,9 @@ dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + +# The drafter's head: the target's tied table again under a name of its own, block fp8, which the +# draft head reads instead of the bf16 table -- half the widest read on the draft path, for half +# the table's bytes again (176 MiB a rank at tp 4). Drafts are verified, so this changes what is +# proposed, never what is accepted. +dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 diff --git a/data/recipes/gemma4-26b-a4b-df-pad768.recipe b/data/recipes/gemma4-26b-a4b-df-pad768.recipe index f88c1dee..46749c3b 100644 --- a/data/recipes/gemma4-26b-a4b-df-pad768.recipe +++ b/data/recipes/gemma4-26b-a4b-df-pad768.recipe @@ -23,3 +23,9 @@ dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + +# The drafter's head: the target's tied table again under a name of its own, block fp8, which the +# draft head reads instead of the bf16 table -- half the widest read on the draft path, for half +# the table's bytes again (176 MiB a rank at tp 4). Drafts are verified, so this changes what is +# proposed, never what is accepted. +dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 diff --git a/data/recipes/gemma4-26b-a4b-df.recipe b/data/recipes/gemma4-26b-a4b-df.recipe index 35bd4a3f..b296b701 100644 --- a/data/recipes/gemma4-26b-a4b-df.recipe +++ b/data/recipes/gemma4-26b-a4b-df.recipe @@ -25,3 +25,9 @@ dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + +# The drafter's head: the target's tied table again under a name of its own, block fp8, which the +# draft head reads instead of the bf16 table -- half the widest read on the draft path, for half +# the table's bytes again (176 MiB a rank at tp 4). Drafts are verified, so this changes what is +# proposed, never what is accepted. +dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 diff --git a/docs/ARCHITECTURES.md b/docs/ARCHITECTURES.md index 360b9131..423f8fca 100644 --- a/docs/ARCHITECTURES.md +++ b/docs/ARCHITECTURES.md @@ -511,6 +511,15 @@ The drafter's head is vocab-sharded with the trunk's: each rank's top-2 are all- `pair_argmax` picks the winner (two a rank, because a row-interleaved `all_gather` moves 16-byte words and one pair is 8 bytes). +**The draft head in fp8.** The drafter's head is the widest read on the draft path: the target's +bf16 table, 352 MiB a rank at tp 4, every draft pass. A container converted with the line +`dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16` (the three `-df` recipes +carry it) stores a block-fp8 copy of the table under that name, and the head reads the copy at +fp8a8 instead -- half the bytes, for 176 MiB a rank more. Drafts are verified, so the coarser +logits can change what is proposed and never what is accepted; `draft_n_accepted` says whether +they propose worse. A container without the copy reads the bf16 table as before, and the startup +note names which head is in use. + **FP8 experts.** The experts are ~90% of the weight bytes, so each projection is served as the container holds it, per layer: bf16 by `moe_gemm`, block fp8 by `moe_gemm_q`. gate_up `[1408, 2816]` is whole 64-row tiles and 128-blocks. down `[2816, 704]` is not — the fp8 grouped GEMM reads K in diff --git a/tests/arch_test.cpp b/tests/arch_test.cpp index c53ac9b8..43c641ef 100644 --- a/tests/arch_test.cpp +++ b/tests/arch_test.cpp @@ -3759,3 +3759,49 @@ TEST(gemma4_scales_the_routing_weights_in_one_launch) { if (o.resolved) CHECK(o.uses_declared); } } + +/* The drafter's head reads the container's block-fp8 copy of the target's table where it holds one + * -- `dflash.draft_head.weight` -- through quant_act_fp8 and gemm_nt_q, and the bf16 table through + * gemm_nt where it does not. The copy is declared only in the first case, so a container converted + * without the recipe line is served exactly as before. */ +TEST(gemma4_dflash_head_reads_the_fp8_copy_where_the_container_holds_one) { + const std::vector keys = g4df_keys(), vals = g4df_vals(); + for (int fp8 = 0; fp8 < 2; ++fp8) { + RadModelMeta meta = gemma4_moe_meta(); + meta.n_kv = (int)keys.size(); + meta.kv_key = keys.data(); + meta.kv_val = vals.data(); + RadBuilder b; + if (fp8) + b.encs = { { "dflash.draft_head", rad_enc_affine(RAD_F8E4M3, RAD_BF16, 128, 128) } }; + RadBuildCtx ctx = build_ctx(); + ctx.max_spec = 15; + CHECK_OK(gemma4::declare(&b, &meta, &ctx)); + CHECK_EQ(find_w(b, "dflash.draft_head.weight") != nullptr, fp8 == 1); + + const int dlog = buf_named(b, "df_dlog"), selh = buf_named(b, "df_selh"); + REQUIRE(dlog > 0 && selh > 0); + const RecOp* head = nullptr; + for (const auto& o : b.ops) + if (o.resolved && + std::find(o.writes.begin(), o.writes.end(), (rad_buf)dlog) != o.writes.end()) + head = &o; + REQUIRE(head != nullptr); + CHECK_EQ(head->op, std::string(fp8 ? "gemm_nt_q" : "gemm_nt")); + const bool reads_selh = + std::find(head->reads.begin(), head->reads.end(), (rad_buf)selh) != head->reads.end(); + CHECK_EQ(reads_selh, fp8 == 0); + + /* and a draft pass issues it */ + RadCtx c; c.b = &b; c.rank = 0; c.world = 1; + RadBatch batch = decode_batch(); + batch.draft_pass = 1; + c.batch = &batch; + gemma4::step(&c, &batch); + CHECK(c.step_fail.empty()); + int head_issues = 0; + for (const auto& i : c.issues) + if (b.op_of(i.op) == head) ++head_issues; + CHECK_EQ(head_issues, 1); + } +}