mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1934] [CLOSED] mtp_pack: Q2_0 scale search over 0.15 to 1.0 x max|w|, either sign #3764
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#3764
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/1934
Author: @gputier
Created: 10/11/2026
Status: ❌ Closed
Base:
main← Head:pr/mtp-scale-0.1.42📝 Commits (5)
3da72d7mtp_pack: Q2_0 scale search over 0.15 to 1.0 x max|w| with either sign of dde515f6tools: test_mtp_pack compares the Q2_0 scale search with the previous one and the engine's dequant7705715tests: expert_multi_test gives the Q2_0 scales either sign and checks the kernel against the scalar oracle6bc257dmtp_pack: Q2_0 search keeps the previous candidates and rounds each scale to fp16 before measuring it2676f75tools: test_mtp_pack asserts the Q2_0 search block by block and decodes with gguf_writer📊 Changes
3 files changed (+187 additions, -15 deletions)
View changed files
📝
src/kernels/cpu/expert_multi_test.cpp(+16 -3)📝
tools/mtp_pack.py(+28 -12)➕
tools/test_mtp_pack.py(+143 -0)📄 Description
tools/mtp_pack.pypicks each Q2_0 block's scale among 17 positive values between 0.5 and 1.0 times the block's max |w|. The levels are -1, 0, 1 and 2, so they are not symmetric, and a negative scale is often closer: it puts the level 2 on the side where the block's largest weights are. This PR searches 0.15 to 1.0 times max |w| for both signs. It keeps the previous 17 candidates in the set and rounds each scale to fp16 before measuring it, so no block ends up with a larger error than before. The file format does not change, and neither does the engine: the kernels already read a signed scale.Relative RMS error of the packed draft experts, on synthetic blocks (
tools/test_mtp_pack.py): 0.855 of the previous search on normal weights, 0.824 on Laplace, 0.833 on Student t3. The test also checks every block, and that the packed bytes decode, throughtools/gguf_writer.dequantize_q2_0, to the values the search measured. A scale too large for fp16 now raises an error. One that rounds to 0 keeps the previous behaviour.expert_multi_testnow gives half of its Q2_0 scales a negative sign and compares the kernel with the scalar oracle.s2_expert_grouped_parityalready drew signed scales. On an RTX 5090 with a Ryzen 9 9950X3D (AVX-512), both pass, and the whole ctest gives the same 106 of 107 as v0.1.42.On that machine (IQ3_S, a French draft vocabulary of 46,587 tokens, served with
--spec 4 --spec-min-p 0.5), I rebuilt the draft head from the same inputs with this packer. Onlyexperts.binchanges. Against the current head, 8 interleaved pairs on fresh servers: draft acceptance 0.732 against 0.716, and output speed on a 22,785-token prompt +9.4% (8 of 8 pairs). Short prompts and a 99K-token cold read stayed within noise. That head was built before the commit that adds the previous candidates back to the search, which can only lower each block's error.Python suite:
tools/test_mtp_pack.pyadds 5 tests. Everything else gives the same results as on v0.1.42, including 8setup.pytests that fail in a plain container on both.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.