mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #242] [CLOSED] IQ kernels: decode each weight part once for every column and entry, bitwise identical #2525
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#2525
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/242
Author: @gputier
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:pr/iq-grid-decode-0.1.29📝 Commits (1)
b5300b4iq_kernels: decode each IQ weight part once for every column and entry📊 Changes
6 files changed (+855 additions, -36 deletions)
View changed files
📝
CMakeLists.txt(+6 -0)📝
include/strata/kernels/iq_kernels.hpp(+6 -0)📝
src/kernels/cuda/iq_kernels.cu(+450 -21)➕
src/kernels/iq_multi_parity.cpp(+347 -0)📝
src/kernels/iq_parity.cpp(+31 -14)📝
src/kernels/native_expert_parity.cpp(+15 -1)📄 Description
IQ kernels: decode each weight part once for every column and entry, bitwise identical
Rebased on v0.1.29. One commit:
iq_kernels.cuand its header, a new parity test (iq_multi_parity), and additions toiq_parityandnative_expert_parity.What it does
iq_mmvq,native_gu_kernelandnative_down_kernelcalled the format's dot once per column (or group entry), re-reading the weight words and redoing the grid lookups and sign unpacking each time. Each dot is now split into a load (weight side) and an apply (activation side, same integer chain and same float expression), the waynative_mmvq.cu's multi-column traits already work. The dense kernel takes 1, 2, 4 or 8 columns per pass (8 at a time beyond 8), the grouped ones 4 entries per pass (about 48 registers; the default verify window fits in one pass).Every column keeps the same calls, lane stride, summation order and
warp_sum, so results are bitwise equal to the old kernels.Default path is identical to the byte
Measured on an RTX 5090 (sm_120, Windows, MSVC 2022, CUDA 13.4), Release build, v0.1.29 as the base.
iq_multi_parity(new, in ctest, synthetic, no model): old against new bitwise for iq2_xxs, iq2_xs, iq3_xxs, iq4_nl, iq3_s, iq2_s, iq4_xs, iq1_m and q2_0,iq_mmvqwith 1 to 8 and 11 columns, andnative_expert_groupedwith 9 groups and 35 entries for the 24 pairings of 8 gate/up formats with IQ4_NL, Q2_0 and IQ4_XS down. 0 failures.native_expert_parityon the real IQ3_S shard (layers 0, 1, 2, 3, 20, 47): 0 failures, and for each layer "gpu decode-once vs per-entry kernels: bitwise equal".iq_paritynow also requires every column of a 1 to 8 columnnative_mmvqcall to equal a one-column call bitwise.tools/iq_fixture.pyis not in the tree, so I ran it on fixtures built locally from gguf-py (random valid blocks, 64 x 512, dequantized by gguf-py from the pinned llama.cpp): 8 IQ formats and Q3_K pass, dequant error 0, dot within 6e-3 of the float product, and the multi-column check holds. Q2_0 has no gguf-py fixture and reports "missing fixture", exactly as v0.1.29 does.ple_parity,expert_parity,pool_test.--spec 4 --expert-cache 8000 --prefill 2048 --max-new 256, three prompts (32, 2 520 and 23 020 tokens), two passes each: all 256 output tokens are identical in every run, and identical withSTRATA_OLD_IQ_MMVQ=1on the shortest and longest prompt.Gain
Kernel micro-benchmark (
iq_multi_parity --bench, RTX 5090, idle GPU), microseconds per call, old / new:iq_mmvq8192 x 2560iq_mmvq8192 x 2560iq_mmvq8192 x 2560Grouped, 16 groups of m entries (IQ3_S gate/up with Q2_0 down): m=1 39.9 / 40.1, m=4 76.0 / 54.1, m=8 129.4 / 90.2. Across the six formats benchmarked, m=8 goes from 109 to 129 us down to 82 to 90 us.
End to end, no gain shows on the IQ3_S model with the default
--spec 4window: decode is 142.8 tok/s for v0.1.29 and 142.8 / 143.3 for this branch on the 23K prompt, and 137.5 / 136.9 against 138.8 / 138.1 on the 2.5K one, within run to run noise. Most of the win is at 3 or more columns or entries per call, which the default window rarely reaches on this model.Switch back
STRATA_OLD_IQ_MMVQ=1(oriq_set_old_kernels) keeps the per-column kernels.Not tested
--specwindow where the multi-column path is hit more often.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.