Module w4a16_gemv_tiers

Module w4a16_gemv_tiers 

Source
Expand description

2026-09-25: SSOT for the narrow w4a16_gemv_batch{M} tier family (M = 4..8).

Owner: model-layers (NVFP4 GEMV dispatch). Invariants:

  • select_tier never returns a tier narrower than m, nor one that the loaded target did not resolve.

w4a16_gemv_batchm_impl<MAX_M> sizes acc[] and s_vl[] by MAX_M and unrolls its row loop over MAX_M, so MAX_M also sizes the code. The t >= M guard skips a dead row’s work at run time but not its instructions, so M=5 on the MAX_M=8 tier carries three unused rows; the exact-M tiers 5, 6 and 7 avoid that.

The width decision lives here once, as a pure function (select_tier) over which tiers the loaded target resolved; every consumer holds a W4a16BatchmTiers and calls kernel(m).

METRALE_NO_GEMV_EXACT_M_TIERS (presence-checked: any value, including 0, disables) hides widths 5/6/7 from the decision, leaving widths 4 and 8. It does not unload the kernels, so an A/B needs no rebuild.

Structs§

W4a16BatchmTiers
2026-09-25: Resolved handles for the narrow w4a16_gemv_batch{M} family.

Constants§

W4A16_BATCHM_WIDTHS
2026-09-25: Tier widths in this family, narrowest first. Parallel to the handles field of W4a16BatchmTiers and to the present array of select_tier. w4a16_gemv_batch16/_batch32 are not in this table: they are held separately (wide, wide32) and handed out only above 8 rows, within the row edge (W4a16BatchmTiers::edge).

Functions§

exact_m_tiers_enabled
2026-09-25: Are the exact-M tiers (5/6/7) allowed in the dispatch decision?
select_tier
2026-09-25: Pure tier decision: index into W4A16_BATCHM_WIDTHS of the narrowest tier that covers m rows and is present in the loaded target, or None when no such tier exists (or m is 0).