Skip to main content

Module int8

Module int8 

Source
Expand description

Int8 W8A8 kernels: symmetric per-output-channel Q8 weights times per-row Q8 activations.

This is the Phase-2/3A quantized projection route for the talker and microdecoder GEMMs. The numeric contract is S8S8: weights quantized by the canonical symmetric recipe (scale = max|row| / 127, ties-to-even, [-127, 127], -128 never emitted — identical to ftts-artifacts::converter::quantize_output_channel_q8, byte-for-byte, asserted by a cross-crate test in ftts-model-qwen), activations quantized dynamically per row with the same recipe. Accumulation is exact i32; the two f32 scales are applied once, after accumulation, in a fixed multiplication order shared by every tier.

§Tier law

Every tier of dot_i32 is exactly equal in i32 to Int8Tier::Scalar on every input — integer addition is associative, and the overflow selftest proves the all-extreme reduction fits i32 at every census binding K. A tier is only dispatchable after crate::selftest::run_selftest has executed its all-extreme proof rows through the real kernel function on the running silicon. Do not add a tier here without extending the selftest.

Inherited prior NE-INH-003 (re-verify per toolchain): on Apple M4, LLVM autovectorization of the scalar shape beat a hand SDOT micro-tile at m=1. Both routes therefore ship; dispatch preference is decided by measurement (FTTS_INT8_TIER forces a route for A/B), never by assumption.

Structs§

KernelPlanV0
The measured per-regime route assignment, decided once per process.
QuantizedMatrix
A weight matrix quantized with per-output-channel symmetric Q8 scales.

Enums§

Int8Tier
An executable int8 dot-product route.
QuantLinearMode
Which quantized linear op class the armed route runs.

Constants§

Q8_MAX_ABS
Largest absolute Q8 byte the canonical symmetric recipe emits.

Functions§

autotuned_plan
Measures each available tier at the two live regimes and returns the winners.
dot_i32
Exact i32 dot product of two Q8 rows over the selected route.
linear_q8
W8A8 linear: quantized activations [m, k] times a QuantizedMatrix [n, k], producing f32 [m, n].
linear_q8_dynamic
Quantizes an f32 activation matrix [m, k] per row and runs linear_q8.
linear_w8a16
W8A16 linear: f32 activations [m, k] times a QuantizedMatrix [n, k] producing f32 [m, n].
neon_sdot_available
Whether the SDOT island is compiled in and the CPU reports FEAT_DotProd.
quant_linear
Runs one quantized linear in the selected mode; the drop-in used by the armed model paths.
quant_mode_from_environment
The armed quantized-linear mode for the talker/microdecoder route.
quantize_row_q8
Quantizes one row (weight output channel or activation row) with the canonical symmetric Q8 recipe.
wasm_simd128_available
Whether the SIMD128 island is compiled in.