[PR #584] [CLOSED] CPU lane: IQ1_M one-token rows take ggml-cpu's dot where pdep is fast #608

Closed
opened 2026-10-29 21:27:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/584
Author: @somnergy
Created: 10/28/2026
Status: ❌ Closed

Base: main ← Head: perf/iq1m-pdep-zen3


📝 Commits (1)

  • 414329b CPU lane: IQ1_M one-token rows take ggml-cpu's dot where pdep is fast

📊 Changes

5 files changed (+45 additions, -36 deletions)

View changed files

📝 docs/SETTINGS.md (+1 -1)
📝 include/strata/kernels/cpu/expert_layout.hpp (+3 -0)
📝 src/ds4/ds4_iq_cpu.cpp (+6 -33)
📝 src/kernels/cpu/expert_layout.cpp (+31 -0)
📝 src/kernels/cpu/native_expert.cpp (+4 -2)

📄 Description

The CPU lane's one-token IQ1_M rows (#452) build the grid indices without BMI2 pdep. That suits AMD family 17h (Zen, Zen+, Zen 2) and Hygon, where pdep runs in microcode. On every other CPU with BMI2, ggml-cpu's own IQ1_M dot builds the indices with pdep and is about 2× faster per core for a single token.

With this change, a decode step's IQ1_M experts use ggml-cpu's dot wherever pdep is fast. The pdep-free rows still serve family 17h/18h, and multi-token rows are unchanged. The existing slow-pdep CPUID probe moves, unchanged, from the DeepSeek IQ1_S rows into the CPU kernel library as cpu_pdep_slow(), so both choices share it.

Results

Verdict by CPU class:

  • Zen 4: one-token IQ1_M experts run 2.1× faster on one core, and 29-49% faster at 24-40 threads. The other formats are unchanged.
  • Zen 3, Intel Haswell and later: not measured. Expected to gain the same way: it is the path MAYA_GLM_CPU_1T=0 already chose there.
  • Zen 1/2, Hygon: unchanged by construction (the same rows as before). Not measured.

Measured on a Threadripper 7980X (Zen 4), with the engine's own iq_cpu_gate_up / iq_cpu_down on real IQ1_M / IQ2 experts of a DeepSeek-V4.1-Flash GGUF. Figures are µs per expert, one token each, median of 2 runs over 64 experts. k is the number of experts in the batch; the format pairs are gate-up / down.

format k 1 thread 24 threads 40 threads
IQ1_M / IQ1_M 1 3519 → 1642 218.5 → 112.5 126.1 → 89.9
IQ1_M / IQ1_M 6 3538 → 1653 165.5 → 82.8 113.3 → 62.1
IQ2_XXS / IQ1_M 1 2357 → 1740 152.1 → 119.1 96.1 → 85.5
IQ2_XS / IQ1_M 1 2260 → 1624 145.7 → 112.8 98.3 → 89.0
IQ2_XXS / IQ2_XXS (unchanged) 1 1771 → 1780 122.0 → 122.8 86.8 → 89.5
IQ2_XS / IQ2_XS (unchanged) 1 1628 → 1610 114.6 → 113.5 91.2 → 90.8

The unchanged formats move within the harness's run-to-run spread.

Correctness

  • Against a double-precision reference on real weights, all 8 format combinations show the same maximum relative error before and after (1.61e-7).
  • These tests pass: native_rows_exact_test, native_split_test, ds4_iq1_rows_test (with DS4_IQ1_PDEP=0 and =1), and tools/check_hip_compat.py.
  • The test "split iq1_m window of 6 vs one token at a time: identical" still holds. It now compares ggml's one-token dot with the multi-token rows, so a drafter's verify window gives the same results as single tokens.

Settings

Nothing to set. MAYA_GLM_CPU_1T=0 is no longer needed to get the faster IQ1_M path.

Multi-token IQ1_M is left alone on purpose: ggml is faster at 2 tokens on one core, but loses at 4 tokens and at 40 threads.


🔄 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/mw00/project-maya/pull/584 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `perf/iq1m-pdep-zen3` --- ### 📝 Commits (1) - [`414329b`](https://github.com/mw00/project-maya/commit/414329bded9034203ed3b89210dfaf7ca8e37d40) CPU lane: IQ1_M one-token rows take ggml-cpu's dot where pdep is fast ### 📊 Changes **5 files changed** (+45 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -1) 📝 `include/strata/kernels/cpu/expert_layout.hpp` (+3 -0) 📝 `src/ds4/ds4_iq_cpu.cpp` (+6 -33) 📝 `src/kernels/cpu/expert_layout.cpp` (+31 -0) 📝 `src/kernels/cpu/native_expert.cpp` (+4 -2) </details> ### 📄 Description The CPU lane's one-token IQ1_M rows (#452) build the grid indices without BMI2 `pdep`. That suits AMD family 17h (Zen, Zen+, Zen 2) and Hygon, where `pdep` runs in microcode. On every other CPU with BMI2, ggml-cpu's own IQ1_M dot builds the indices with `pdep` and is about 2× faster per core for a single token. With this change, a decode step's IQ1_M experts use ggml-cpu's dot wherever `pdep` is fast. The pdep-free rows still serve family 17h/18h, and multi-token rows are unchanged. The existing slow-pdep CPUID probe moves, unchanged, from the DeepSeek IQ1_S rows into the CPU kernel library as `cpu_pdep_slow()`, so both choices share it. ## Results Verdict by CPU class: - **Zen 4:** one-token IQ1_M experts run 2.1× faster on one core, and 29-49% faster at 24-40 threads. The other formats are unchanged. - **Zen 3, Intel Haswell and later:** not measured. Expected to gain the same way: it is the path `MAYA_GLM_CPU_1T=0` already chose there. - **Zen 1/2, Hygon:** unchanged by construction (the same rows as before). Not measured. Measured on a Threadripper 7980X (Zen 4), with the engine's own `iq_cpu_gate_up` / `iq_cpu_down` on real IQ1_M / IQ2 experts of a DeepSeek-V4.1-Flash GGUF. Figures are µs per expert, one token each, median of 2 runs over 64 experts. `k` is the number of experts in the batch; the format pairs are gate-up / down. | format | k | 1 thread | 24 threads | 40 threads | |---|---|---|---|---| | IQ1_M / IQ1_M | 1 | 3519 → 1642 | 218.5 → 112.5 | 126.1 → 89.9 | | IQ1_M / IQ1_M | 6 | 3538 → 1653 | 165.5 → 82.8 | 113.3 → 62.1 | | IQ2_XXS / IQ1_M | 1 | 2357 → 1740 | 152.1 → 119.1 | 96.1 → 85.5 | | IQ2_XS / IQ1_M | 1 | 2260 → 1624 | 145.7 → 112.8 | 98.3 → 89.0 | | IQ2_XXS / IQ2_XXS (unchanged) | 1 | 1771 → 1780 | 122.0 → 122.8 | 86.8 → 89.5 | | IQ2_XS / IQ2_XS (unchanged) | 1 | 1628 → 1610 | 114.6 → 113.5 | 91.2 → 90.8 | The unchanged formats move within the harness's run-to-run spread. ## Correctness - Against a double-precision reference on real weights, all 8 format combinations show the same maximum relative error before and after (1.61e-7). - These tests pass: `native_rows_exact_test`, `native_split_test`, `ds4_iq1_rows_test` (with `DS4_IQ1_PDEP=0` and `=1`), and `tools/check_hip_compat.py`. - The test "split iq1_m window of 6 vs one token at a time: identical" still holds. It now compares ggml's one-token dot with the multi-token rows, so a drafter's verify window gives the same results as single tokens. ## Settings Nothing to set. `MAYA_GLM_CPU_1T=0` is no longer needed to get the faster IQ1_M path. Multi-token IQ1_M is left alone on purpose: ggml is faster at 2 tokens on one core, but loses at 4 tokens and at 40 threads. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:27:27 +07:00
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#608
No description provided.