Skip to content

feat(tt-blockfloat): solve GPTQ with exponent blocks along out_features (TT-native layout) - #3992

Merged
Qubitium merged 1 commit into
mainfrom
feat/tt-blockfloat-out-axis-solver
Nov 14, 2026
Merged

Qubitium merged 1 commit into
mainfrom
feat/tt-blockfloat-out-axis-solver

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Problem

ttnn.linear(x, W) takes its weight as [in_features, out_features], and bf4_b/bf8_b share one exponent per 16 consecutive values of the last dim. gptq_solve_blockfloat blocks along in_features of [out, in], so every block-float checkpoint written so far is re-quantized when it is uploaded the way ttnn.linear needs it.

Measured on a p300c with real layers of the published Llama-3.2-1B-Instruct bf4/bf8 checkpoint (ttnn.from_torch → to_torch round trip):

layer upload [out, in] upload [in, out]
q_proj bf8 drift 0 14 % of values change, relL1 0.30 %
gate_proj bf4 drift 0 11 % change, relL1 3.4 %
up_proj L7 bf4 drift 0 16 % change, relL1 5.0 %

At M=32, gate_proj bf4 output error vs fp64: 8.1 % with the re-quantized [in, out] weight, 0.42 % with matmul(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 as quantize_blockfloat), act_order never splits a block, and the tail update uses GPTQ's lazy-batch GEMM with a float64 factorisation.
  • quantize_model_blockfloat forwards block_axis/act_order; with "out" the embedding is blocked along the vocabulary, so a tied head E^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 records block_axis follows in a separate small PR.

Evidence

  • A Llama-3.2-1B-Instruct quantized with this solve (sequential GPTQ, act-order, bf8 attention/down, bf4 gate/up, bf8 embed) uploads as W^T with 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 of W^T, exact code round trip, beats RTN, act-order helps bf4, the in-axis result is not on the W^T grid, 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 on main without this change.

🤖 Generated with Claude Code

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]>
@Qubitium
Qubitium merged commit db6da64 into main Nov 14, 2026
6 checks passed
@Qubitium
Qubitium deleted the feat/tt-blockfloat-out-axis-solver branch November 14, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant