Repository navigation
feat(sinq): add NF4/NF3 non-uniform codebooks - #6608
Merged
Merged
Conversation
Add SINQConfig.codebook ("uniform" default, "nf4" at 4-bit, "nf3" at 3-bit) and fit the published NormalFloat codebooks on the Sinkhorn-normalized tiles. Non-uniform checkpoints store the continuous row shift in a new FP32 sinq_zero tensor; the kernel gathers codebook levels and the dense export path reconstructs the same weights.
ZX-ModelCloud
marked this pull request as ready for review
December 1, 2026 06:26
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in non-uniform NF4/NF3 codebooks to SINQ while keeping the existing
uniform affine grid as the default. At 3 bits, NF3 improves WikiText-2
perplexity by 11.0% relative to uniform SINQ in the same run, using the same
checkpoint/reload and evaluation path.
What Changed
SINQConfig.codebook(uniformdefault,nf4at 4 bits,nf3at 3 bits),carried through config serialization,
meta.weight_only, dynamic-overriderejection, and module construction.
tiles: per-row mean shift, max-abs step, nearest-level selection, then
(level - zero) * step * row_scale.SinqLinearpacks codebook indices directly, stores the continuous row shiftin a new FP32
sinq_zerobuffer, decodes with a gather, and stays on theeager path because the compiled affine decoder cannot represent a codebook.
post_initvalidation, and dense fileexport support
sinq_zero.oracle, exact code recovery after packing (including non-32-aligned NF4),
HF pack parity, save/reload, dense export, config round trips, and
accelerator forward parity.
quantization guide, citations, and kernel compile matrix.
Existing uniform checkpoints keep their layout;
sinq_zerois required onlyfor NF4/NF3.
Tests
Executed and passed:
The single skip is the existing
TestGPTQProcessorStreaming::test_gptq_processor_async_d2h_streaming_roundtripcase whose subprocess helper is unavailable in this environment; it is
unrelated to SINQ.
Measured Impact
WikiText-2, Qwen2.5-0.5B-Instruct, 3-bit, group size 128, default gate
(
gate_scope="group",kurtosis_threshold=10.0), 16 × 2,048-token evaluationwindows. Both rows come from the same run, with the checkpoint saved and
reloaded before scoring:
Reference rows from the same evaluation setup: asymmetric RTN 60.677 and
calibrated GPTQ 23.292. Uniform remains the default; NF4/NF3 are opt-in.
Model Support / Module Plan
Not applicable: no new model, alias, or definition.
AWQ onboarding safety
Not applicable: no model or AWQ grouping, search, replay, or folding change.
Logic Flow Documentation
The quantizer gains a codebook branch and the checkpoint gains an optional
sinq_zerotensor.docs/sinq.mdcontains the updated before/after Mermaidflow and the checkpoint layout table; the page is linked from
README.md.Review Requirements
Kernel Accuracy Requirements
nearest-level oracle after packing; decoded outputs are compared against
the quantizer's reconstructed weight and the dense export path.
Notes
sinq_zero; uniformcheckpoints keep the existing layout.
decoder.