mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2215] [CLOSED] cpu: one token's IQ3_XXS/IQ3_S/IQ2_S gate/up rows in ggml's exact bits, faster (same output; STRATA_CPU_SINGLE_EXACT=0 keeps ggml's dot) #3926
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#3926
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/2215
Author: @aslater3
Created: 10/13/2026
Status: ❌ Closed
Base:
main← Head:a770/up-cpu-exact📝 Commits (1)
bfd6680cpu: one token's IQ3_XXS/IQ3_S/IQ2_S gate/up rows in ggml's exact bits, faster (STRATA_CPU_SINGLE_EXACT=0 keeps ggml's dot)📊 Changes
7 files changed (+189 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+9 -0)📝
docs/DETAILS.md(+12 -0)📝
include/strata/kernels/cpu/iq_avx2.hpp(+7 -0)📝
src/kernels/cpu/iq_avx2.cpp(+63 -0)➕
src/kernels/cpu/iq_single_parity.cpp(+74 -0)📝
src/kernels/cpu/native_expert.cpp(+19 -0)📝
sycl/CMakeLists.txt(+5 -0)📄 Description
Title
Issue: none (CPU decode speed on AVX2 machines without AVX-512)
Summary
On an AVX-2 CPU without AVX-512, a CPU expert that serves one token runs ggml-cpu's single-token
vec_dot(#152). This adds a gate/up kernel for IQ3_XXS / IQ3_S / IQ2_S that uses the AVX-2 rows' decode but keeps ggml's float order exactly (the same per-lane integer sums,d = x.d * y.dand one fmadd per block, the format constant afterhsum_float_8's tree), so the output does not change, only the time: one-token gate/up -27% (IQ3_S) and -6% (IQ3_XXS) per expert on a Ryzen 7 3800X.STRATA_CPU_SINGLE_EXACT=0keeps ggml's dot.What changed
src/kernels/cpu/iq_avx2.cpp,include/strata/kernels/cpu/iq_avx2.hpp:iq256_gu_single_exact(+row_dot_single,gu_single,hsum8_ggml). Upstream's multi-token kernels are untouched.src/kernels/cpu/native_expert.cpp:native_gu_rowstakes it fornt == 1, types 18/21/22, only where it would have reached ggml's dot (after the multi-token checks, soSTRATA_IQ_MT_MIN/STRATA_IQ3S_MT1behave as before), the CPU has AVX2 and no AVX-512, and ggml-cpu itself was built for AVX2 and not AVX-512 (ggml_cpu_has_*: aSTRATA_ISA_FLOORbuild's ggml dots round differently).STRATA_NO_IQ256still means ggml's dot. Down rows are unchanged.src/kernels/cpu/iq_single_parity.cpp(new): the kernel andnative_gu_rowsat one token against ggml'svec_dotbit for bit; exit 77 where the reference is not ggml's AVX2 build. Registered in the top-level build (also asiq_single_parity_offwithSTRATA_CPU_SINGLE_EXACT=0) and insycl/.docs/DETAILS.md: a paragraph with the switch and the numbers below.How it was checked
Ryzen 7 3800X (Zen 2, AVX2, no AVX-512), Ubuntu 26.04.1, g++ 15.2 (top-level CPU build) and icpx 2026.1 (SYCL build).
iq_single_parity: 0 bitwise mismatches (default andSTRATA_CPU_SINGLE_EXACT=0);iq_avx2_parity: 0 failures.iq_avx2_parity --bench --dispatch, 1 token, one thread, engine path, ms per expert (gate/up): IQ3_S 0.497 -> 0.365, IQ3_XXS 0.343 -> 0.322; down unchanged (0.095).pool multistats): gate/up 15.2-15.4 -> 14.0-14.2 ms/round, CPU pool call about -3%, output ids identical in every run. End-to-end decode did not change measurably there (the pool is ~30 ms of a ~110 ms round).Not built: CUDA and HIP (no toolchains on this machine). The files are shared CPU code; nothing CUDA/HIP-specific is touched, but please build those before merging. Measured on Zen 2 only.
Extra Notes
An earlier version also had an exact IQ4_NL down kernel; it measured ~2% slower in the engine, so it is not in this PR.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.