Archived
arch/gemma4: the sliding layers' attention reads q in the fused qkv row
The q lift -- a `cast` copying q out of the fused [q|k|v] projection into a dense block -- was there because libr4d's paged attention reads q only dense. gemma4k's takes q at any row pitch (its head_view, and g4k_emu's q-pitch-slice cases), and gemma4k serves all of Gemma 4's attention, so the slice goes straight in: one launch and a [T, q] copy less on each of the 25 sliding layers, every step. With libr4d ahead of gemma4k its attention refuses the slice by name (RAD_E_STRIDE) rather than reading it wrong. arch_test: no copy between projection and attention, and the attention reads `qkv_s`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9967158d4a
commit
3a48ee78de
2 files changed
+25
-13
No files matched your search
@@ -3624,3 +3624,19 @@ TEST(gemma4_dflash_taps_are_live_from_the_layer_that_writes_them) {
|
||||
}
|
||||
CHECK_EQ(taps, 3);
|
||||
}
|
||||
|
||||
/* The sliding layers' attention reads q where the fused projection left it: no copy op between
|
||||
* the qkv projection and the attention, and the attention's declared reads name the fused row. */
|
||||
TEST(gemma4_sliding_attention_reads_q_in_the_fused_row) {
|
||||
RadBuilder b;
|
||||
RadModelMeta meta = gemma4_moe_meta();
|
||||
RadBuildCtx ctx = build_ctx();
|
||||
CHECK_OK(gemma4::declare(&b, &meta, &ctx));
|
||||
const int qkv = buf_named(b, "qkv_s");
|
||||
REQUIRE(qkv > 0);
|
||||
CHECK_EQ(buf_named(b, "q_s"), 0);
|
||||
const RecOp* at = find_op(b, "attn_paged", 0);
|
||||
REQUIRE(at != nullptr);
|
||||
CHECK(std::find(at->reads.begin(), at->reads.end(), (rad_buf)qkv) != at->reads.end());
|
||||
CHECK_EQ(count_op(b, "cast"), 0); /* no drafter here, so no taps either */
|
||||
}
|
||||
Reference in new issue
Block a user