mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3946] [Engine] faster Q2_0 expert rows on AVX-512 full 8-block groups (bit-exact kernel) #4845
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#4845
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/3946
Author: @Ext3h
Created: 10/24/2026
Status: 🔄 Open
Base:
main← Head:opt/q2-0-rows📝 Commits (4)
16c857fcpu: faster q2_0 expert rows for full 8-block groups (bit-exact)635dc65bench: the portable q2_0 rows microbenchmark that checks v2 bit for bit and times it3b46bcebuild: a CTest entry for the q2_0 rows bit-exact sweep0e217b6bench: q2_0 rows measured against the original on a Ryzen 7 9800X3D📊 Changes
14 files changed (+929 additions, -3 deletions)
View changed files
📝
CMakeLists.txt(+12 -0)➕
bench/micro/q2g_rows_bench.cpp(+497 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/README.md(+70 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/q2g_ctest.txt(+24 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/q2g_isa_guard.txt(+4 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/q2g_rows_bench-clang-run2.txt(+27 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/q2g_rows_bench-clang.txt(+27 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/q2g_rows_bench-msvc-run2.txt(+27 -0)➕
bench/results/2026-10-24-q2_0-rows-kernel/q2g_rows_bench-msvc.txt(+27 -0)📝
include/strata/kernels/cpu/expert.hpp(+4 -0)📝
metal/src/engine/stubs.cpp(+1 -0)📝
src/kernels/cpu/expert.cpp(+204 -0)📝
src/kernels/cpu/expert_layout.cpp(+3 -2)📝
tools/check_isa_guard.py(+2 -1)📄 Description
Summary
Adds
q2_0_gguf_rows_multi_v2, an AVX-512 kernel that runs a full eight-block Q2_0 group as a written-out straight-line body instead of the masked path, and routes theq2_rows_anyrungs to it. Warm full-group rows take 0.516-0.877 of the original's time on clang and 0.360-1.010 on MSVC. "Bit-exact" means 320 seeded harness cases compare equal withmemcmp, not a proof over all inputs.Why
The original sends every group through the masked tail: an eight-trip scalar scale gather and a runtime block loop. MSVC rejects
#pragma clang loop unroll(full)with C4068, so the steps are written out; the tail was slower than the original's single loop, so rows with fewer than eight blocks keep the original.Changes
q2_0_gguf_rows_multi_v2(token-major up to four tokens, block-major from five), the dispatch rungs, the Metal host stub, and theWIDE_PUBLICguard entry.bench/micro/q2g_rows_bench.cppbuilds on POSIX and Windows, times v2 against the original, and exits 77 before either kernel on a CPU without AVX-512 (--validate-onlyruns the sweep alone).q2g_rows_bench_validate, withSKIP_RETURN_CODE 77.bench/results/2026-10-24-q2_0-rows-kernel/.Results
v2/original; each cell spans the first run and a second run of the same binaries:
nblocks >= 8)Medians and ratios come from the wall clock; the TSC only feeds
cyc/op. The full table and both runs are in bench/results/2026-10-24-q2_0-rows-kernel/README.md.Validation
Passed:
/arch:AVX512, bench TU at baseline flags).tools.test_check_isa_guardpasses 10 tests.Passed; withSTRATA_FORCE_AVX2=1the same test isSkipped(exit 77 before any kernel).expert_layoutobject leaves undefined.Failed: none.
Not run:
Limits
memcmpover 320 seeded cases, not full-model logits.CI
Intake passes;
Title areaandMetal buildareaction_requiredon the fork, and no job has compiled this branch.— Claude
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.