Files
llama.cpp/tests
LumpiastyandClaude Opus 5.5 af815458ca ggml-cpu: faster AVX2 NVFP4 x Q8_0 dot product (two blocks per iteration, vector UE4M3 scales)
The x86 AVX2 ggml_vec_dot_nvfp4_q8_0 did one block per iteration with four
scalar UE4M3 table lookups, two scalar FP16 conversions, four scalar muls and
broadcasts per 64 weights, plus two FMAs on one accumulator chain.

New AVX2 path, two blocks (128 weights) per iteration:
- E2M1 decode with 256-bit pshufb on the whole 32-byte qs, unpack + permute2x128
  into the q8_0 element order (low nibbles are elements 0-7 of a sub-block,
  high nibbles 8-15);
- the 8 sub-block sums reduced exactly in int16 (a sub-block sum is at most
  16*12*127) with two levels of hadd_epi16 and one madd, one cvt;
- the 8 UE4M3 scales decoded in one vector (bit manipulation, bit-exact with
  ggml_ue4m3_to_fp32 for all 256 bytes: x0.5, 0x7F -> 0, sign bit ignored,
  subnormals), the 4 q8_0 FP16 scales assembled in a GPR and converted with one
  vcvtph2ps; one mul and one FMA per iteration.
An odd trailing block uses the existing scalar loop. The AVX (non-AVX2) path
and the generic reference are unchanged.

tests: test-backend-ops perf cases at Inkling-2-Mini expert shapes (n_embd 2304,
gate_up 2304, down 1152, 128 experts / 8 used; n = 1, 8, 16, 32) for nvfp4,
mxfp4 and q4_0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PZz44SLQvTXMyWGio6t9DZ
2026-11-23 00:01:59 +01:00
..