ParoQuant: dense per-group rotation (givens_dense_quant): composed 128x128 f16 matrices built at convert time, WMMA kernel with int8/fp8 epilogue; LinearFP8 uses it for the quantising rotation

This commit is contained in:
Malic Zilyas committed 2026-10-08 23:35:43 +02:00
1 parent a19cbcae85
commit c17f5fdc89
13 files changed
+493 -30

No files matched your search

+15
View File
@@ -206,6 +206,10 @@ static const RadOperandSpec oQuantFp8[] = { OPD("x"), OUT("q"), OUT("scale") };
* resolved, moved and placed with the weight they belong to. */
static const RadParamSpec pGivensQuant[] = { P_INT("M"), P_INT("n"), P_INT("group"), P_STR("dtype"),
P_INT("stages"), P_INT("parts") };
static const RadParamSpec pGivensDense[] = { P_INT("M"), P_INT("n"), P_INT("group"), P_STR("dtype"),
P_INT("parts"), P_STR("out") };
static const RadOperandSpec oGivensDense[] = { OPD("x"), WGT("tdense"), WGT("rscale"), OUT("q"),
OUT("scale") };
static const RadOperandSpec oGivensRotate[] = { OPD("x"), WGT("pairs"), WGT("angle"), WGT("rscale"),
OUT("y") };
static const RadOperandSpec oGivensQuant[] = { OPD("x"), WGT("pairs"), WGT("angle"), WGT("rscale"),
@@ -811,6 +815,13 @@ static const RadOpSchema kSchemas[] = {
"stages) of `pairs` and `angle` and row p of `rscale`: a fused projection's pieces were each "
"rotated on their own. Only a weight stored with the \"givens\" transform reads the result; "
"it is NOT quant_act_fp8's output in either direction." },
{ "givens_dense_quant", ARR(pGivensDense), ARR(oGivensDense),
"ParoQuant's activation quantiser with the rotation as a dense per-group matrix: y = T (x / "
"rscale) for each of `parts` rotated copies, T the [128, 128] f16 matrix a (part, 128-column "
"group) that its Givens stages compose to, then the block-scaled quantiser `out` names "
"(\"i8\": scale amax / 127, round to nearest; \"fp8\": E4M3, amax / 448). q is [M, parts * n] "
"and scale [M, parts * n / group]; tdense is [parts * n, 128]. The same activation as "
"givens_quant_act_i8g / _fp8 up to the f16 rounding of T." },
{ "givens_quant_act_i8g", ARR(pGivensQuant), ARR(oGivensQuant),
"givens_quant_act_fp8 with an int8 output: the same channel scale and rotations, then "
"quant_act_i8g's quantiser (scale = amax / 127 per `group`, round to nearest). For the int8 "
@@ -1188,6 +1199,10 @@ SIMPLE("ref_givens_quant_act_fp8", "givens_quant_act_fp8", "quant",
"channel scale and Givens rotations per part, then the block-scaled E4M3 quantiser",
"float in, fp8_e4m3 out, f32 scale per group; int32 pairs, f32 angles and channel scales",
ref_givens_quant_act_fp8),
SIMPLE("ref_givens_dense_quant", "givens_dense_quant", "quant",
"the rotation as a dense per-group matrix, then the block-scaled int8 or E4M3 quantiser",
"float in, int8 or fp8_e4m3 out, f32 scale per group; f16 matrices and f32 channel scales",
ref_givens_dense_quant),
SIMPLE("ref_givens_quant_act_i8g", "givens_quant_act_i8g", "quant",
"channel scale and Givens rotations per part, then the block-scaled int8 quantiser",
"float in, int8 out, f32 scale per group; int32 pairs, f32 angles and channel scales",