Repository navigation
feat(tt-blockfloat): sequential block-by-block GPTQ calibration - #4009
Merged
Merged
Conversation
quantize_model_blockfloat(sequential=True) quantizes decoder blocks one at a time and collects each block's Hessians from the outputs of the blocks already quantized before it (standard GPTQ). The first block's inputs and side arguments (rotary embeddings, masks) are captured once with a pre-forward hook; hidden states are then propagated through each quantized block. The default one-pass mode (every Hessian from the dense model) is unchanged. seqlen is now a parameter of both modes. scripts/tt_quantize_blockfloat.py: --sequential, --seqlen. Llama-3.2-1B-Instruct, out-axis + act-order + sequential, 128 x 512-token windows (bf8 attn/down, bf4 gate/up, bf8 tied embed), CPU fp32 perplexity on held-out text: nm 4.594 (+1.6 % over dense 4.523), GSM8K 4.426 (+0.8 % over 4.390); the published in-axis checkpoint was +2.5 % / +2.6 %. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
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.
What
quantize_model_blockfloat(..., sequential=True, seqlen=...)runs GPTQ block by block: each decoder block's Hessians come from the outputs of the blocks already quantized before it, so later layers calibrate against the activations they will actually see. The default one-pass mode, where every Hessian comes from the dense model, is unchanged.flowchart TD A["iter_calibration_windows"] --> B["pre-forward hook on block 0<br/>capture hidden + rotary/mask kwargs, stop"] B --> C["for each block"] C --> D["forward hooks: X^T X per nn.Linear<br/>shared input -> one matmul"] D --> E["gptq_solve_blockfloat per linear<br/>block_axis, act_order"] E --> F["propagate hidden through the QUANTIZED block"] F --> C C --> G["embedding RTN onto the grid"]scripts/tt_quantize_blockfloat.py:--sequential,--seqlen.Result
Llama-3.2-1B-Instruct,
--block-axis out --act-order --sequential --nsamples 128 --seqlen 512on 4000 neuralmagic calibration rows (bf8 attention/down, bf4 gate/up, bf8 tied embed). CPU fp32 perplexity, 40×512-token windows of held-out text:All 113 modules are on the grid, and the checkpoint reloads bit-exactly (logits maxdiff 0.0).
Tests
tests/test_tt_blockfloat_out_axis.py: 22 passed. New tests: the first block's quantized weights are identical in sequential and one-pass mode (same inputs reach it), later blocks differ, and sequential does not lose to one-pass on calibration loss. Both block axes are covered.test_tenstorrent_support.py+test_tt_blockfloat_precision.py: 138 passed, 18 skipped. The one failure is the pre-existingtest_calibration_hessian_strides_through_the_text, which also fails onmain.ruff checkclean.🤖 Generated with Claude Code