mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4951] [CLOSED] [Engine] CPU: add AVX-VNNI vpdpbusd path for 256-bit NVFP4 expert rows #5261
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#5261
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/4951
Author: @utombords
Created: 11/1/2026
Status: ❌ Closed
Base:
main← Head:pr/avx-vnni-nvfp4📝 Commits (2)
a22c26fcheck_isa_guard: read AVX-VNNI at all, and read file names as names9698b50nvfp4: vpdpbusd for the AVX-2 rows where the CPU has AVX-VNNI📊 Changes
10 files changed (+320 additions, -96 deletions)
View changed files
📝
CMakeLists.txt(+4 -1)📝
docs/DETAILS.md(+1 -0)📝
docs/NVFP4.md(+17 -1)📝
include/strata/kernels/cpu/nvfp4_avx2.hpp(+13 -0)📝
src/kernels/cpu/nvfp4_avx2.cpp(+74 -79)➕
src/kernels/cpu/nvfp4_avx2_rows.inl(+105 -0)📝
src/kernels/cpu/nvfp4_avx512_parity.cpp(+37 -3)📝
sycl/CMakeLists.txt(+2 -1)📝
tools/check_isa_guard.py(+37 -11)📝
tools/test_check_isa_guard.py(+30 -0)📄 Description
Problem and result
CPUs that have AVX-VNNI (
CPUID.07H.01H:EAX[4]) without AVX-512 (Intel 12th–14th Gen, Core Ultra / Arrow Lake, Sierra Forest) run the 256-bit NVFP4 CPU expert rows insrc/kernels/cpu/nvfp4_avx2.cpp. Whileq2_avx2.cppandiq_avx2.cppalready compile an AVX-VNNI copy of their row kernels (*_rows.inl),nvfp4_avx2.cppstill ran the two-instructionvpmaddubsw+vpmaddwd(ones)pair on those CPUs instead of single-instructionvpdpbusd.In addition,
tools/check_isa_guard.pyhad two bugs on the ELF path:binutils 2.42prints VEX-encoded AVX-VNNI instructions as{vex} vpdpbusd ...(so the parser read{vex}as the mnemonic and missed all 321vpdp*instructions inlibstrata_kernels_cpu.a), andWIDE_OBJECTSwas matched as a substring (native_expert.cpp.omatchedexpert.cpp.o).With these two commits:
tools/check_isa_guard.pystrips leading{vex}/{evex}markers before reading the mnemonic and matches object filenames as exact basenames (<name>.o/<name>.obj).src/kernels/cpu/nvfp4_avx2.cppincludesnvfp4_avx2_rows.inltwice—intonamespace plain(STRATA_ROWS_VNNI 0, no target attribute) andnamespace vnni(STRATA_ROWS_VNNI 1,target("avxvnni")on GCC/Clang)—and dispatches at runtime behindcpu_avxvnni_ok()andSTRATA_NO_NVFP4_VNNI.nvfp4_avx512_paritychecks bothavx2+vnniandavx2+plainseparately for bit-exact equality againstggml-cpu, and adds--bw THREADS TOKENS avx2plain|avx2vnni.334.8 msto225.8 msat 1 token (12.7->18.8 GB/s,+48.3%),611.3 msto530.8 msat 4 tokens (+15.2%), and1177.1 msto1011.0 msat 8 tokens (+16.4%), with0bit differences againstggml-cpu. End-to-end (tools/strata_bench.py, 3 runs, warm RAM, RTX 5070 Ti + 15 CPU workers), short chat decode moves from57.7 tok/s(52.0–80.3) to59.1 tok/s(50.4–85.5,+2.4%median) while full-pool multi-turn decode stays DRAM-bound (67.8vs67.2 tok/s).Related discussion
none
Approach
.inlstructure used inq2_avx2.cpp(q2_avx2_rows.inl) andiq_avx2.cpp(iq_avx2_rows.inl):nvfp4_avx2_rows.inlis included innamespace plainandnamespace vnni, both inside the anonymous namespace so no weak/COMDAT symbol can leak to callers.12(kvalues_fp4) against Q8_0 activations in[-127, 127], so avpmaddubswpair reaches at most2 * 12 * 127 = 3048inint16(<= 32767) and6096inint32, which cannot saturate and equalsvpdpbusdbit for bit.STRATA_NO_NVFP4_VNNI=1so this kernel can be switched back to thevpmaddubsw+vpmaddwdpair independently ofSTRATA_NO_AVXVNNI=1(which also switchesq2_avx2andiq_avx2).Validation
Passed:
870aedd9(v0.2.8) andc62d5e3a(v0.2.9 / engine 0.1.55):nvfp4_avx512_parity.exe:dumpbin /disasm nvfp4_avx2.cpp.obj:0vpdpbusdinstructions inplain::*,0vpmaddubswinstructions invnni::*.nvfp4_avx512_parity.exe --bw(1536 experts, P-core 0 pinned for 1-thread runs, 3 interleaved pairs on clean boot; 24 threads for full pool):python tools/strata_bench.py --runs 3(qwen3.8-flash-next-nvfp4-nvfp4-BF16, RTX 5070 Ti 16 GB +--pool-workers 15, warm RAM):STRATA_NO_NVFP4_VNNI=1(avx2+plain): chat decode57.70 tok/s(52.00-80.30,n=9), TTFT0.92 s; 4K prompt1702.50 tok/s; 16K prompt2700.90 tok/s; agent decode67.80 tok/s(n=15).avx2+vnni): chat decode59.10 tok/s(50.40-85.50,n=9,+2.4%median,+6.5%peak), TTFT0.91 s; 4K prompt1702.00 tok/s; 16K prompt2698.00 tok/s; agent decode67.20 tok/s(n=15).64f69faand870aedd9:python3 -m unittest tools.test_check_isa_guard:13tests (10existing +2in commit 1 +1in commit 2),OK.python3 tools/check_isa_guard.py build/libstrata_kernels_cpu.a:321functions,113hold wide-ISA instructions,0not allowed (exit0; before commit 1:0hold wide-ISA instructions due to{vex}prefix).objdump -d nvfp4_avx2.cpp.o:vpdpbusdappears only in the eightvnni::row_dot<1..8>instantiations (2each) and nowhere else (0inplain::*and public entry points); built with-DSTRATA_AVXVNNI=0,0vpdpbusdin the object.sde64 -future -- ./be_vnni 6:216trials,648forced comparisons (plainvsvnnivs auto),0mismatches;sde64 -- ./be_vnni 6 autoon host CPUID without AVX-VNNI exits0with noSDE-ERROR.Failed:
Not run:
sycl/CMakeLists.txtbuild with Intel oneAPIicpx(the one-lineSTRATA_AVXVNNIproperty addition insycl/CMakeLists.txtmirrorsq2_avx2.cppdirectly, but no SYCL toolchain was installed on the test machine).Limits
threads = 24,tokens = 1), the NVFP4 rows are DRAM-bandwidth bound (79.4 GB/svs79.1 GB/s), sovpdpbusdimproves per-core latency and few-worker / few-token windows rather than peak memory bandwidth.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.