ParoQuant dense: review fixes -- the matrices composed exactly, out checked, the stored form pinned

* r4d_rad_relayout_gdense composes in f64 (angles widened, cos/sin and products in double) and rounds to
  f16: the stored matrix is a derivation of the planes, the same bytes whichever libm computed it, as
  abi/rad_abi.h asks of a relayout.
* givens_dense_quant (libr4d and libref) refuses an `out` that does not name q's dtype instead of reading
  the quantiser off q alone.
* relayout_parity_test pins the dense stored form by hash, checks each matrix is orthogonal to f16
  accuracy and that a broken pairing is refused.
* r4d_givens_dense: static_assert that a thread stages one channel scale of the group; the selftest's
  givens_numeric takes one mode (rotate / dense fp8 / dense i8) instead of three flags; cGivensDense
  sits after the Hadamard constraint with its own comment.
This commit is contained in:
Malic Zilyas committed 2026-10-08 23:35:43 +02:00
1 parent d6b506fe4f
commit 9137948b95
6 files changed
+100 -30

No files matched your search

+5 -3
View File
@@ -3020,12 +3020,14 @@ static const RadConstraint cQuantActFp8[] = {
* straddle the end of a row: the ragged tail the unrotated kernel writes zero-padded would mix
* real values with padding inside one butterfly, and there is no weight block on the other side
* that was rotated the same way. */
static const RadConstraint cGivensDense[] = {
C_DIV("n", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"), C_IN("out", "i8 fp8"),
};
static const RadConstraint cHadQuantActFp8[] = {
C_DIV("n", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"),
};
/* ParoQuant's dense rotation: the same whole-group rule (a rotation group cannot straddle a row's end),
* and `out` one of the two quantisers its epilogue has. */
static const RadConstraint cGivensDense[] = {
C_DIV("n", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"), C_IN("out", "i8 fp8"),
};
/* The dtype is the INPUT's, and the input is already quantised -- so it is `fp8a8` and not `bf16`
* the way every other row in this family reads it. A four-multiple `n` is the staging slot (one