Repository navigation
feat(sinq): add A-SINQ with the AWQ activation-aware scale search - #6615
Merged
Merged
Conversation
ZX-ModelCloud
force-pushed
the
feat/sinq-awq
branch
from
December 1, 2026 07:45
fbd1512 to
fee49c5
Compare
ZX-ModelCloud
marked this pull request as ready for review
December 1, 2026 07:55
ZX-ModelCloud
force-pushed
the
feat/sinq-awq
branch
from
December 1, 2026 08:01
fee49c5 to
43cb455
Compare
13 tasks done
ZX-ModelCloud
force-pushed
the
feat/sinq-awq
branch
from
December 1, 2026 09:14
43cb455 to
413c0da
Compare
Plain SINQ is calibration-free and lands behind same-bit GPTQ at 4 bits. SINQConfig(awq=True) captures native linear inputs, scores the project's twenty-point AWQ scale grid plus the calibration-free result through SINQ's own affine fit, and folds the winning per-input-channel scale into the weight. The inverse is stored in the existing sinq_scale tensor, so packing, the checkpoint layout and SinqLinear are unchanged. The scale is folded before the fit rather than after the Sinkhorn walk. Sinkhorn's column estimate is proportional to the column magnitude of the tile it normalizes, so folding first and keeping the walk divides the calibration back out: on Qwen2.5-0.5B-Instruct the mean per-layer output error is 0.95x of plain SINQ with the walk and 0.80x without it. The calibrated scale therefore replaces the column axis; the row axis is absorbed by the per-group affine scale. WikiText-2 perplexity, 4-bit, group_size=128, 16 calibration windows: SmolLM2-135M 17.133 vs GPTQ 17.496; Qwen2.5-0.5B-Instruct 15.425 vs GPTQ 15.103 (plain SINQ: 17.530 / 16.100). The pre-pass costs 39.9 s / 461 MiB and 19.4 s / 1,484 MiB respectively. AWQ_SCALE_GRID and awq_scale_candidates now live in gptqmodel/quantization/awq/quantize/scale.py so the AWQ processor and A-SINQ share one candidate definition.
ZX-ModelCloud
force-pushed
the
feat/sinq-awq
branch
from
December 1, 2026 09:20
413c0da to
b73a09e
Compare
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 A-SINQ, the calibrated SINQ variant:
SINQConfig(awq=True)capturesnative linear inputs, reuses the project's AWQ activation-aware scale search,
folds the winning per-input-channel scale into the weight, and stores its
inverse in the existing
sinq_scaletensor. Packing, the checkpoint layout andSinqLinearare unchanged.Based on current
main(includes the NF4/NF3 codebook change, #6608); theA-SINQ path is orthogonal to the codebook and gate-scope additions.
Net: 13 files, +1221 / -103.
Problem
Plain SINQ is calibration-free. At 4 bits / group 128 on WikiText-2 it lands
behind same-bit GPTQ on both benchmark models (17.530 vs 17.496 on
SmolLM2-135M, 16.100 vs 15.103 on Qwen2.5-0.5B-Instruct). The AWQ search
already produces the per-input-channel scale that SINQ's Sinkhorn column axis
only approximates, so the calibration pre-pass reuses it.
What Changed
gptqmodel/quantization/sinq_awq.py(new): captures each target linear'snative input rows, scores the 20-point AWQ grid plus the calibration-free
result through SINQ's own affine fit, and returns one scale per module.
Modules without captured rows, or whose best candidate is the calibration-free
result, keep plain SINQ. Rows are staged per calibration batch and moved to
the host, so the accelerator holds one batch of activations.
gptqmodel/quantization/sinq.py:SINQ(awq_scale=...)folds the scale intothe tile before the affine fit and divides it out of the stored column scale.
The calibrated scale replaces Sinkhorn's column estimate, so the walk is
skipped for A-SINQ. The NF4/NF3 fit and the per-tile gate are unchanged for
the plain path.
gptqmodel/quantization/awq/quantize/scale.py:AWQ_SCALE_GRIDandawq_scale_candidatesare now shared;awq_processor.pyconsumes the helperinstead of its inline copy (no behavior change).
gptqmodel/quantization/config.py:SINQConfiggainsawq,awq_samples,awq_grid, with validation, dynamic-override rejection and serialization.gptqmodel/models/base.py:_calibrate_sinq_awqprepares the calibrationrows, moves the dense model to the calibration device, runs the pre-pass and
restores device/training/cache state; the scales are handed to the weight-only
processor.
gptqmodel/looper/weight_only_processor.py: passes the per-module scale toSINQ.scripts/benchmark_sinq_ppl.py:asinqconfig plus--awq-samples/--awq-grid, and records calibration samples, tokens, grid, time and peak.Follow-up intentionally out of scope: 2D tiling, fused SINQ GEMM, and
per-layer scale search for models whose calibration rows are not captured.
Flow
Before (plain SINQ):
flowchart LR A["dense W"] --> B["Sinkhorn walk<br/>row + column scales"] B --> C["affine or NF4/NF3 fit per group"] C --> D["qweight, scales, zeros"] B --> E["sinq_scale = column scale"]After (A-SINQ):
flowchart LR A["calibration rows X"] --> B["capture native linear inputs"] B --> C["AWQ grid: 20 candidates<br/>plus plain SINQ"] C --> D["fold s into W"] D --> E["affine fit per group<br/>walk skipped"] E --> F["qweight, scales, zeros"] D --> G["sinq_scale = 1 / s"]Situation -> before -> after:
CalibrationConfig.datasetwhenawq=Truesinq_scaleWhy the scale is folded before the fit
The reference A-SINQ applies the AWQ scale after the Sinkhorn walk. Measured
on Qwen2.5-0.5B-Instruct (35 sampled layers, 16 calibration windows of 512
tokens), mean per-layer output error relative to plain SINQ:
Sinkhorn's column estimate is proportional to the column magnitude of the tile
it normalizes, so folding first and keeping the walk divides the calibration
back out. Its row estimate is absorbed by the per-group affine scale: row-only
normalization measured identically to no normalization. A-SINQ therefore uses
the calibrated scale as the column axis and skips the walk.
Tests
calibration-free fallback, capture row identity, config round trip and the
tiny-model end-to-end path.
Red/green: reintroducing the post-Sinkhorn order makes
test_sinq_awq_folds_scale_before_the_affine_fitandtest_sinq_awq_skips_the_sinkhorn_column_estimatefail; the committed codepasses both.
Measured Impact
WikiText-2 perplexity, weight-only, 4-bit,
group_size=128. Every checkpoint isreloaded before scoring; GPTQ uses 128 calibration windows of 512 tokens, A-SINQ
uses 16 (8,192 tokens) and the 20-point grid.
Calibration cost (one pre-pass; wall-clock varies with host load):
The branch is rebased onto the merged 2D-tiling (#6614) and fused-decode
(#6619) changes. A re-run of the SmolLM2-135M row on that base reproduced the
numbers exactly: A-SINQ 17.133 versus GPTQ 17.496.
A-SINQ is ahead of same-bit GPTQ on SmolLM2-135M and 2.1% behind on
Qwen2.5-0.5B-Instruct; the remaining gap is GPTQ's second-order error feedback.
Raising
awq_samplesdid not help: Qwen2.5-0.5B-Instruct scored 15.72 with 64windows (32,768 tokens) against 15.42 with 16.
Reproduce:
Model Support / Module Plan
Not applicable: no
MODEL_MAPentry, alias or definition changes.Skips / unverified
but were not scored.
codebook fit, so the path runs, but no accuracy number is claimed.
SINQ; the fallback is unit-tested.
num_betasand L1 variants are not exposed.Related
merged; this branch is rebased on all three. No open PR implements A-SINQ.