mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 19:04:50 +07:00
[PR #623] CPU lane: IQ1_M rows with folded scales and int16 sums, IQ2_XS one-token own rows (bit for bit ggml-cpu dot) #629
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#629
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/mw00/project-maya/pull/623
Author: @SeriousRising
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:cpu-iq1m-iq2xs-rows📝 Commits (1)
b772203CPU lane: IQ1_M rows with folded scales and int16 sums, IQ2_XS one-token own rows (bit for bit ggml-cpu dot)📊 Changes
7 files changed (+186 additions, -68 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -0)📝
include/strata/kernels/cpu/iq_avx2.hpp(+1 -1)📝
include/strata/kernels/cpu/native_expert.hpp(+2 -0)📝
src/kernels/cpu/iq_avx2.cpp(+126 -62)📝
src/kernels/cpu/native_expert.cpp(+4 -2)📝
src/kernels/cpu/native_rows_exact_test.cpp(+44 -0)📝
tests/ds4_lane_bench.cpp(+8 -3)📄 Description
What.
src/kernels/cpu/iq_avx2.cpp(row_dot_iq1m,row_dot_iq2xs,iq256_rows1_supported), on top of #452's rows:IQ1_M. A microbenchmark showed #452's rows are bound by the total uop count (Broadwell: 4 a cycle, ~20 cycles per 64 weights), not by the shuffle port. Two exact integer identities cut the uops:
maddubs(|g|, sign(q8, g))equalsmaddubs(scale, sign(q8, g))with the block scale folded in, and both|g|sign ops go.madda block instead of 4madd+ 4addper 64 weights.Grid indices come from ggml's
pdepform wherepdepis fast (CPUID: BMI2, and not AMD / Hygon below family 19h), elsewhere from scalar indices into a 4-entry table. The delta signs come from one broadcast of qh, with noset_epi64x. The int32 lanes per block are ggml's exact integers, and ggml's float steps are unchanged.IQ2_XS. The grid by
tab4from scalar u16 loads, half-scales from a 256-entry table. Its one-token own rows are enabled (type 17 iniq256_rows1_supported/iq256_rows1); before, IQ2_XS at one token fell back to ggml'svec_dot.No AVX2 code runs before
main: the tables areconstexpr(.rodata), and thepdepprobe is a function-local static behindcpu_avx2_ok(), so a pre-AVX2 CPU still reaches the ggml fallback.Tests:
native_rows_exact_testgains the IQ1_M int16 worst case (every scale 15, an all +1 grid, every delta bit, q8 = -127, lanes at +-30480).ds4_lane_benchgains aniq2_xsformat and prints the exactness of each format's one-token and multi-token rows.Setting:
DS4_IQ1M_PDEP=0/1forces the index form on a BMI2 CPU, for checking the other form (both exact); unset = the CPUID choice above. A row indocs/SETTINGS.md, besideDS4_IQ1_PDEP.Overlap with #584 (open): #584 sends one-token IQ1_M rows to ggml-cpu's own BMI2 dot where
pdepis fast. This PR touches the same routing: our rows are faster than ggml's dot at one token (table below) and also cover several tokens, which #584 leaves alone. If #584 lands first, this replaces its one-token routing with these rows and would keep itscpu_pdep_slow()probe instead of ours; happy to rebase either way.pdep-free form (chosen on Zen 1/2, Hygon)pdepformOutput: unchanged, bit for bit ggml-cpu's dot:
rows_match_ggml: 306 one-token rows and nt 2/5/11, with the subnormal shifts; any mismatch falls back to ggml); both forms pass it for IQ1_M and IQ2_XS;native_rows_exact_test: "all identical" withDS4_IQ1M_PDEPunset,=0and=1;ds4_iq1_rows_test(DS4_IQ1_PDEP=0and=1, its two CMake tests): 36 cases, 0 differ from ggml-cpu's dot;ds4_lane_bench --check: IQ1_M and IQ2_XS own rows bit-identical to ggml's dot, one token and several; every format within 1.8e-7 of the double reference;ds4_gguf_test: ALL OK; the engine run below gives the same token ids and DSpark counts as v1.1.35.Measured. CPU: 16-vCPU Xeon E5-2697 v4 VM (Broadwell, AVX2 + BMI2, 4-channel DDR4-2133), g++ 13.3,
-march=native.ds4_lane_bench, one token, an expert end to end (gate/up/down, activation quant, SiLU, the pool's jobs), v1.1.35's binary vs this branch's, one run each:iq2_xsformat in v1.1.35's bench)(IQ2_XXS's code is not changed; its 1-thread difference is run-to-run spread on a shared VM.)
Engine: 2x CMP 170HX 64 GB (sm_80; PCIe Gen2 x16 + Gen2 x4, platform-specific), DeepSeek-V4.1-Flash-1017 GSQ-RCO IQ2_XXS (routed experts IQ1_M / IQ2_XS / IQ2_XXS; most in VRAM, the rest on the CPU lane),
--tp 1 --gpus 0,1 --dspark on --cpu-threads 14 --suffix-draft 0, 2000 fixed prompt ids + 256 greedy tokens, one run per binary: verify time 5086.6 -> 4529.6 ms over the same 80 DSpark rounds (-11 %), decode 40.68 -> 45.10 tok/s, the same ids. Earlier, through the server on our v1.1.29-based fork (5 prompts x 512 tokens, temperature 0): -6.5 % / -3.8 % a verify window,--dspark none-3.1 % / -2.3 % a step, the same text; the larger gain on v1.1.35 was not analysed.Zen 3 / Zen 4 / newer Intel (the
pdepform) and Zen 1/2 / Hygon (thepdep-free form): not measured. The gain depends on how much CPU-lane time is exposed; a box that streams more experts from RAM should gain more (not measured).Checks (as
.github/workflows/tests.yml):tools/check_hip_compat.pyOK; server tests 463 OK (12 skipped); installer and tools tests 584 OK (31 skipped) - the same counts as v1.1.35.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.