Files
leleka/crates/cpu-sys
Pavlo Ratushnyi fc08b9b4fe STRA-338 size-fn: cpu-sys kernels: x86 SIMD kernels split into helpers (fn>30 8 -> 0)
attn_weighted_sum_avx2, attn_weighted_sum_f16_avx2, dot_i8i8_avxvnni, dot_i4i8_avxvnni,
dot_mxfp4_q8r4_avxvnni, dot_mxfp4_q8r4_avx2 and quantize_q8_0_avx2 are cut into statement-group
helpers (#[inline] with the same #[target_feature] as the original, unsafe fn, the 64-byte/4-block
main loops, the per-head accumulator block, the scalar column tail, the amax reduction and the
scale/round/pack step, the MXFP4 scaled fma, the int4 nibble unpack). #[inline(always)] is not
combinable with #[target_feature], so #[inline] is used, as the existing helpers do.
Arithmetic, accumulator count, FMA/accumulation order, lane order, rounding and the bounds-check
sites are unchanged; no expression was rewritten.

Identity check (throwaway, deleted): the base-commit x86 module tree (git HEAD) and the new tree were
compiled side by side in a test and run on fixed xorshift inputs, comparing output bits:
attn_weighted_sum f32 and f16 (heads 1-4, hd 1..192 incl. non multiples of 8, n 1..40, stride > hd),
dot_i8i8 / dot_i4i8 (n 0..513 around the 16/32/64 steps), dot_mxfp4_q8r4 avx2 and vnni (0..33 blocks),
quantize_q8_0 (0..33 blocks, zero and -0.0 blocks): 792 cases, all bit-identical, debug and release.
The AVX-VNNI variants cannot run on this CPU (i9-11900H: AVX2, FMA, F16C, AVX-512, no AVX-VNNI):
for them the check ran both trees with vpdpbusd replaced by a scalar emulation and the avxvnni
target feature removed, which proves the loop/helper restructuring but not the instruction itself;
the real VNNI instructions were only compiled. leleka-cpu-sys tests (attention, multi, tiles, lib)
pass; test ids unchanged; clippy -D warnings clean.
Codegen effect is not A/B-measured; no performance claim is made.
2026-11-06 18:41:32 +01:00
..