[GH-ISSUE #4728] [Engine] AVX-only CPUs: a native pack's Q2_0 experts still run on ggml-cpu's vec_dot, not on q2_avx1.cpp #2166

Open
opened 2026-11-04 01:57:10 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Keoian on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4728

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Let a native pack's Q2_0 experts run on Strata's AVX1 Q2_0 rows (q2_avx1.cpp) on CPUs with AVX but no AVX2, instead of ggml-cpu's Q2_0 vec_dot. This only concerns the experimental older-CPU source build (STRATA_ISA_FLOOR=avx); release engines need AVX2 and are not affected.

Why I am raising it again. #1824 proposed this and was closed as covered: "The base already has a Q2_0 AVX kernel for CPUs without AVX2 (q2_avx1.cpp, from the #1699 fix)". The kernel is there, but a native pack never reaches it on these CPUs. The gate in include/strata/kernels/cpu/expert_layout.hpp still admits AVX2 only:

inline bool q2_native_kernels(int type) { return type == 42 && cpu_avx2_ok(); }

So on an AVX-only CPU every native pack's Q2_0 layer takes ggml-cpu's own vec_dot. That includes ISTA-DASLab's Qwen3.8-Flash-Next Q2_0 and the Q2_0 down projections of the IQ3_XXS pack that #1824 mentions. kq_cpu_bench on main says so itself: its Q2_0 line has no "on Strata's rows (the pool's path)" suffix there.

Measured. i7-3770 (Ivy Bridge, AVX, no AVX2), DDR3-1600, GCC 15, built from 870aedd9 with STRATA_ISA_FLOOR=avx. kq_cpu_bench --pairs q2_0/q2_0 --mb 1024 --reps 3, ms per expert per thread at 1 / 3 / 4 tokens:

Build Legacy rows STRATA_Q2_BITPLANE=1
main (ggml-cpu vec_dot) 0.975 / 2.89 / 3.78 0.975 / 2.89 / 3.79 (not used)
gate admits cpu_avx1_ok() 0.517 / 1.13 / 1.40 0.418 / 0.807 / 0.954
+ the bit-plane pair's float part on 256 bits (bytes unchanged) 0.487 / 1.11 / 1.38 0.297 / 0.597 / 0.752

End to end, on the same CPU with 2x RX 5700 XT 8 GB (gfx1010, layer split 27), Qwen3.8-Flash-Next ISTA-DASLab Q2_0, --spec 4 --mtp, STRATA_Q2_BITPLANE=1, STRATA_HC_Q8=0, 3 prompts x 2 reps x 2 engine starts in ABBA order, 256 tokens greedy: decode 14.97 tok/s on main against 22.38 with both commits (+49.6%, 11 of 12 pairs faster).

Proposed change. Two commits, ready on https://github.com/Keoian/Strata/tree/avx1-q2-native-rows:

  1. q2_native_kernels() also admits cpu_avx1_ok(). A CPU without AVX keeps ggml-cpu.
  2. The AVX1 bit-plane row computes a pair's float part in one 256-bit register, and a normal fp16 block scale is converted without branches. Both kernels' outputs are byte-identical before and after (hashes of fixed random blocks at 1-8 tokens), and q2_bitplane_parity passes.

On these CPUs the first commit changes bits against ggml-cpu's path, since the AVX1 rows sum floats in their own order. AVX2 CPUs already take Strata's rows. AVX2 / AVX-512 CPUs and the release engines are unchanged.

Would you take this as a pull request? If you want the gate only, the second commit can be left out.

What do you do today instead?

I build the engine from my fork with these two commits.

Originally created by @Keoian on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4728 ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? Let a native pack's Q2_0 experts run on Strata's AVX1 Q2_0 rows (`q2_avx1.cpp`) on CPUs with AVX but no AVX2, instead of ggml-cpu's Q2_0 `vec_dot`. This only concerns the experimental older-CPU source build (`STRATA_ISA_FLOOR=avx`); release engines need AVX2 and are not affected. **Why I am raising it again.** #1824 proposed this and was closed as covered: "The base already has a Q2_0 AVX kernel for CPUs without AVX2 (q2_avx1.cpp, from the #1699 fix)". The kernel is there, but a native pack never reaches it on these CPUs. The gate in `include/strata/kernels/cpu/expert_layout.hpp` still admits AVX2 only: ```cpp inline bool q2_native_kernels(int type) { return type == 42 && cpu_avx2_ok(); } ``` So on an AVX-only CPU every native pack's Q2_0 layer takes ggml-cpu's own `vec_dot`. That includes ISTA-DASLab's Qwen3.8-Flash-Next Q2_0 and the Q2_0 down projections of the IQ3_XXS pack that #1824 mentions. `kq_cpu_bench` on main says so itself: its Q2_0 line has no "on Strata's rows (the pool's path)" suffix there. **Measured.** i7-3770 (Ivy Bridge, AVX, no AVX2), DDR3-1600, GCC 15, built from 870aedd9 with `STRATA_ISA_FLOOR=avx`. `kq_cpu_bench --pairs q2_0/q2_0 --mb 1024 --reps 3`, ms per expert per thread at 1 / 3 / 4 tokens: | Build | Legacy rows | `STRATA_Q2_BITPLANE=1` | | --- | --- | --- | | main (ggml-cpu `vec_dot`) | 0.975 / 2.89 / 3.78 | 0.975 / 2.89 / 3.79 (not used) | | gate admits `cpu_avx1_ok()` | 0.517 / 1.13 / 1.40 | 0.418 / 0.807 / 0.954 | | + the bit-plane pair's float part on 256 bits (bytes unchanged) | 0.487 / 1.11 / 1.38 | 0.297 / 0.597 / 0.752 | End to end, on the same CPU with 2x RX 5700 XT 8 GB (gfx1010, layer split 27), Qwen3.8-Flash-Next ISTA-DASLab Q2_0, `--spec 4 --mtp`, `STRATA_Q2_BITPLANE=1`, `STRATA_HC_Q8=0`, 3 prompts x 2 reps x 2 engine starts in ABBA order, 256 tokens greedy: decode 14.97 tok/s on main against 22.38 with both commits (+49.6%, 11 of 12 pairs faster). **Proposed change.** Two commits, ready on https://github.com/Keoian/Strata/tree/avx1-q2-native-rows: 1. `q2_native_kernels()` also admits `cpu_avx1_ok()`. A CPU without AVX keeps ggml-cpu. 2. The AVX1 bit-plane row computes a pair's float part in one 256-bit register, and a normal fp16 block scale is converted without branches. Both kernels' outputs are byte-identical before and after (hashes of fixed random blocks at 1-8 tokens), and `q2_bitplane_parity` passes. On these CPUs the first commit changes bits against ggml-cpu's path, since the AVX1 rows sum floats in their own order. AVX2 CPUs already take Strata's rows. AVX2 / AVX-512 CPUs and the release engines are unchanged. Would you take this as a pull request? If you want the gate only, the second commit can be left out. ### What do you do today instead? I build the engine from my fork with these two commits.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2166
No description provided.