Repository navigation
feat(sinq): add opt-in two-dimensional tiling - #6614
Merged
Merged
Conversation
ZX-ModelCloud
force-pushed
the
feat/sinq-2d-tiling
branch
from
December 1, 2026 07:41
1cb75e1 to
25bd7c6
Compare
ZX-ModelCloud
marked this pull request as ready for review
December 1, 2026 07:50
Fit square group_size tiles along both matrix axes for tiling_mode=2d, with partial final row and column blocks handled as their own tiles. Fold each tile's row scale into the GPTQ-shaped scales tensor and store the per-tile input-column scale as [ceil(out_features / group_size), in_features] sinq_scale; 1D checkpoints keep the existing [in_features] layout. Thread tiling_mode through SINQConfig, module construction/checkpoint restore, SinqLinear pack/forward/effective_weight, and dense checkpoint export. Add a sinq_2d benchmark config and document the A/B results; 1D remains the default.
ZX-ModelCloud
force-pushed
the
feat/sinq-2d-tiling
branch
from
December 1, 2026 07:51
25bd7c6 to
46679ba
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 opt-in
tiling_mode="2d"to SINQ. The default remains"1d", so existing checkpoints and quality are unchanged. 2D fits squaregroup_size × group_sizetiles along both matrix axes, with partial final row and column blocks fitted as their own tiles. Each tile's row scale is folded into the GPTQ-shapedscales; the input-column scale is stored assinq_scalewith shape[ceil(out_features / group_size), in_features]. 1D keeps the existing[in_features]layout.This is rebased onto current
mainand composes with the NF4/NF3 codebook work from #6608: the 2D path reuses the shared tile fit and therefore works withcodebook="uniform","nf4", and"nf3".What Changed
SINQConfig: accepttiling_mode="1d"|"2d", validate it, serialize it, and pass it to the kernel constructor.SINQ.quantize: dispatch to_quantize_1dor_quantize_2d; share tile gating and batch fitting; recordtiling_modeandrow_tilesinsinkhorn_stats.SinqLinear: carrytiling_mode, validate 1D/2Dsinq_scalelayouts, pack 2D column scales, apply per-row-block column scales ineffective_weight/forward, and declare the 2D checkpoint shape incheckpoint_tensor_rules.module_constructor_configrecordstiling_mode; dense export applies 2D row-block column scales.sinq_2dconfig plus--tiling-mode.Flow
Before (1D default):
flowchart TD A["SINQ.quantize"] --> B["one full-width tile per input group"] B --> C["Sinkhorn row/column scales"] C --> D["affine or codebook fit per row"] D --> E["scales: groups x out_features<br/>sinq_scale: in_features"]After (mode selects tile geometry and column-scale layout):
flowchart TD A["SINQ.quantize"] --> B{"tiling_mode"} B -->|"1d"| C["full-width input-group tiles"] B -->|"2d"| D["square group_size tiles<br/>plus partial edges"] C --> E["Sinkhorn row/column scales"] D --> E E --> F["affine or codebook fit"] F --> G["scales: groups x out_features"] G --> H{"tiling_mode"} H -->|"1d"| I["sinq_scale: in_features"] H -->|"2d"| J["sinq_scale: row_tiles x in_features"][out_features, group_size][group_size, group_size]plus partial edgessinq_scale[in_features][ceil(out_features / group_size), in_features]Measured Impact
WikiText-2 PPL, uniform codebook, default gate (
gate_scope="group",kurtosis_threshold=10.0), same evaluation windows. Negative change means 2D is better.2D wins on the coarser grids and at 3-bit group 128 on both tested models, but loses at 4-bit group 128 and 3-bit group 64, so 1D stays the default. Quantization took 1.2x to 3.5x the 1D time in the sweep (for example 27.9 s vs 8.8 s at 4-bit group 128); peak quantization memory was lower because 2D processes one output-row block at a time. Inference cost is unchanged: the checkpoint still stores packed GPTQ codes and one extra scale row per output block.
Post-merge recheck of the 3-bit group-128 case: 1D 32.039 PPL vs 2D 29.263 PPL, matching the sweep.
Tests
Commands and results (run from the worktree root):
The deselected node
tests/test_quantization_lifecycle_contracts.py::test_checkpoint_roles_match_processor_lifecyclesfails identically on unmodifiedorigin/main(tetradeclaresCheckpointSupport.PRIMARYwhile the test expectsUNSUPPORTED); it is unrelated to this change.Skipped/unverified: no fused SINQ GEMM is added; 2D uses the same portable Torch decode as 1D, so no new kernel path is claimed.
Model Support / Module Plan
Not applicable: no
MODEL_MAP, alias, definition, or module-plan change.AWQ onboarding safety
Not applicable: no model/alias/definition or AWQ grouping/search/replay/fold change.
Notes for reviewers
[in_features]scale.