mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #863] [CLOSED] cpu kernels: gathered decode on the cores where it is faster, AVX-VNNI rows, IQ3_S one-token kernel #2880
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#2880
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/863
Author: @Hardin22
Created: 10/5/2026
Status: ❌ Closed
Base:
main← Head:pr/cpu-iq-kernels📝 Commits (3)
bc48c52iq_avx2: the gathered IQ3_XXS / IQ3_S / IQ2_S decode on the cores where it is faster (STRATA_IQ256_GATHER auto)e9802b4cpu kernels: AVX-VNNI forms of the AVX-2 i-quant, IQ4_NL and Q2_0 rows (cpu_avxvnni_ok)695a75bnative experts: IQ3_S takes the AVX-2 kernel for one token too where its grid is gathered📊 Changes
13 files changed (+1293 additions, -317 deletions)
View changed files
📝
CMakeLists.txt(+36 -0)📝
docs/DETAILS.md(+3 -1)📝
include/strata/kernels/cpu/expert.hpp(+3 -0)📝
include/strata/kernels/cpu/expert_layout.hpp(+16 -0)📝
include/strata/kernels/cpu/iq_avx2.hpp(+18 -0)📝
include/strata/kernels/cpu/native_expert.hpp(+3 -0)📝
src/kernels/cpu/expert_layout.cpp(+78 -0)📝
src/kernels/cpu/iq_avx2.cpp(+167 -263)➕
src/kernels/cpu/iq_avx2_parity.cpp(+552 -0)➕
src/kernels/cpu/iq_avx2_rows.inl(+290 -0)📝
src/kernels/cpu/native_expert.cpp(+19 -5)📝
src/kernels/cpu/q2_avx2.cpp(+41 -48)➕
src/kernels/cpu/q2_avx2_rows.inl(+67 -0)📄 Description
Three changes to the AVX2 expert kernels. Each one gives the same bits as the scalar path, except (c), which follows the #152 rule.
STRATA_IQ256_GATHER: unset = auto, 0 = off, 1 = every core).dd24a55.vpdpwssd/vpdpbusdforms of the i-quant, IQ4_NL and Q2_0 rows. Integer sums, so the same bits.cpu_avxvnni_ok(), which lives inexpert_layout.cpp(not compiled for AVX2) and respectsSTRATA_FORCE_ISAandSTRATA_ISA_FLOOR.STRATA_NO_AVXVNNI=1turns it off.target("avxvnni"), and only if CMake finds the intrinsics. No file gets-mavxvnni.STRATA_IQ_MT_MINkeeps its meaning.Test:
iq_avx2_parity, a CPU-only CTest. Random blocks for IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S and IQ4_XS gate/up rows and IQ4_NL / Q2_0 down rows. Every variant at 1..8 tokens must match the scalar variant bit for bit; the scalar rows are checked against ggml's vec_dot (Q2_0 against a double reference).STRATA_IQ256_GATHER=0,STRATA_IQ_MT_MIN=1,STRATA_NO_AVXVNNI=1andSTRATA_FORCE_ISA=avx2, and pinned to a P-core and to an E-core.STRATA_FORCE_ISA=avxit skips cleanly.Measured (
iq_avx2_parity --bench --dispatch, i9-14900KF, one thread, more expert blobs than L3, median of 5)Engine path, ms per expert (gate/up + down) at 1-4 tokens. Upstream main is shown at its default (
STRATA_IQ256_GATHERunset = 0) and with=1:The full grid has 5 formats × 1-4 tokens × P/E core. Nowhere is it slower than main beyond noise. On E-cores,
gather=1is 40-75% slower, which is why auto leaves them alone.End to end: Swift 1.5 IQ3_XXS on an RTX 5080 alone (most of the window is CPU experts) showed no difference beyond noise. That is expected: its CPU experts mostly see one token, and IQ3_XXS at one token is unchanged. I don't have an IQ3_S model here, so the end-to-end effect on IQ3_S, where one token goes from 0.43 to 0.26 ms per expert, is not measured. A report from an IQ3_S rig would settle it.
Not tested
target("avxvnni")copies and the CMake check have never been compiled. If the check fails, the build simply leaves the VNNI copies out.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.