Repository navigation
feat(tt-blockfloat): solve GPTQ with exponent blocks along out_features (TT-native layout) - #3992
Merged
Merged
Conversation
ttnn.linear(x, W) stores its weight as [in, out] and shares one bf4_b/bf8_b exponent per 16 values of the last dim. The existing solve blocks along in_features, so uploading a checkpoint in the orientation ttnn.linear wants re-quantizes it (measured on p300c with the published Llama-3.2-1B bf4/bf8 checkpoint: bf4 weight relL1 3.4-5.0 %, 8.1 % output error). gptq_solve_blockfloat gains block_axis="out": blocks of 16 consecutive output features of one input column. Each block sits inside one GPTQ column, so its exponent is chosen at column-quantization time with the same neighbour search as quantize_blockfloat, act_order no longer splits blocks, and the tail update uses GPTQ's lazy-batch GEMM. quantize_model_blockfloat forwards block_axis / act_order and blocks the embedding along the vocab for an E^T tied head. Default behaviour (block_axis="in") is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 14, 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.
Problem
ttnn.linear(x, W)takes its weight as[in_features, out_features], andbf4_b/bf8_bshare one exponent per 16 consecutive values of the last dim.gptq_solve_blockfloatblocks alongin_featuresof[out, in], so every block-float checkpoint written so far is re-quantized when it is uploaded the wayttnn.linearneeds it.Measured on a p300c with real layers of the published Llama-3.2-1B-Instruct bf4/bf8 checkpoint (
ttnn.from_torch→to_torchround trip):[out, in][in, out]q_projbf8gate_projbf4up_projL7 bf4At M=32,
gate_projbf4 output error vs fp64: 8.1 % with the re-quantized[in, out]weight, 0.42 % withmatmul(transpose_b=True)on[out, in], which is 30 % slower (0.065 vs 0.050 ms). Neither is acceptable for serving.Change
gptq_solve_blockfloat(..., block_axis="out", act_order=...): blocks are 16 consecutive output features of one input column. A block sits inside one GPTQ column, so its exponent is chosen when the column is quantized (after error feedback, with the same lowest-error neighbour search asquantize_blockfloat),act_ordernever splits a block, and the tail update uses GPTQ's lazy-batch GEMM with a float64 factorisation.quantize_model_blockfloatforwardsblock_axis/act_order; with"out"the embedding is blocked along the vocabulary, so a tied headE^T [hidden, vocab]is native too.is_on_blockfloat_grid(w, bits, block_axis=...),quantize_blockfloat_column.hw/tenstorrent.md: orientation section with the measurements above.Default (
block_axis="in") is unchanged. The checkpoint/module format that recordsblock_axisfollows in a separate small PR.Evidence
W^Twith zero drift on all 81 block-float tensors, fused QKV and the bf8 tied head included.tests/test_tt_blockfloat_out_axis.py: 12 passed (on the grid ofW^T, exact code round trip, beats RTN, act-order helps bf4, the in-axis result is not on theW^Tgrid, lazy batch equals unbatched, model-level layers plus embedding).tests/test_tenstorrent_support.py tests/test_tt_blockfloat_precision.py: 116 passed, 18 skipped, 1 failed. The failure,test_calibration_hessian_strides_through_the_text, also fails onmainwithout this change.🤖 Generated with Claude Code