mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1824] [CLOSED] cpu: Q2_0 rows on AVX-only CPUs (q2_avx1.cpp) instead of ggml-cpu's scalar dot #3702
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3702
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1824
Author: @xrip
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:pr/avx1-q2-rows📝 Commits (1)
394b500cpu: Q2_0 rows on AVX-only CPUs (q2_avx1.cpp) instead of ggml-cpu's scalar dot📊 Changes
6 files changed (+341 additions, -7 deletions)
View changed files
📝
CMakeLists.txt(+10 -1)📝
include/strata/kernels/cpu/expert.hpp(+6 -0)📝
include/strata/kernels/cpu/expert_layout.hpp(+4 -4)📝
src/kernels/cpu/expert_layout.cpp(+70 -2)➕
src/kernels/cpu/q2_avx1.cpp(+85 -0)➕
src/kernels/cpu/q2_avx1_parity.cpp(+166 -0)📄 Description
What
The older-CPU build (
STRATA_ISA_FLOOR=avx) on an AVX-only CPU (Sandy / Ivy Bridge, Xeon E5 v1/v2): a native pack'sQ2_0 expert rows run on a new AVX kernel (
src/kernels/cpu/q2_avx1.cpp) instead of ggml-cpu's Q2_0vec_dot, whichis scalar on x86. Bitwise the same results as the scalar reference. AVX2 / AVX-512 CPUs and CPUs without AVX run the
same code as before.
Why
In the IQ3_XXS pack, Q2_0 is the down projection of 30 of the 48 layers, so on these CPUs most CPU expert work went
through a scalar loop.
Change
q2_native_kernels()also accepts an AVX-only CPU (cpu_avx1_ok()).q2_rows_any: AVX-512 -> AVX2 -> AVX1 (new) -> scalar.act_quant_anyuses a scalar Q8_1 quantizer without AVX2.q2_0_gguf_rows_multi_avx1: compiled with-mavx//arch:AVXonly (no FMA). The 2-bit codes are unpacked onceper block for all tokens; SSSE3
maddubs/maddinteger dots (exact: a pair sums to at most 762, no saturation);an exact half -> float; the float steps in the scalar order, so the bits equal
q2_0_gguf_rows_multi_scalar.kq_avx1.cpp.q2_avx1_parity(ctest; exit 77 without AVX).Measured
2x Xeon E5-2670 v2 (Ivy Bridge-EP), GCC 14.2:
q2_avx1_parity: bitwise equal to the scalar reference for all 65,536 half scales and 216 random cases (1-12tokens, partial row ranges, padded and unaligned rows, edge and zero-scale activations).
Measured on a fork based on 0.1.38. On current
main(0.1.41) it was checked on a Ryzen 7 5700X withSTRATA_FORCE_ISA=avx:q2_avx1_paritypasses (12.5x over scalar at 1 token), and so do all CPU tests.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.