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

+28 -2
View File
@@ -80,6 +80,12 @@ const RadKernelInfo kKernels[] = {
.shape = "any n; rows may be padded",
.dtypes = "float x, gain and y (bf16 in the recipes), f32 arithmetic",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::rmsnorm },
{ .name = "xe2_add_rmsnorm", .op = "add_rmsnorm", .family = "norm",
.computes = "x += a (bf16, as add rounds it), then rmsnorm of the x written at rmsnorm's own "
"partition: byte-identical to add then rmsnorm here",
.shape = "any n; bf16 rows wider than 512, 8-aligned, in one pass, else the pair",
.dtypes = "float x, a, gain and y (bf16 in the recipes), f32 arithmetic",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::add_rmsnorm },
{ .name = "xe2_rmsnorm_quant_fp8", .op = "rmsnorm_quant_fp8", .family = "norm",
.computes = "residual add (optional), RMS norm, bf16 narrowing, E4M3 codes and an f32 scale "
"per group; int8 codes at amax/127 for an int8 q",
@@ -426,6 +432,22 @@ const RadKernelInfo kKernels[] = {
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::gdn_conv_recurrent_update },
};
/* Schemas of the device-only ops libxe2 serves that libref does not declare (docs/OPS.md, libr4d's
* spellings field for field). */
const RadParamSpec pAddRmsNorm[] = {
{ "M", RAD_P_INT, 1, 0 }, { "n", RAD_P_INT, 1, 0 }, { "eps", RAD_P_F64, 1, 0 },
{ "dtype", RAD_P_STR, 1, 0 }, { "wadd", RAD_P_F64, 0, 0 }, { "mult", RAD_P_F64, 0, 0 },
};
const RadOperandSpec oAddRmsNorm[] = {
{ "x", RAD_OPD_INOUT, 0 }, { "a", RAD_OPD_IN, 0 }, { "w", RAD_OPD_WEIGHT, 0 }, { "y", RAD_OPD_OUT, 0 },
};
const RadOpSchema kSchemas[] = {
{ "add_rmsnorm", pAddRmsNorm, (int)(sizeof pAddRmsNorm / sizeof pAddRmsNorm[0]), oAddRmsNorm,
(int)(sizeof oAddRmsNorm / sizeof oAddRmsNorm[0]),
"x = x + a, then y = rmsnorm(x) * (w + wadd) * mult over the x written: a residual add and the "
"next norm in one pass, byte-identical to add then rmsnorm." },
};
const RadPluginInfo kInfo = {
RAD_PLUGIN_KERNEL, "libxe2", "0.1",
"Intel Xe2 (Battlemage) kernels in SYCL, checked against libref",
@@ -441,8 +463,12 @@ __attribute__((visibility("default"))) uint32_t rad_plugin_abi_version(void) {
}
__attribute__((visibility("default"))) uint64_t rad_plugin_abi_layout(void) { return rad_abi_layout(); }
__attribute__((visibility("default"))) const RadPluginInfo* rad_plugin_info(void) { return &kInfo; }
__attribute__((visibility("default"))) int rad_kernel_schema_count(void) { return 0; }
__attribute__((visibility("default"))) const RadOpSchema* rad_kernel_schema_at(int) { return nullptr; }
__attribute__((visibility("default"))) int rad_kernel_schema_count(void) {
return (int)(sizeof kSchemas / sizeof kSchemas[0]);
}
__attribute__((visibility("default"))) const RadOpSchema* rad_kernel_schema_at(int i) {
return i >= 0 && i < rad_kernel_schema_count() ? &kSchemas[i] : nullptr;
}
__attribute__((visibility("default"))) int rad_kernel_count(void) {
return (int)(sizeof kKernels / sizeof kKernels[0]);
}