libxe2: device rows for gelu, silu, gelu_tanh, scale, mul_weight, clamp, fill, iota, act_mul, gelu_mul

These weightless elementwise ops had no libxe2 row, and an op with no weights cannot be placed on
the host, so a model whose graph declares one refused to start on Intel ("no device kernel for op
'gelu_mul' in any plugin"). libr4d serves them; the architectures that use them include Gemma 3
and 4, the embedding models (nomic-bert, embgemma, nemotron-embed), Qwen3-ASR, LFM2's SigLIP2,
Nemotron-H and the diffusion and audio models.

Each is libref's chain element by element (xe2_elem_act.cpp): erf, tanh and exp in double rounded
once to float; silu (alone or in act_mul) to a bf16 result takes the float exp and libref's chain
again near a rounding tie, as silu_mul and sigmoid do. gelu and gelu_tanh stay in double: 1 +
erf(x) cancels for negative x, so a float erf's error is not bounded by the result's.

rad-kbench: the nemotronh + moe + default fixtures, 339/339 (act_mul 60, mul_weight 10, iota 9,
silu 20); a random-weight 2-layer Gemma3 converted to .rad, every resolved kernel agrees with
libref (gelu_mul 10 cases). That Gemma3 now serves (1.5k tok/s decode on the B65); without these
rows it does not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aneinanderandClaude Opus 5.5 committed 2026-11-08 13:15:46 +01:00
1 parent d04a27fad3
commit b0ac7fd42c
3 files changed
+322

No files matched your search

+40
View File
@@ -60,6 +60,46 @@ const RadKernelInfo kKernels[] = {
.computes = "1 / (1 + exp(-x)), the exp in double rounded once as libref's",
.shape = "any element count; any strides", .dtypes = "any float dtype in and out",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::sigmoid },
{ .name = "xe2_gelu", .op = "gelu", .family = "elem",
.computes = "0.5x(1 + erf(x / sqrt 2)), erf in double rounded once, as libref's",
.shape = "any element count; any strides", .dtypes = "any float dtype in and out",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::gelu },
{ .name = "xe2_silu", .op = "silu", .family = "elem",
.computes = "x sigmoid(x), exp in double (a bf16 result: a float exp, libref's chain near a tie)",
.shape = "any element count; any strides", .dtypes = "any float dtype in and out",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::silu },
{ .name = "xe2_gelu_tanh", .op = "gelu_tanh", .family = "elem",
.computes = "the tanh gelu, tanh in double rounded once, as libref's",
.shape = "any element count; any strides", .dtypes = "any float dtype in and out",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::gelu_tanh },
{ .name = "xe2_scale", .op = "scale", .family = "elem",
.computes = "y = x * s, s a one-element weight",
.shape = "any element count; any strides", .dtypes = "any float x, s and y",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::scale },
{ .name = "xe2_mul_weight", .op = "mul_weight", .family = "elem",
.computes = "y = x * w, w one element or one row broadcast down the rows; f32 product rounded once",
.shape = "rows of n, uniform row pitch", .dtypes = "any float x, w and y",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::mul_weight },
{ .name = "xe2_clamp", .op = "clamp", .family = "elem",
.computes = "y = min(max(x, lo), hi), lo and hi one-element weights",
.shape = "rows of n, uniform row pitch", .dtypes = "any float dtype",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::clamp },
{ .name = "xe2_fill", .op = "fill", .family = "elem",
.computes = "y = value over [M, n], rounded once to y's dtype",
.shape = "rows of n, uniform row pitch", .dtypes = "any float dtype",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::fill },
{ .name = "xe2_iota", .op = "iota", .family = "elem",
.computes = "y[i] = start + (period ? i % period : i) * step",
.shape = "any element count; any strides", .dtypes = "i32, u32, i64, i16, i8, u8",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::iota },
{ .name = "xe2_act_mul", .op = "act_mul", .family = "elem",
.computes = "y = rd(act(a)) * b; silu, gelu, gelu_tanh, sigmoid, quick_gelu, relu in libref's chain",
.shape = "rows of n, uniform row pitch (column slices of one fused row)", .dtypes = "any float dtype",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::act_mul },
{ .name = "xe2_gelu_mul", .op = "gelu_mul", .family = "elem",
.computes = "y = gelu_tanh(gate_up[i]) * gate_up[n + i], the gate first, tanh in double",
.shape = "rows of 2n in, n out", .dtypes = "any float dtype",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::gelu_mul },
{ .name = "xe2_scatter_rows", .op = "scatter_rows", .family = "gather",
.computes = "row m of v to row idx[m] of x; a negative index skipped, one past x refused",
.shape = "any n and row counts; rows may be padded, the last axis dense",