Skip to content

feat(tt-blockfloat): checkpoint/module format for out-axis exponent blocks - #3994

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

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

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Follow-up to #3992 (out-axis solver), so this is the piece that makes those weights saveable and loadable.

Change

  • TTBlockfloatLinear / TTBlockfloatEmbedding / swap_blockfloat_modules take block_axis ("in" default, "out"). With "out" the module stores W^T [in, out]: code_shape is the stored shape, exponents is [in, out/16], and dequantize() still returns [out, in]. pack() and load_codes_from() quantize/decompose along the stored axis.
  • CUDA/HIP dispatch stays gated to "in", because both kernels index one exponent per 16 inputs of a row. An out-axis module takes the exact torch path on GPU until those kernels learn the other axis.
  • save_blockfloat_model(..., block_axis=None): dense weights are decomposed along the requested axis; the axis is inferred from already-packed modules; mixed or contradicting axes are refused. quantization_config.block_axis is written only when it is "out", so in-axis checkpoints stay byte-identical.
  • build_blockfloat_model and the shipped modeling_tt_blockfloat.py read block_axis; _validate_restored_geometry checks the stored orientation, so a swapped code_shape is still rejected.
  • scripts/tt_quantize_blockfloat.py: --block-axis {in,out}, --act-order (requires out).

Why

On Tenstorrent, the out-axis layout is the one that uploads to ttnn.linear(x, W^T) without re-quantization (#3992). Llama-3.2-1B-Instruct, CPU fp32, 40×512-token windows on text disjoint from calibration:

model nm held-out PPL GSM8K-test PPL
dense 4.523 4.390
published bf4/bf8 (in-axis) 4.635 (+2.5 %) 4.506 (+2.6 %)
out-axis, act-order, sequential GPTQ (same bits: bf8 attn/down, bf4 gate/up, bf8 tied embed) 4.594 (+1.6 %) 4.452 (+1.4 %)

Tests

  • tests/test_tt_blockfloat_out_axis.py: 19 passed. Added: module stores the transpose and matches F.linear; out_features multiple-of-16 check; out-axis checkpoint round trip gives bit-identical logits; re-save is byte-identical and keeps the axis; in-axis config has no block_axis key; a swapped code_shape is rejected; contradicting axes are refused.
  • test_tenstorrent_support.py, test_tt_blockfloat_precision.py, test_tt_blockfloat_cuda_*, test_tt_blockfloat_hip.py: 128 passed, 92 skipped (no GPU), 1 failed. The failure is the pre-existing test_calibration_hessian_strides_through_the_text, which also fails on main without this change.
  • ruff check clean.

🤖 Generated with Claude Code

…nt blocks

TTBlockfloatLinear/Embedding take block_axis ("in" default, "out"). With
"out" the module stores W^T [in, out] codes (code_shape is the stored shape,
exponents [in, out/16]); dequantize() still returns [out, in]. CUDA/HIP
dispatch stays gated to "in" until those kernels index the other axis, so an
out-axis module takes the exact torch path there.

save_blockfloat_model(block_axis=...) writes out-axis checkpoints, infers the
axis from packed modules, refuses mixed or contradicting axes, and records
quantization_config.block_axis only when it is "out" so in-axis checkpoints
are byte-identical. build_blockfloat_model and the shipped modeling file read
it; geometry validation checks the stored orientation.

scripts/tt_quantize_blockfloat.py: --block-axis {in,out} and --act-order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium merged commit dc6da73 into main Nov 14, 2026
6 checks passed
@Qubitium
Qubitium deleted the feat/tt-blockfloat-out-axis-format branch November 14, 2026 12:50
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