mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4944] [Engine] Table-lookup Q2_0 rows for Sandy / Ivy Bridge (STRATA_Q2_LUT=1, opt-in) #5259
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#5259
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/4944
Author: @hiyazakite
Created: 11/1/2026
Status: 🔄 Open
Base:
main← Head:cpu-q2-lut📝 Commits (2)
47fc760[CPU] Q2_0 native experts on the AVX1 rung (Sandy / Ivy Bridge)59089ab[CPU] Table-lookup Q2_0 rows for Sandy / Ivy Bridge (STRATA_Q2_LUT=1, opt-in)📊 Changes
11 files changed (+790 additions, -11 deletions)
View changed files
📝
CMakeLists.txt(+20 -0)📝
include/strata/kernels/cpu/expert_layout.hpp(+5 -4)➕
include/strata/kernels/cpu/q2_lut.hpp(+42 -0)📝
src/core/expert_source.cpp(+5 -0)📝
src/kernels/cpu/kq_cpu_bench.cpp(+34 -3)📝
src/kernels/cpu/pool.cpp(+13 -4)➕
src/kernels/cpu/q2_lut.cpp(+255 -0)➕
src/kernels/cpu/q2_lut_avx1.cpp(+210 -0)➕
src/kernels/cpu/q2_lut_kernels.hpp(+33 -0)➕
src/kernels/cpu/q2_lut_snb.cpp(+4 -0)➕
src/kernels/cpu/q2_native_parity.cpp(+169 -0)📄 Description
Problem and result
On Sandy Bridge and Ivy Bridge CPUs,
pmaddubsw,pmaddwd, vector shifts, andmulpsall issue exclusively on execution Port 0. As a result, the multiply-accumulate rows inq2_avx1.cppare Port 0 bottlenecked (~2.4 weight x activation products per cycle on an E5-2603 core, ~7.2 GB/s on dual 4-core sockets).This opt-in feature (
STRATA_Q2_LUT=1) replaces the multiply-add loop withpshufbtable lookups on Ports 1 and 5. Standalone weight bandwidth improves from 7.2 GB/s to 17.1 GB/s (2.4x) on the dual E5-2603, and CPU-side decode layer throughput increases 2.5x.Related discussion
Continuation of the AVX1 lane work in #4854 and #4858.
Approach
T + 762 = 32A + B). Four lookups accumulate directly in bytes without overflow (paddbon Ports 1/5), followed bypunpckandpmaddubsw(..., [1, 32])on Port 0.ArenaExpertSource) are mirrored; dynamic buffers bypass the rung and fall back toq2_rows_any.q2_lut_avx1.cpp, with hardware F16C) and Sandy Bridge (q2_lut_snb.cpp, software fp16 conversion), selected at runtime via CPUID.STRATA_Q2_LUT=1on AVX1 CPUs, orSTRATA_Q2_LUT=forceon any AVX CPU. Default execution path remains 100% bit-identical.Validation
Passed:
q2_native_parity: Passes withSTRATA_Q2_LUT=force. Tested against ggml-cpuvec_dotand exact dot on E5-2603: relative error 4.7e-3..6.0e-3. Ragged row ranges and single-token slices match whole calls bitwise. Registered asctest q2_native_parity_lut.kq_cpu_benchon dual Xeon E5-2603 (8 threads):bench/prompts/standard-v1on live server): 12/12 sanity checks passed (tool-call checks match reference behavior), decode 30-35 tok/s paired with a single 5060 8 GB and 128 GB quad channel per NUMA node DDR3.Failed:
Not run:
STRATA_CPU_X86and x86 AVX1 translation units).strata bench run(only standalone layer bench and live server decode measured so far).Limits
STRATA_Q2_LUT=1.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.