Archived
gemma3: the pipelined prefill's shared pair keeps every linear's own quantiser
The pipeline is decided before the blocks are declared, the fused fp8 junctions only after them. Where those then did not resolve (no rmsnorm_quant_fp8, a mixed container), every q|k|v and gate|up still read the shared pair as a shared linear with no quantiser, and the serial fallback read whatever the last writer left there. The pair is now handed to each such linear as the target of its own quantiser (G3Linear::q8_into / s8_into): the fused junctions write it when they resolve, the unfused step's quantisers otherwise. - a note says why the pipeline is off when declare turns it off; - a missing bounds buffer fails the step on both ranks (rad_step_fail) instead of one rank falling back to the serial step alone. arch_test: with rmsnorm_quant_fp8 refused at two ranks and 2048 rows the step is serial, every q and gate|up quantises into the pair it reads (failed before: no quantiser). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
73b1d039a0
commit
28f1f2dd8c
2 files changed
+56
-21
No files matched your search
+30
-2
@@ -6614,12 +6614,40 @@ TEST(gemma3_a_wide_prefill_runs_in_two_pieces_with_its_boundaries_on_the_second_
|
||||
CHECK_EQ(wide_taps, 0);
|
||||
CHECK(!c.joins.empty());
|
||||
for (const gemma3::Layer& l : m.layers) {
|
||||
CHECK(l.attn.ln_q.q8 == m.pipe_in.q8);
|
||||
CHECK(l.mlp.ln_gu.q8 == m.pipe_in.q8);
|
||||
CHECK(l.attn.ln_q.q8 == m.pipe_in.q8 && !l.attn.ln_q.shared_in && l.attn.ln_q.op_q);
|
||||
CHECK(l.mlp.ln_gu.q8 == m.pipe_in.q8 && !l.mlp.ln_gu.shared_in && l.mlp.ln_gu.op_q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Where the fused fp8 junctions do not resolve, a pipelined deployment falls back to the unfused
|
||||
* step with every linear quantising its own input -- into the shared pair, which it therefore still
|
||||
* fills: each q|k|v and gate|up GEMM is issued behind a quantiser writing its pair. */
|
||||
TEST(gemma3_without_fused_junctions_every_linear_quantises_into_what_it_reads) {
|
||||
MetaKV mk = gemma3_meta();
|
||||
const RadEncoding mx = rad_enc_affine(RAD_FP4E2M1, RAD_E8M0, 1, rad::arch::RAD_MX_GROUP);
|
||||
RadBuilder b;
|
||||
b.encs = { { "blk.", mx } };
|
||||
b.refuse = { "rmsnorm_quant_fp8" };
|
||||
RadBuildCtx ctx = build_ctx(0, 2);
|
||||
ctx.max_tok = 2048;
|
||||
REQUIRE_EQ(stderr_of_rc([&] { return gemma3::declare(&b, mk.meta(), &ctx); }), RAD_OK);
|
||||
const gemma3::Model& m = gemma3::g_model[0];
|
||||
CHECK(!m.fuse_mx);
|
||||
CHECK(!m.pipe_on);
|
||||
const auto pf = kit(b, {}, { 64 });
|
||||
const auto v = run_passes(b, gemma3::step, { pf.get() }, 0, 2);
|
||||
CHECK_PASSES(b, v);
|
||||
for (const gemma3::Layer& l : m.layers) {
|
||||
CHECK(l.attn.ln_q.q8 == m.pipe_in.q8 && l.attn.ln_q.op_q && !l.attn.ln_q.shared_in);
|
||||
CHECK(l.mlp.ln_gu.q8 == m.pipe_in.q8 && l.mlp.ln_gu.op_q && !l.mlp.ln_gu.shared_in);
|
||||
}
|
||||
int quant = 0;
|
||||
for (const RecIssue& i : v[0]->issues)
|
||||
if (const RecOp* o = b.op_of(i.op); o && o->op == "quant_act_fp8") ++quant;
|
||||
CHECK(quant >= 2 * (int)m.layers.size());
|
||||
}
|
||||
|
||||
/* The DFlash2 drafter: a block of 8 (depth 7, fixed), taps copied out after the named layers into
|
||||
* one column-sliced buffer, the mask token from the config, and the drafter's own KV group after
|
||||
* the trunk's two. Its input_embedding_scale must be the trunk's sqrt(hidden) held in bf16
|
||||
|
||||
Reference in new issue
Block a user