mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2713] [Engine] use the AVX-512 i-quant kernels on CPUs with AVX512F/BW/VL/DQ + VNNI but no VBMI (Skylake-X, Cascade Lake) #1083
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#1083
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?
Originally created by @zhai-hello on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2713
Re-test on 0.2.1: it still happens. This is my issue #2713, which was closed as
not plannedin the 0.2.0-betatracker reset; the comment there asks for a re-test on the current release and a
/reopen. This is that re-test, onStrata 0.2.1 / engine 0.1.46, with the CPUID bits measured on this machine today.
Problem. The run-time gate for the AVX-512 expert kernels also asks for AVX512VBMI. This CPU, an i9-10940X
(Cascade Lake-X), has AVX512F, BW, VL, DQ, CD and VNNI, but no VBMI, so the engine puts the expert kernels on AVX-2.
As far as I can read them, the i-quant AVX-512 kernels use no VBMI instruction, so the gate is the only thing keeping
this CPU off them. It matters on this box: the CPU pool (13 workers) computes the cache-miss experts that are not sent
over the PCIe share (
--pcie-frac 0.20), so which kernel runs decides most of a miss.Actual — my engine log, this run (2026-10-21 08:22:28), line 10:
What I measured — the CPUID bits on this machine. I compiled a small
__cpuidexprobe withcl.exe(Visual Studio 2022) on this PC and ran it today:
So OSXSAVE and "the OS saves the AVX-512 state" both pass, and VBMI is the only bit that makes
cpu_avx512_ok()answer no. AVX-VNNI is 0 too, and
cpu_gather_fast()needs it (include/strata/kernels/cpu/expert_layout.hpp:65-69:the older Intel cores gather slowly, Skylake to Tiger Lake under the Downfall/GDS microcode), so this CPU is also
outside the fast AVX-2 gather path: by iq_avx2.cpp:491-494 the AVX-2 i-quant rows take the scalar decode unless
STRATA_IQ256_GATHER=1. The fallback here is the slowest AVX-2 form, not the Alder Lake one.What I want (the goal, not an implementation): a CPU with F/BW/VL/DQ + VNNI and no VBMI should run the AVX-512
i-quant and NVFP4 rows instead of the AVX-2 ones — by default where that is provably safe, and in any case with a way
to opt in, because today there is no way in:
STRATA_FORCE_AVX2=1only answers no,STRATA_NO_IQ512=1andSTRATA_NO_NVFP4_512=1only switch paths off, andSTRATA_FORCE_ISA=avx2|avx|sseonly caps what is found.What I do today instead: the AVX-2 kernels, and nothing else — no knob changes it.
STRATA_IQ3S_MT1=1(docs/DETAILS.md:105-107) is written for an Intel CPU of Alder Lake or later without AVX-512, where the AVX-2 kernel
gathers the IQ3_S grid, so it does not apply to this CPU (AVX-VNNI 0). I have not A/B'd
STRATA_IQ256_GATHER=1, so Iclaim nothing about it.
What I read in the 0.2.1 source — reading only, unconfirmed static analysis:
src/kernels/cpu/expert_layout.cpp:42-75: line 72 still ANDs the same five bits as the 0.1.44.1 report,((ebx >> 16) & 1u) && ((ebx >> 30) & 1u) && ((ebx >> 31) & 1u) && ((ecx >> 11) & 1u) && ((ecx >> 1) & 1u)= F, BW, VL, VNNI, and
(ecx >> 1)= VBMI.src/program/generate.cpp:3528-3535(SYCL mirrorsycl/src/program/generate.cpp:2677).cpu_avx512bw_ok()(
src/kernels/cpu/expert_layout.cpp:77-109; line 106 asks F + DQ + BW + VL), declared atinclude/strata/kernels/cpu/expert_layout.hpp:47-48with the comment "AVX-512F + AVX-512BW + AVX-512VL + AVX-512DQ(e.g. Skylake-X i9-9920X) for iq_avx512.cpp". Searching the whole 0.2.1 tree finds only those two places, so no call
site. It leaves VNNI out, so what this CPU has — F/BW/VL/DQ + VNNI, no VBMI — is a fourth set, not that one.
src/andinclude/forvpermb,permi2b,permt2b,permutexvar_epi8returns one line,src/kernels/cpu/iq_avx512.cpp:47_mm512_permutexvar_epi16, which isvpermw(AVX512BW), not VBMI.iq_avx512.cpp,nvfp4_avx512.cppandtq_avx512.cppwith/arch:AVX512(CMakeLists.txt:1563-1570), which is F/CD/BW/DQ/VL and never emits VBMI, while GCC/Clang add-mavx512vbmito the same files (CMakeLists.txt:1579-1580) and totq_avx512.cpp(CMakeLists.txt:1586-1587), wherethe comment at :1584 says the trellis kernels want "AVX-512 F/BW/VL/VBMI/VNNI (exactly what cpu_avx512_ok() checks)".
I found no VBMI intrinsic in
tq_avx512.cpp, so I cannot say whether that flag is needed or left over, and I wouldnot relax the gate for the trellis path on my reading alone.
setup.py:1191-1212,_cpuid_avx512_full()wantsavx512f,avx512bw,avx512vl,avx512_vnniandavx512vbmi, so the AVX-512 Q2_0 pack is closed to this CPU at install time as well.tools/check_isa_guard.py:31already lists the AVX-512 kernels that sit behindcpu_avx512_ok(), which seems likethe place where a per-kernel feature list would live.
I can build and measure it here. This is the PC the log came from: Windows 10 21H2, Visual Studio 2022
(
vcvars64+ Ninja) and CUDA 13.2, sm_86, the 0.2.1 source inC:\Strata-0.2.1, andengine/BUILD.jsonshows therunning engine was built here (
"source": "local","src": "c70a6f6332be8ba5","archs": [86]). If you tell me theshape you want — the smallest seems to be letting
iq_avx512.cpp/nvfp4_avx512.cppuse a gate that does not ask forVBMI, or a
STRATA_FORCE_AVX512=1opt-in for that test — I will build it and post the numbers the waydocs/COMMUNITY_BENCHMARKS.md asks, against a same-day run of this stock 0.2.1 engine, and say what I did not test.
The default path on Ice Lake, Sapphire Rapids and Zen 4 and later would stay exactly as it is.
Limits. No speed claim in this report: the only things I measured are the CPUID bits above and the engine's own
fallback line. The VBMI-free reading of the kernels is my reading of the 0.2.1 source; it says nothing about the
trellis (
tq_avx512) path, about ggml, or about what a compiler might emit there. No AVX-512 build has run on thisCPU yet, so there is no AVX-512 number here.
Environment. Strata 0.2.1, engine 0.1.46 ("session is up (engine 0.1.46)"), built locally from the 0.2.1 source
with CUDA 13.2 for sm_86 · Intel Core i9-10940X (Cascade Lake-X, family 6 model 85 stepping 7), 14 cores / 28 threads
· 64 GB DDR4 (the engine's memory guard read "limit 63.7 GiB") · NVIDIA GeForce RTX 3090 24 GB, compute capability 8.6
· Windows 10 21H2 (10.0.19044) · model SC117 Qwen3.8-Flash-Next GSQ-RCO abliterated IQ3_S, pack
sc117-iq3_s,--pcie-frac 0.20 --spec 4 --spec-min-p 0.70 --max-context 131072 --kv int8 --kv-resident 32768 --vram-reserve-mib 700 --adapt-every 1 --adapt-swaps 160 --adapt-decay 0.97, 13 pool workers over 14 physical cores.Reproduction status: reproduced locally on this machine on 0.2.1 (engine 0.1.46) — the log line and the CPUID
output are mine. The source reading above is unconfirmed static analysis.
Full startup log attached:
strata-sc117-iq3_s.log(the engine start of this run; local paths only, no keys).``
My CPU is an Intel i9-10940X (Cascade Lake-X, 14 cores). It has AVX512F, AVX512BW, AVX512VL, AVX512DQ, AVX512CD and AVX512-VNNI. It does not have AVX512-VBMI — VBMI came in on Cannon Lake, and Cascade Lake is Skylake-X plus VNNI.
cpu_avx512_ok()asks for all five bits, so the engine printsand the i-quant gate/up rows run on the AVX-2 kernel. What I want is for the gate to accept CPUs that have F/BW/VL/DQ + VNNI but not VBMI, at least on builds where nothing in those translation units can emit a VBMI instruction.
What it changes: on the Windows/MSVC build, CPUs of this class (Skylake-X/Brookdale, Cascade Lake-X, Cascade Lake-SP with VNNI) would run the AVX-512 i-quant kernels instead of the AVX-2 ones.
What it leaves alone: the default path on Ice Lake / Zen 4 and newer stays byte-identical, and the GCC/Clang build keeps asking for VBMI (reason below).
Why I think it is safe on the MSVC build
/arch:AVX512is set on the sources (CMakeLists.txt:1326 foriq_avx512.cppandnvfp4_avx512.cpp, :1219 forexpert.cpp), and MSVC's/arch:AVX512covers F/CD/BW/DQ/VL — the compiler will not emit a VBMI instruction from it.src/for the VBMI intrinsics (vpermb / vpermi2b / vpermt2b / vpmovb2m …): the only byte-or-word permute in them is_mm512_permutexvar_epi16at iq_avx512.cpp:47, which is AVX512BW. The VNNI intrinsic_mm512_dpbusd_epi32is used (expert.cpp:183, nvfp4_avx512.cpp:120) — that is why the gate needs VNNI, and this CPU has it.cpu_avx512bw_ok(), documented at include/strata/kernels/cpu/expert_layout.hpp:47 as "AVX-512F + AVX-512BW + AVX-512VL + AVX-512DQ (e.g. Skylake-X i9-9920X)".Why the gate asks for VBMI anyway
On GCC/Clang those same sources are compiled with
-mavx512vbmiexplicitly (CMakeLists.txt:1224, :1339), so on that build a CPU without VBMI can reach a VBMI instruction and take an illegal instruction — which is what the comment at expert_layout.cpp:300 is guarding against. So the fix probably has to be build-aware (relax the bit only where the build cannot emit VBMI), ortools/check_isa_guard.pyshould show the AVX-512 objects are VBMI-free.How I checked, and what I have not measured
--pcie-frac 0.00), so a faster CPU kernel should matter more on this box than on a box that streams from PCIe, but I am not claiming a number.Machine, and I can test it
i9-10940X (Cascade Lake-X, 14C/28T, an ES part, stepping B1), RTX 3090 24 GB, 64 GB DDR4, Windows 10 21H2, engine 0.1.44.1, model Swift 1.5 IQ3_XXS (native pack,
--pcie-frac 0.00,--spec-min-p 0.70).If you put out a test binary with the relaxed gate, I will run the same-day comparison the way docs/COMMUNITY_BENCHMARKS.md asks and post the numbers.
Similar reports in other projects, for what they are worth: ollama #14435 (Enable AVX512_VNNI for Cascade Lake CPUs), ik_llama.cpp #2409 (Optimizing the AVX-512 codepath on Intel Cascade Lake).
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.
@zhai-hello commented on GitHub (Oct 21, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 21, 2026):
Reopened, thank you. A maintainer will pick it up from here.
@DylanFromMassey commented on GitHub (Oct 25, 2026):
I'm not a maintainer, but I have a machine with essentially this CPU and I tried exactly what you're asking for, so I can offer a result rather than an opinion.
My processor is the previous generation of the same family (Intel Xeon W-2133 — same core design as your Cascade Lake-X, just without VNNI, which this part of the engine doesn't use anyway). I modified the source so that these AVX-512 expert kernels are used despite the missing instruction, and checked the results carefully: the output matches what the existing code produces, and the project's own correctness checks pass. So your reading of the source looks right to me — turning those kernels on for this CPU class appears to be safe, and the extra instruction set the check demands doesn't seem to be used by them at all.
The part I'd temper is the expectation of a speed-up. On my machine it was consistently slower — roughly 2 to 8% slower text generation across the tests I ran, with prompt processing unchanged. I ran the comparison twice, on two different hardware configurations, and got the same answer both times. The cause appears to be the processor rather than the code: on this generation of Intel chip, running any AVX-512 code drops the clock by about 10% (3.8 GHz down to 3.4 GHz) and holds it there, even for very light work. The AVX-512 version of these kernels also does more work per result, so it ends up no faster per clock before that penalty is applied. Your CPU is the same core generation, so I'd expect broadly similar behaviour — though my setup is different from yours (Linux and an AMD card, with much less of the work falling to the CPU; you're on Windows with an RTX 3090 and a deliberately CPU-heavy split).
Given that, I'd suggest measuring it rather than asking for it as a default change. If you build the opt-in version and post an honest before-and-after, that settles the question one way or the other, and a difference of even a few percent is enough to decide it. If it comes out neutral or slower, as mine did, then I'd argue the issue has shrunk to a wording problem: the message "this CPU has no AVX-512" isn't accurate for your part and could say what it actually means, without changing which kernels run. If it's genuinely faster on your box, that's a new data point and the opt-in is worth having.
Happy to go into more detail on how I tested it if that's useful.
@williswu commented on GitHub (Nov 2, 2026):
Data point from the same CPU class, on the other side of the question: I measured whether relaxing the gate could pay off here at all, and it cannot — the CPU pool is not what a decode window waits on.
Machine. Xeon W-2245 (Cascade Lake-SP refresh, 8C/16T), Linux, engine 0.1.40.1, two cards (RTX 4060 Ti 16 GB + RTX 3060 12 GB), Qwen3.8-Flash-Next GSQ-RCO IQ3_S,
--layer-split 28 --spec 4 --spec-min-p 0.5 --expert-cache 4500 --kv int8 --kv-resident 10240 --pool-workers 11.CPUID 7:0 — AVX512F/BW/VL/DQ/CD = 1, AVX512VNNI = 1, AVX512VBMI = 0, and AVX-VNNI (7:1 EAX[4]) = 0. Same set as your i9-10940X: this is the part that has VNNI and no way to reach either VNNI kernel.
1. Where a decode window's time goes.
STRATA_DECODE_TIMING=1, one request, 50 windows:So the CPU experts are ~0.4 ms per layer-window, ~2.4 ms of host work per 32 ms window (7%), and 23 ms is waiting on the GPUs. On a two-card split with a 98–99% expert-cache hit rate, a 2x faster expert kernel has nowhere to show up. That is the opposite of your box, where
--pcie-frac 0.20puts a real share of the misses through the CPU pool — a build is still the way to tell on yours.2. Is the CPU pool on the critical path at all? Interleaved A/B/A/B, six
openssl speedthreads stealing 6 of 16 vCPUs, two benchmark runs per phase (decode tok/s):Taking 37% of the CPU away did not slow decoding. That agrees with @DylanFromMassey's result above (2–8% slower with the gate relaxed): on this core generation the AVX-512 licence drop costs more than the kernel gains.
3. The binary does contain VNNI code, just not in a shape this part can run.
vnni::dot_rows_nt/gu_rows_nt(src/kernels/cpu/iq_avx2.cpp) are 2284{vex} vpdpwssd, 256-bit, zero zmm — AVX-VNNI (Alder Lake and newer), which this CPU does not have.s2_expert_vnni(src/kernels/cpu/expert.cpp) is 26vpdpbusd(EVEX) plus 27vpmultishiftqb, so the VBMI bit inCpuFeatures::usable()is load-bearing, not conservative.perf reporton the serving process confirms what runs:plain::17 samples,vnni::0.Conclusion, for what it is worth. I would not ask for the gate change on this CPU class — the ceiling is about 7% of a window that is 71% GPU wait, and the frequency penalty sits on the other side of the ledger. The part of the request that still looks worth doing is the log line: "this CPU has no AVX-512" reads wrong for a part that has F/BW/VL/DQ/VNNI and is missing only VBMI.
CpuFeatures::reason()already names the missing bits individually, so this may only be about which call site is used.Happy to re-run any of this against 0.2.9 if that would settle it on the current engine.
__dp4afalls back to a 4-iteration loop although gfx906 has v_dot4_i32_i8 #3012