fp8: the trunk-rotation question lives beside its predicates

"The trunk is rotated int8 (linear_is_w8h or linear_is_wnh), its
activation codes one scale a trunk_g8 columns: 256 for IQ8R, 128 for
the other rotated forms" was written twice, verbatim, in flint's and
bailing_hybrid's field declarations, and the probe that answers it --
weight_enc, the two predicates, linear_w8h_group -- was re-typed at
both arches' layer-0 sites. museglimmer_ct carries the near-variant;
its question is narrower (exactly-IQ8R, not rotated-at-all), so it
keeps its own predicate.

rad_fp8.h now answers it once: trunk_rotation(enc, &g8), beside the
predicates it is made of, so the group-width semantics travel with the
forms that define them instead of with three copies of a comment. The
two call sites shrink to the probe and the named question.

Standards axis of the 2.1.0 review pass, finding 4.
This commit is contained in:
fl0l0u committed 2026-11-15 22:02:30 +00:00
1 parent 8ac613ddb9
commit a8d82678fa
3 files changed
+20 -12

No files matched your search

+4 -5
View File
@@ -420,9 +420,9 @@ struct Model {
Names nm{};
Geom g{};
Shape s{};
/* The trunk is rotated int8 (rad_fp8.h's linear_is_w8h or linear_is_wnh), its activation codes
* one scale a `trunk_g8` columns: 256 for IQ8R, 128 for the other rotated forms. `norm_fed`:
* the block norms write those codes themselves (rmsnorm_had_quant_i8g is served). */
/* Whether layer 0's probe found a rotated-int8 trunk, and its activation scale group: see
* rad_fp8.h's trunk_rotation. `norm_fed`: the block norms write those codes themselves
* (rmsnorm_had_quant_i8g is served). */
bool trunk_rot = false, norm_fed = false;
int64_t trunk_g8 = RAD_FP8_BLOCK;
std::vector<Layer> layers;
@@ -849,8 +849,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
{
RadEncoding enc{};
m.trunk_rot = weight_enc(b, nm.f("blk.0.attn_qkv.weight"), &enc) &&
(linear_is_w8h(enc) || linear_is_wnh(enc));
if (m.trunk_rot) m.trunk_g8 = linear_w8h_group(enc);
trunk_rotation(enc, &m.trunk_g8);
}
int64_t shared_g8 = m.trunk_g8;
if (m.trunk_rot) {