libxe2: add_rmsnorm (schema and row); arch/common: the plain norm and the attention gate without unread work

- libxe2 serves `add_rmsnorm` (device-only; libxe2 now publishes its schema, libr4d's spelling):
  x += a then rmsnorm of the x written in one pass, at rmsnorm's own bf16 partition, so both
  outputs are byte-identical to the pair here. NormQuantFP8's plain form takes it where it
  resolves (one launch instead of `add` + `rmsnorm`, ~150 a round).
- AttnGatedFP8: under the plain norm an out projection that reads no codes skips the
  quantiser after the gate's sigmoid + mul.

Greedy output 8/8 identical to the previous commit; decode proxy 81.2 -> 82.5 tok/s; declared
ops 2046 -> 1902.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-11-02 03:17:05 +01:00
1 parent f26eec2633
commit 4511822138
5 files changed
+148 -4

No files matched your search

+11 -2
View File
@@ -465,11 +465,20 @@ inline int AttnGatedFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int
RAD_STR("dtype", g.dtype), RAD_STR("act", "sigmoid")),
RAD_NOWEIGHTS),
{w.qg, w.attn.x}, {w.attn.cq(), w.attn.cs(), w.attn.x});
/* Under Geom::plain_norm an out projection that reads no codes (a 4-bit one) takes the
* pair alone: the quantiser after it wrote codes nobody read. */
bool o_plain = false;
if (!op_gq && g.plain_norm) {
RAD_ARCH_TRY(o.probe(b, nm, g, nm.f("blk.%d.attn_output", l), { src.o }));
o_plain = o.codes_free && o.reads_x;
}
if (!op_gq && g.head_dim % RAD_FP8_BLOCK == 0) {
RAD_ARCH_TRY(gate_pair(decl_b(b, nm.f("blk.%d.attn_gate", l), g.act_dtype,
{g.max_tok, q_dim})));
RAD_ARCH_TRY(q_gate.declare(b, g, w.attn, q_dim));
if (!q_gate.op) return RAD_E_INVAL;
if (!o_plain) {
RAD_ARCH_TRY(q_gate.declare(b, g, w.attn, q_dim));
if (!q_gate.op) return RAD_E_INVAL;
}
}
}