Archived
libxe2: rmsnorm, rmsnorm_quant_fp8, quant_act_fp8, gated_quant_fp8
One work-group a row; a quantisation group a sub-group. The arithmetic is libref's step for step, and two things made it so on the card: - Device code is generated at link time (AOT), so the flags that shape it now go to the link as well as the compile: -ffp-contract=off, -ffp-model=precise, and -foffload-fp32-prec-div/-sqrt. Without correctly rounded division a group's scale amax * (1/448) came out one ulp off, and bf16 inputs sit exactly on E4M3 rounding ties often enough that 1780 of 524288 codes moved (a standalone host/device comparison showed it; with the flags, none). - The sum of squares is libref's ascending f32 sum, by one work-item. A tree reduction moved normed values across bf16 ties on MiniCPM5-2B's real weights and failed rmsnorm_quant_fp8 at M=1 (rel 7.7e-3 against its 4e-3 tolerance). rad-kbench against libref: the fixture 228/228 and MiniCPM5-2B's container 140/140, worst rel_l2 1e-7, inside guarded allocations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
41a3c32a65
commit
b2cdcb4420
5 files changed
+332
-5
No files matched your search
@@ -20,6 +20,29 @@ const RadKernelInfo kKernels[] = {
|
||||
.dtypes = "any float dtype in and out (bf16, f16, f32, fp8), f32 arithmetic, rounded as libref",
|
||||
.domain = RAD_DOMAIN_DEVICE, .priority = 0,
|
||||
.launch = xe2::add },
|
||||
|
||||
{ .name = "xe2_rmsnorm", .op = "rmsnorm", .family = "norm",
|
||||
.computes = "RMS norm, one work-group a row, f32 work-group reduction",
|
||||
.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_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",
|
||||
.shape = "any n and group; one sub-group a quantisation group",
|
||||
.dtypes = "bf16 in, E4M3 (or i8) codes, f32 scales, optional bf16 out",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::rmsnorm_quant_fp8 },
|
||||
{ .name = "xe2_quant_act_fp8", .op = "quant_act_fp8", .family = "quant",
|
||||
.computes = "E4M3 codes and an f32 scale amax/448 per group",
|
||||
.shape = "any n and group",
|
||||
.dtypes = "float in, E4M3 codes, f32 scales",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::quant_act_fp8 },
|
||||
{ .name = "xe2_gated_quant_fp8", .op = "gated_quant_fp8", .family = "quant",
|
||||
.computes = "silu(gate)*up or sigmoid(gate)*up over packed gate_up, bf16 narrowing, E4M3 "
|
||||
"codes and an f32 scale per group",
|
||||
.shape = "any n and group",
|
||||
.dtypes = "bf16 gate_up, E4M3 (or i8) codes, f32 scales, optional bf16 out",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::gated_quant_fp8 },
|
||||
};
|
||||
|
||||
const RadPluginInfo kInfo = {
|
||||
|
||||
Reference in new issue
Block a user