[PR #4763] [Engine] opt-in Zen 5 gather, IQ4_NL 512-bit down, and V-Cache pool #5170

Open
opened 2026-11-07 16:33:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4763
Author: @Yoshiki-Matsuda
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: engine/opt-in-vcache-cpu-paths


📝 Commits (3)

  • dcc20e1 [Engine] keep Zen 5 gather, IQ4_NL 512-bit down, and the V-Cache pool opt-in
  • abf2d09 [Engine] query L3 only on Linux so the Metal build compiles
  • a4ff1d0 [Engine] call the AVX-512 Hadamard only on x86

📊 Changes

14 files changed (+816 additions, -67 deletions)

View changed files

📝 docs/DETAILS.md (+8 -0)
📝 include/strata/kernels/cpu/expert_layout.hpp (+11 -0)
📝 include/strata/kernels/cpu/iq_avx512.hpp (+10 -0)
📝 include/strata/kernels/cpu/pool.hpp (+5 -0)
📝 include/strata/kernels/cpu/pool_plan.hpp (+78 -0)
📝 src/kernels/cpu/expert_layout.cpp (+77 -0)
📝 src/kernels/cpu/hadamard.cpp (+9 -0)
📝 src/kernels/cpu/iq_avx512.cpp (+288 -46)
📝 src/kernels/cpu/kq_cpu_bench.cpp (+93 -11)
📝 src/kernels/cpu/native_expert.cpp (+44 -0)
📝 src/kernels/cpu/pool.cpp (+137 -9)
📝 src/kernels/cpu/pool_plan_test.cpp (+48 -0)
📝 src/kernels/cpu/portable.cpp (+6 -0)
📝 tools/check_isa_guard.py (+2 -1)

📄 Description

Summary

  • Adds three opt-in CPU paths. With nothing set, expert kernels and core order stay as they were.
  • STRATA_IQ_GATHER=1 gathers i-quant codebooks. That is already the default on Intel CPUs where gathers are fast. On Zen 5 it also sends one token of IQ3_XXS and IQ3_S through the 512-bit exact rows, unless STRATA_NO_IQ512X1=1.
  • STRATA_IQ4NL512=1 uses a 512-bit IQ4_NL down kernel after a one-time check against this build's ggml dot.
  • STRATA_VCACHE_POOL=1 fuses gate and up, uses a 512-bit Hadamard rotation, aligns CPU expert tasks to 16 rows, and on a two-CCD X3D places workers on the larger L3. A one-CCD CPU keeps its usual core order.

No prior issue. #4055 asks for IQ4_NL gate/up format support and is a different change.

What was measured

Decode tokens/s was not measured. The numbers below are one CPU-pool microbench on synthetic iq3_s/iq4_nl experts (kq_cpu_bench --pool --hadamard), not a strata generate run.

Machine: Windows, Ryzen 7 9800X3D (Zen 5, one CCD, 96 MB L3, AVX-512). Eight threads, host thread pinned to core 0. Same binary, flags off against flags on. "1 token" means one token routed to that expert. "2" and "4" mean that many tokens of a verify window share the expert, as with --spec / MTP. It is not the length of the reply.

Weight-read rate, GB/s, off to on:

Working set 1 token 2 tokens 4 tokens
16 MB (inside L3) 35.1 to 38.0 (+8%) 29.2 to 37.7 (+29%) 25.6 to 30.3 (+18%)
33 MB 49.8 to 43.2 (−13%) 37.6 to 45.4 (+21%) 32.7 to 35.7 (+9%)
49 MB 41.0 to 38.5 (−6%) 37.0 to 39.7 (+7%) 31.3 to 34.3 (+10%)
65 MB 40.5 to 44.6 (+10%) 33.3 to 39.5 (+19%) 29.4 to 35.5 (+21%)
536 MB (from DRAM) 38.9 to 36.7 (−6%) 30.9 to 35.6 (+15%) 30.9 to 33.0 (+7%)

One token is not consistently slower: two of the five sizes were faster. Another run of the on side at 49 MB and one token read 41.9, 44.3, and 51.8 GB/s, so the smaller gaps sit inside run-to-run noise. Two and four tokens were faster in this sweep (+7% to +29%) and were not repeated enough to treat that as a decode result.

On this CPU the V-Cache placement does nothing: every core shares the 96 MB L3. The on side still changes fused gate/up, the 512-bit Hadamard, 16-row task edges, gather, and the IQ4_NL down kernel.

The same PC's usual IQ3_S serve is a two-GPU layer split. The fast card (170 SMs, 2.41 GHz) runs layers 0–46. The second card (82 SMs, 1.70 GHz, 6.4 GB/s host-to-device) runs layer 47 only. Startup predicted about 98% of profiled routed mass in the two caches, and long replies were about 60–110 tok/s. The CPU only computes cache misses, so a change in the table above does not move those tok/s by the same percent. That serve was not re-run with these flags.

How to turn it on

Use a build that contains this commit. A released engine from before this pull request does not have STRATA_IQ4NL512 or STRATA_VCACHE_POOL.

On the 9800X3D above, all three switches together are the whole patch. STRATA_VCACHE_POOL=1 does not move threads on that one-CCD CPU. Put them in the model config's "env" object and restart:

"env": {
  "STRATA_IQ_GATHER": "1",
  "STRATA_IQ4NL512": "1",
  "STRATA_VCACHE_POOL": "1"
}

Unset means off. STRATA_IQ_GATHER=0 forces scalar codebook loads. STRATA_NO_IQ512X1=1 keeps one-token IQ3_XXS / IQ3_S on ggml's dot even when gather is on.

A two-CCD X3D (7900X3D, 7950X3D, 9900X3D, 9950X3D) is the only case where STRATA_VCACHE_POOL=1 also places workers on the 96 MB CCD and the host thread on the 32 MB CCD. That placement was checked with a synthetic topology in pool_plan_test. It was not timed on a two-CCD machine.

Test plan

  • Passed: portable AVX2 build (STRATA_PORTABLE=ON) on Windows, Ryzen 7 9800X3D. pool_plan_test, pool_cores_test, pool_tasks_test (648 bitwise comparisons), q8k_quant_parity, iq512_gather_parity (gather off), iq_avx2_parity (0 failures), native_arithmetic_parity (4,866,048 comparisons).
  • Passed: the same binaries with STRATA_VCACHE_POOL=1 (pool_tasks_test), STRATA_VCACHE_POOL=1 plus STRATA_IQ4NL512=1 (native_arithmetic_parity), and STRATA_IQ_GATHER=1 (iq512_gather_parity, types 18, 21, 22).
  • Passed: isa_guard_check on that portable iq_avx2_parity.exe: 4718 functions, 145 with wide instructions, 0 not allowed.
  • Passed: CUDA 13.3 configure and cmake --build build-cuda --config Release --target strata on this PC (CMAKE_CUDA_ARCHITECTURES=native). build-cuda/Release/strata.exe linked, including the changed CPU objects.
  • Failed: none in the runs above.
  • Not run: HIP (hipcc is not installed) and SYCL (icpx is not installed). Intel SDE AVX2-only and AVX-VNNI-only runs were not run. End-to-end decode tokens/s was not measured.

These paths stay opt-in because the CPU microbench does not justify changing the default.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4763 **Author:** [@Yoshiki-Matsuda](https://github.com/Yoshiki-Matsuda) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `engine/opt-in-vcache-cpu-paths` --- ### 📝 Commits (3) - [`dcc20e1`](https://github.com/Niko1221/Strata/commit/dcc20e107b0d982adb6a834a8903435f64d134ee) [Engine] keep Zen 5 gather, IQ4_NL 512-bit down, and the V-Cache pool opt-in - [`abf2d09`](https://github.com/Niko1221/Strata/commit/abf2d09b9cb75347ca7244e320b8494a0857cff3) [Engine] query L3 only on Linux so the Metal build compiles - [`a4ff1d0`](https://github.com/Niko1221/Strata/commit/a4ff1d0cef6aa09695b35c98c9a074526c385541) [Engine] call the AVX-512 Hadamard only on x86 ### 📊 Changes **14 files changed** (+816 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+8 -0) 📝 `include/strata/kernels/cpu/expert_layout.hpp` (+11 -0) 📝 `include/strata/kernels/cpu/iq_avx512.hpp` (+10 -0) 📝 `include/strata/kernels/cpu/pool.hpp` (+5 -0) 📝 `include/strata/kernels/cpu/pool_plan.hpp` (+78 -0) 📝 `src/kernels/cpu/expert_layout.cpp` (+77 -0) 📝 `src/kernels/cpu/hadamard.cpp` (+9 -0) 📝 `src/kernels/cpu/iq_avx512.cpp` (+288 -46) 📝 `src/kernels/cpu/kq_cpu_bench.cpp` (+93 -11) 📝 `src/kernels/cpu/native_expert.cpp` (+44 -0) 📝 `src/kernels/cpu/pool.cpp` (+137 -9) 📝 `src/kernels/cpu/pool_plan_test.cpp` (+48 -0) 📝 `src/kernels/cpu/portable.cpp` (+6 -0) 📝 `tools/check_isa_guard.py` (+2 -1) </details> ### 📄 Description ## Summary - Adds three opt-in CPU paths. With nothing set, expert kernels and core order stay as they were. - `STRATA_IQ_GATHER=1` gathers i-quant codebooks. That is already the default on Intel CPUs where gathers are fast. On Zen 5 it also sends one token of IQ3_XXS and IQ3_S through the 512-bit exact rows, unless `STRATA_NO_IQ512X1=1`. - `STRATA_IQ4NL512=1` uses a 512-bit IQ4_NL down kernel after a one-time check against this build's ggml dot. - `STRATA_VCACHE_POOL=1` fuses gate and up, uses a 512-bit Hadamard rotation, aligns CPU expert tasks to 16 rows, and on a two-CCD X3D places workers on the larger L3. A one-CCD CPU keeps its usual core order. No prior issue. [#4055](https://github.com/Niko1221/Strata/issues/4055) asks for IQ4_NL gate/up format support and is a different change. ## What was measured Decode tokens/s was not measured. The numbers below are one CPU-pool microbench on synthetic `iq3_s/iq4_nl` experts (`kq_cpu_bench --pool --hadamard`), not a `strata` generate run. Machine: Windows, Ryzen 7 9800X3D (Zen 5, one CCD, 96 MB L3, AVX-512). Eight threads, host thread pinned to core 0. Same binary, flags off against flags on. "1 token" means one token routed to that expert. "2" and "4" mean that many tokens of a verify window share the expert, as with `--spec` / MTP. It is not the length of the reply. Weight-read rate, GB/s, off to on: | Working set | 1 token | 2 tokens | 4 tokens | | --- | --- | --- | --- | | 16 MB (inside L3) | 35.1 to 38.0 (+8%) | 29.2 to 37.7 (+29%) | 25.6 to 30.3 (+18%) | | 33 MB | 49.8 to 43.2 (−13%) | 37.6 to 45.4 (+21%) | 32.7 to 35.7 (+9%) | | 49 MB | 41.0 to 38.5 (−6%) | 37.0 to 39.7 (+7%) | 31.3 to 34.3 (+10%) | | 65 MB | 40.5 to 44.6 (+10%) | 33.3 to 39.5 (+19%) | 29.4 to 35.5 (+21%) | | 536 MB (from DRAM) | 38.9 to 36.7 (−6%) | 30.9 to 35.6 (+15%) | 30.9 to 33.0 (+7%) | One token is not consistently slower: two of the five sizes were faster. Another run of the on side at 49 MB and one token read 41.9, 44.3, and 51.8 GB/s, so the smaller gaps sit inside run-to-run noise. Two and four tokens were faster in this sweep (+7% to +29%) and were not repeated enough to treat that as a decode result. On this CPU the V-Cache placement does nothing: every core shares the 96 MB L3. The on side still changes fused gate/up, the 512-bit Hadamard, 16-row task edges, gather, and the IQ4_NL down kernel. The same PC's usual IQ3_S serve is a two-GPU layer split. The fast card (170 SMs, 2.41 GHz) runs layers 0–46. The second card (82 SMs, 1.70 GHz, 6.4 GB/s host-to-device) runs layer 47 only. Startup predicted about 98% of profiled routed mass in the two caches, and long replies were about 60–110 tok/s. The CPU only computes cache misses, so a change in the table above does not move those tok/s by the same percent. That serve was not re-run with these flags. ## How to turn it on Use a build that contains this commit. A released engine from before this pull request does not have `STRATA_IQ4NL512` or `STRATA_VCACHE_POOL`. On the 9800X3D above, all three switches together are the whole patch. `STRATA_VCACHE_POOL=1` does not move threads on that one-CCD CPU. Put them in the model config's `"env"` object and restart: ```json "env": { "STRATA_IQ_GATHER": "1", "STRATA_IQ4NL512": "1", "STRATA_VCACHE_POOL": "1" } ``` Unset means off. `STRATA_IQ_GATHER=0` forces scalar codebook loads. `STRATA_NO_IQ512X1=1` keeps one-token IQ3_XXS / IQ3_S on ggml's dot even when gather is on. A two-CCD X3D (7900X3D, 7950X3D, 9900X3D, 9950X3D) is the only case where `STRATA_VCACHE_POOL=1` also places workers on the 96 MB CCD and the host thread on the 32 MB CCD. That placement was checked with a synthetic topology in `pool_plan_test`. It was not timed on a two-CCD machine. ## Test plan - [x] Passed: portable AVX2 build (`STRATA_PORTABLE=ON`) on Windows, Ryzen 7 9800X3D. `pool_plan_test`, `pool_cores_test`, `pool_tasks_test` (648 bitwise comparisons), `q8k_quant_parity`, `iq512_gather_parity` (gather off), `iq_avx2_parity` (0 failures), `native_arithmetic_parity` (4,866,048 comparisons). - [x] Passed: the same binaries with `STRATA_VCACHE_POOL=1` (`pool_tasks_test`), `STRATA_VCACHE_POOL=1` plus `STRATA_IQ4NL512=1` (`native_arithmetic_parity`), and `STRATA_IQ_GATHER=1` (`iq512_gather_parity`, types 18, 21, 22). - [x] Passed: `isa_guard_check` on that portable `iq_avx2_parity.exe`: 4718 functions, 145 with wide instructions, 0 not allowed. - [x] Passed: CUDA 13.3 configure and `cmake --build build-cuda --config Release --target strata` on this PC (`CMAKE_CUDA_ARCHITECTURES=native`). `build-cuda/Release/strata.exe` linked, including the changed CPU objects. - [x] Failed: none in the runs above. - [ ] Not run: HIP (`hipcc` is not installed) and SYCL (`icpx` is not installed). Intel SDE AVX2-only and AVX-VNNI-only runs were not run. End-to-end decode tokens/s was not measured. These paths stay opt-in because the CPU microbench does not justify changing the default. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5170
No description provided.