mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #616] RTX A3000 / 0.1.38: AVX2 i-quant gate/up codebook gather — bit-exact ~1.3x isolated, +1.0% e2e, kept as opt-in #289
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#289
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 @yannickloth on GitHub (Oct 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/616
Context
Follow-up to #494 (the CPU-pool decode profile on this host). P4 sized i-quant gate/up at 28.2 ms/round = 68% of the CPU expert pool = 36% of a fresh round on 0.1.35, and the kernel documents itself as codebook-lookup bound (
src/kernels/cpu/native_expert.cpp:81-82). This tests that on the AVX2 path (this host has no AVX-512) and lands the cheap fix: replace the scalar_mm256_set_epi32grid assembly with an AVX2_mm256_i32gather_epi32.Result: bit-exact, ~1.3x isolated, +1.0% serve end to end, kept as opt-in
STRATA_IQ256_GATHER. The codebook lookup is real single-core; the 15-worker pool is not decode-bound enough for it to move the whole token, so the large lever remains fewer bytes/pack format, but the gather is a free compounding win where it lands.Host: RTX A3000 12 GB (sm_86) + i7-12850HX (8 P + 8 E, AVX2 + AVX-VNNI, no AVX-512), 128 GB. Engine 0.1.38 (local source build), Swift 1.5 IQ3_XXS native pack,
--adapt-every 1 --pool-workers 15, fixed prompt (--stats:hit_rate 0.5509, 1.78 tok/round). Serve unit stopped for the measurements.The split (0.1.38, this config)
Phase 0 — the lookup is the single-core bound
Harness:
native_expert_parity --synthetic <GU/DOWN>, one thread, weights L2-resident, pinned withtaskset -c 2. Real geometry H=2560, FF=640.Gate+up, one token, one thread (AVX2
iq256_gu_rowsvs ggml-cpu per-tokenvec_dot):At one token AVX2 ≈ ggml (the documented "no faster at one"); the win is decode-once amortization (
nt=3 is ~2.2x/token for IQ3_XXS). A scratch build substituting a constant for the grid vector (correctness ignored, reverted) nearly doubles the two 32-bit-grid formats:So the grid lookup is ~half the single-core kernel for the 32-bit-grid formats (18/21 — 6+13 of 48 layers, ~58% of the gate/up lookup work). A 64-bit-index AVX2 gather for 16/17/22 measured a wash/loss and was dropped.
H1 — AVX2 gather (bit-exact, ~1.3x isolated, +1.0% e2e)
STRATA_IQ256_GATHERselects_mm256_i32gather_epi32(iq3xxs_grid, cvtepu8_epi32(q), 4)(same foriq3s_grid, 9th bit built withsrlv/add). Opt-in, default off — the same shape as the AVX-512 kernels'STRATA_IQ_GATHER(gather throughput is core-dependent).cmpclean);native_expert_paritystays green (samerel ≈ 3.1e-08vs ggml'svec_dot); width invariance 0 rows; AVX-512 untouched.End to end (
bench/e2e.sh, same binary, switch on/off, interleaved, 5 pairs,decode_tok_sfrom/metrics):+1.0% mean, on ≥ off in 5/5. Deterministic
--statsis flat (gate/up off median 9.756 / on 9.773 ms/round), i.e. the pool does not move, but the gather is never worse in the engine.Why it does not move the whole token: at 15 workers the i-quant gate/up is not decode-bound enough.
STRATA_NO_IQ256=1(ggml per-tokenvec_dot) raises gate/up to 12.8-13.3 ms/round, so the AVX2 multi-token kernel is ~1.35x at pool scale — the pool responds to the kernel — but substituting the whole lookup assembly (a superset of any micro-tweak) moves almost nothing: the SMT/E-core concurrency eats most of the single-core decode win.Decision
STRATA_IQ256_GATHER(default off), branchperf/iq-gateup. No numbers change; the engine is unchanged unless the variable is set.tools/calibrate.py's launch-settingMIN_GAIN, not a kernel-change bar.Refs #494 (P4 pool profile), #610 (P6 GPU floor), #485 (PCIe probe).
@Niko1221 commented on GitHub (Oct 3, 2026):
Thank you for the careful measurement, including the pinned harness and the interleaved 5-pair A/B. A +1.0% end-to-end gain isn't enough to justify another opt-in variable to maintain, so the kernel stays as it is. Your conclusion that the next lever is fewer bytes per lookup or the GPU matches ours, and the numbers stay here for reference. Closing.