tt-quant: CUDA-free GPTQ/LDLQ bfp4 pipeline on the TT cards (#67) #81

Merged
Grok merged 29 commits from tt-quant into master 2026-09-25 23:09:38 +02:00
Owner

TT-native quantization: the CUDA-free GPTQ/LDLQ bfp4 pipeline that runs the propagation and
the Hessians on the P150a cards instead of a CUDA box (#67).

  • tools/tt-quant/ + nix/tt-quant.nix + nix run .#tt-quant: operator CLI and the stage
    drivers (precision probe, GPTQ, TT Hessians, TT teacher), stages running in the vllm-tt
    image on the card host.
  • Stage 1: Blackhole matmul precision measured on the real L0 Hessian, with a synthetic FPU
    probe separating multiplier width from accumulation; exact-bf16 3-way split (6×bf16)
    propagation and generic split schemes.
  • Stages 2–3: host propagation chosen; TT Hessians land within CUDA sampling noise.
  • Stage 4: the TT teacher runs end to end; the machinery proof at p ≤ 4096 has host head
    argmax == device argmax 12/12, and a prod-precision control quantifies the bias.
  • Takes ttx per-card slots rather than the legacy /tmp/ttlock.
  • .claude/skills/tt-quant/SKILL.md, including the traps paid for (FPU operand precision,
    OOM, log pipes, lock races). docs/QUANT.md and docs/STATUS.md updated.

This branch also carries the older bfp-quant history; that part landed separately as #80, so
the net addition here versus master is 30 files.

Conflicts, all resolved by keeping the superset. flake.nix: the merge duplicated the
bfp-quant binding — deduplicated, with tt-quant kept in both packages and apps.
bench/bfpq/tt-arm.sh and .claude/skills/bfp-quant/SKILL.md were add/add; master's copies
(from #80) are strict supersets — verified by diffing the result against origin/tt-quant,
which shows zero deletions — so master's were taken whole, keeping ARM_PACKED,
ARM_REQUIRE_BANNERS, TTX_SLOT_HELD and the bfp4-packed-v1 publish section.

Verified after the merge: docs/ still 11 files, no root CLAUDE.md, AGENTS.md is the
lean rewrite, QWEN36_PREFILLED_SLOTS_FIX still in qwen36_vllm.py, no PR #68 deletion
resurrected. Locally green: nixfmt --check, check-cited-records.py, shellcheck,
nix flake check, and nix build .#bfp-quant .#tt-quant.

Refs #67.

🤖 Generated with Claude Code

TT-native quantization: the CUDA-free GPTQ/LDLQ bfp4 pipeline that runs the propagation and the Hessians on the P150a cards instead of a CUDA box (#67). - `tools/tt-quant/` + `nix/tt-quant.nix` + `nix run .#tt-quant`: operator CLI and the stage drivers (precision probe, GPTQ, TT Hessians, TT teacher), stages running in the vllm-tt image on the card host. - Stage 1: Blackhole matmul precision measured on the real L0 Hessian, with a synthetic FPU probe separating multiplier width from accumulation; exact-bf16 3-way split (6×bf16) propagation and generic split schemes. - Stages 2–3: host propagation chosen; **TT Hessians land within CUDA sampling noise**. - Stage 4: the TT teacher runs end to end; the machinery proof at p ≤ 4096 has host head argmax == device argmax 12/12, and a prod-precision control quantifies the bias. - Takes ttx per-card slots rather than the legacy `/tmp/ttlock`. - `.claude/skills/tt-quant/SKILL.md`, including the traps paid for (FPU operand precision, OOM, log pipes, lock races). `docs/QUANT.md` and `docs/STATUS.md` updated. This branch also carries the older bfp-quant history; that part landed separately as #80, so the net addition here versus master is 30 files. **Conflicts, all resolved by keeping the superset.** `flake.nix`: the merge duplicated the `bfp-quant` binding — deduplicated, with `tt-quant` kept in both `packages` and `apps`. `bench/bfpq/tt-arm.sh` and `.claude/skills/bfp-quant/SKILL.md` were add/add; master's copies (from #80) are strict supersets — verified by diffing the result against `origin/tt-quant`, which shows zero deletions — so master's were taken whole, keeping `ARM_PACKED`, `ARM_REQUIRE_BANNERS`, `TTX_SLOT_HELD` and the `bfp4-packed-v1` publish section. Verified after the merge: `docs/` still 11 files, no root `CLAUDE.md`, `AGENTS.md` is the lean rewrite, `QWEN36_PREFILLED_SLOTS_FIX` still in `qwen36_vllm.py`, no PR #68 deletion resurrected. Locally green: `nixfmt --check`, `check-cited-records.py`, `shellcheck`, `nix flake check`, and `nix build .#bfp-quant .#tt-quant`. Refs #67. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Grok added 29 commits 2026-09-25 23:08:24 +02:00
#62 needs weights that sit exactly on the native bfp4_b grid so the host
packer becomes the identity. That is only safe if we reproduce the packer
bit-for-bit, including the parts that differ from a textbook block format:
the shared exponent is the max raw exponent chosen BEFORE rounding, a block
max that rounds past the binade SATURATES (1.9 -> 1.75) instead of bumping
the exponent, bits shifted below the mantissa are dropped with no sticky bit,
subnormal inputs are zero, and -0 loses its sign.

The reference is the verbatim upstream blockfloat_common.cpp / bfloat4.cpp /
bfloat8.cpp at the flake-pinned rev, compiled standalone against a shim that
replaces only logging/tracy/MetalContext/Tile. ttnn.from_torch(device=None)
was avoided on purpose: its host path constructs MetalContext -> tt::Cluster,
which opens /dev/tenstorrent on a card host (and `nix build .#ttnn` currently
fails eval on a narHash mismatch of the local tt-metal input anyway).

MEASURED (bench/runs/bfp-packer-emulation-20260924T093051Z.jsonl): 68 cases
x {bfp8_b, bfp4_b}, packed words and unpacked values bitwise identical to
the real code, incl. binade-edge, ties, exp_diff>31, subnormal inputs, bottom
of the exponent range, and real weights from Qwen3.5-9B-FP8 and a
Qwen3.8-27B-FP8 GDN layer (374M values). snap() is a fixed point of the real
packer on every case. Negative controls (exponent-bump, truncation,
half-away rounding) are all detected; an independent float reimplementation
agrees exactly.

The key layout fact for the quantizer: ttnn stores linears as W^T [in, out],
so one shared exponent covers 16 consecutive OUTPUT channels at one input
index -- every bfp block lives inside a single GPTQ column.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Because a bfp block is 16 output channels at one input index, GPTQ's
column-at-a-time error feedback composes with the block structure without
any coupling: a column's shared exponents are fixed when that column is
rounded, using the packer's own arithmetic, and the rounded block keeps its
max exponent, so the packer later re-derives the same exponent. Optional
per-block exponent search {e, e+1} stays exact because values on a coarser
grid are also on the grid the packer will pick. Neither claim is trusted:
every output goes through check_on_grid (fail closed).

MEASURED, synthetic only (bench/runs/bfp-quant-synthetic-20260924T094254Z.jsonl):
GPTQ beats RTN on the H-weighted proxy for every synthetic layer. The 16-23x
gain comes from a steep synthetic spectrum with outlier channels and is NOT a
prediction for Qwen; real Hessians are the P0 blocker. GPTQ with H = I
reduces exactly to RTN (unit test).

`quantize` writes bf16 safetensors for the selected tensors (untouched shards
symlinked), a manifest with per-tensor sha256 and a suggested distinct
tensor_cache suffix (a stale cache silently serves old weights).
MEASURED (bench/runs/bfp-packer-emulation-20260924T093819Z.jsonl): a snapped
9B gate/up checkpoint is a fixed point of the REAL packer (--expect-snapped);
the unsnapped down_proj fails the same gate, as it must.

`nix run .#bfp-quant -- {test,verify-packer,synthetic,proxy,quantize}`; the
tt-metal rev is read from flake.lock as text so the app never fetches the
tt-metal input.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Can't compute calibration Hessians without a large-RAM or CUDA box, so this
maps where plain RTN error sits, using the H = I proxy (relative MSE against
the FP8 weights dequantised the way production does). This cannot rank LDLQ,
because GPTQ with H = I is RTN.

MEASURED (bench/runs/bfp-proxy-hfree-20260924T092920Z.jsonl), layers 0-3,
30, 31, 62, 63 plus embed and lm_head:
- RTN bfp4 relMSE is 1.31-1.47e-2 in every group; RTN bfp8 is 5.5-6.4e-5
  (about 235x lower).
- 8-10% of bfp4 blocks saturate at the block max.
- The {e, e+1} per-block exponent search gains <= 0.1%, so it is not worth
  having.
- Every processed tensor passed check_on_grid.

The spread across groups is small because bfp4 is essentially a
constant-relative-precision format. Which groups can drop to bf4 therefore
has to come from activation-weighted (Hessian) error and the P1 KL gate, not
from weight statistics. Not measured: bf4-from-bf16 vs bf4-from-FP8 needs
the bf16 checkpoint, which no cluster host holds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The H = I proxy cannot rank LDLQ, so P0 needs real calibration Hessians.
27B bf16 does not fit 4x10 GB, so collect_hessians.py runs the GPTQ-style
sequential pass: one HF Qwen3_5DecoderLayer at a time (the reference
transformers implementation, GDN included -- nothing re-implemented),
weights streamed from safetensors, activations data-parallel across GPUs,
H = sum x x^T per linear input all-reduced in fp32 (TF32 off).
Modules sharing an input share one file, symlinked per module into the
layout `quantize --hessians` reads.

Every 4th layer stores two disjoint calibration halves (H_a/H_b), so GPTQ
can be fitted on one half and scored on the other. In-sample GPTQ gain is
optimistic by construction, and the go/no-go uses the held-out gain.

Verified before touching the GPUs:
- test_collect_equiv.py (tiny random qwen3_5, 3 GDN + 1 attention layer):
  final hidden states match Qwen3_5TextModel to 1.7e-6. Every Hessian
  matches full-model hooks to 3e-7 relative, both single-rank and
  2-rank/held-out.
- CPU run of all 64 real ThinkingCap bf16 layers on 255 tokens gives
  next-token CE 3.748 nats. Production vLLM (Qwen3.8-27B W4A16) scores the
  same tokens at 3.677, so the layer-wise forward is right.

Calibration set (make_calib_set.py, manifest alongside the tokens):
256 x 2048 tokens, rendered with ThinkingCap's own chat template.
- 108 open-r1/codeforces-cots traces and 96 OpenR1-Math traces, both from
  Mixture-of-Thoughts with <think>.
- 52 windows of packed NousResearch hermes function-calling
  conversations.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The first real calibration run saved all 64 layers but then died in the final
CE check (full-vocab logits for every token do not fit a 10 GB card) and lost
the lm_head Hessian, because its group file had the same name as the
per-module symlink pointing at it. CE is now chunked and the group file is
named lm_head.H.safetensors.

The study no longer needs the production GPUs: extract_layer.py pulls one
layer's tensors (bf16 + FP8 with scales) into a mini-checkpoint and
remote_study.sh copies that plus the layer's Hessians to a CPU host, runs
study_hessian.py, and deletes it -- so vllm-pod stays up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This is the first result that uses real calibration Hessians. We had synthetic
(16-23x) and Hessian-free numbers, and both were upper bounds. It covers 25 of
64 layers (184 modules): 16 full-attention layers held out, where GPTQ is fit
on one calibration half and scored on the other, and 9 GDN layers, in-sample
only, because every held-out layer is a full-attention layer.

Held-out GPTQ gains, i.e. the proxy-error ratio of RTN bf4 to GPTQ bf4:
attn_qkv 5.68x, attn_o 3.88x, mlp_down 3.71x, mlp_gate_up 2.63x.
In-sample GPTQ gains on GDN: gdn_ab 12.5x, gdn_qkvz 5.9x, gdn_out 2.40x.
Held-out shrinks the in-sample gain by 0.89 at the median and 0.48 in the
worst case. If that worst case applies to GDN, gdn_out falls to 1.14x. That
number is an estimate, not a measurement. The first #62 GO condition is met.
The EXL3-4bpw comparison has not been measured, so the verdict is
GO-PENDING-EXL3.

What moves the plan: GPTQ bf4 is still ~36x the error of RTN bf8 on
attention, and ~2.5x the ThinkingCap FP8 checkpoint's own error. The
bf8 -> bf4 move for attention/GDN has to be judged on the device accuracy
gate, not on this proxy.

Also: the skill runbook, and a merge that states which gains were in-sample.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner correction: the reference is the native FP8 checkpoint, not bf16. P0 had
measured bf4 error against bf16 weights. What the owner cares about is the
distance from FP8 as served, and a quantizer should start from FP8.
quantize_ckpt.py therefore runs GPTQ from W8, where W8 is the FP8 checkpoint
dequantized the way production does it, and scores it against W8.

On held-out layer 3 k/v it also scored the bf16 source against W8: GPTQ from
FP8 gives 1.32e-3 / 2.37e-3, GPTQ from bf16 gives 1.88e-3 / 2.86e-3. So FP8 is
the better source, as expected.

Two production-layout facts shaped the code:
- in_proj_a/b are fused per device as [a_d|b_d] with 24 rows each. One bfp
  block therefore straddles the two tensors, so they are quantized jointly in
  that order. verify_arm.py round-trips every per-device matrix through the
  real tt-metal packer.
- The lazy FP8 loader passes bf16 keys through untouched. assemble_ckpt.py
  can therefore swap the snapped tensors into the FP8 base without changing
  model code. attn/GDN bf4 is gated by QWEN36_ATTN_GDN_BF4 in copies of the
  image's loaders, and the gate changes weights only.

Modules that share a Hessian are stacked into one GPTQ run. Rows are
independent, so the result matches per-module GPTQ to float noise
(1.2082098e-3 vs 1.2082106e-3), with one column loop instead of three.

The first GPU GPTQ attempt on cfx-llm0 hit an OOM in RTN: the int64
temporaries of a 17408x5120 matrix are ~0.7 GB each. RTN is now chunked, and
the Cholesky is lean with an fp32 fallback. The checkpoint is built on CPU
after all, so production does not go down again.

tt-arm.sh follows the tt-card-slot protocol. It fails closed on the served
root and on the banners, and runs probes, retrieval, GSM8K and the standard
sweep per arm. teacher_fp8.py scores each arm's own continuation with vLLM
FP8 on the GPUs, and kl_reduce.py turns that into top-1 agreement and KL
lower bounds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The whole GPTQ-from-FP8 checkpoint (64 layers, 448 units, 0 errors) was built in one
cfx-llm0 window. The OOM-then-fp32 fallback could not work: the traceback of the fp64
attempt keeps its temporaries alive. verify_arm now proves itself non-blind with a
one-ulp fault injection that must mismatch. The first P arm boot died because the GDN
loader's local 'import os' makes the global unbound in the whole function.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Assembly previously dropped every weight_scale_inv from the arm index, which
flips is_fp8_checkpoint off and routes the arm through the eager loader -- a
different code path from prod, so the A/B would not be clean. Scale entries are
now kept. Cache seeding hardlinks only tensorbins whose values do not change,
because cold builds reuse any tensorbin present.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The P0 proxy record measured error against bf16, but the owner treats the native FP8
checkpoint as lossless, so this adds a record measured against dequantized W8. On held-out
data, GPTQ beats RTN at bf4 by 1.8x on mlp_down up to 5.1x on attn_qkv. That is smaller
than the in-sample 2.1-6.8x, which overstates the gain. Quantizing from bf16 lands farther
from FP8 in 21/21 held-out units, so FP8 stays the source.

On the cards, all four arms are within GSM8K noise (56-58/60) and every arm sits at the
kv-accuracy ceiling. The bf4 attn/GDN arms decode 3.2-4.6 ms/token faster and cut makespan
by 2.8-6.2%. Because task accuracy cannot resolve the arms, the FP8 KL gate is what has to
decide.

Three teacher windows failed on environment differences between the job container and
prod: flashinfer needs ninja, which the image lacks and prod hides behind its JIT cache;
the vision-encoder profile consumed the KV budget; and the prompt_logprobs fp32 tensors
are not counted by vLLM's memory profile. teacher_fp8 now dedups identical continuations,
is resumable and deadline-bounded, and has been dry-run against a fake engine including a
crash and resume.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The on-card task battery could not rank the arms (GSM8K 56-58/60, retrieval at ceiling), so
the go/no-go rested on KL/top-1 against native FP8. On 9 paired deep probes (24k-32k), G2
has the lowest KL to FP8 (0.085 vs prod 0.111) and the highest top-1 (+2.8 +- 1.4 pp), while
R2 -- same bytes and speed as G2, RTN instead of GPTQ -- is worse than prod (KL +0.065 +- 0.045).
That is the answer to the question P1 was built for: moving attn/GDN to bf4 costs accuracy under
RTN, and GPTQ from FP8 buys it back. FP8 itself scores 59/60 GSM8K and 1.0 retrieval.

Coverage is deliberately stated as partial: the teacher scored 32 of 115 unique continuations
(the deepest) before its deadline, in one 47.8-min window.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
#62 built G2 on a CUDA box; the owner wants the toolkit to do this on our own
TT cards (#67). The quantizer semantics are imported from tools/bfp-quant
unchanged; only the propagation W[:, rest] -= E @ Hinv[blk, rest] (~all FLOPs)
is made pluggable. gptq_sweep with the host fp32 propagator is bitwise
quant.gptq (tested), so any TT/CUDA difference is attributable to the
propagation arithmetic alone. TTPropagator keeps W resident on the card and
offers a 3xTF32 split in case Blackhole reads fp32 operands at TF32, which
the stage-1 precision probe measures. fake_ttnn models that one property for
dry runs; LoFi+fp32 acc is refused in code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Stage scripts are written before any card time so each run is one lock
window. The Hessian collector taps linears by WEIGHT identity on the ttnn
ops the prod TP prefill actually calls (MLP down is a plain ttnn.linear, the
rest are fused AG-matmul / matmul-RS), and fails closed unless every tapped
group fires exactly once per sequence. The teacher cannot be prod: prod is
arm P. It upgrades bf4->bf8 weights and forces HiFi4, builds cold without
writing tensorbins (the model disk is 95% full), and checks its host lm_head
against the device argmax.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Believed before: a TT build could match G2 on >=99% of bfp blocks if its
arithmetic were good enough. Measured on the host with the same algorithm in
fp32 (only BLAS/LAPACK differ from cuBLAS/cuSOLVER): L0 GDN groups agree on
99.79-100% of blocks, but L0 down_proj (17408-wide H) agrees on only 65.0%
(fp32 Cholesky) / 62.5% (fp64), while the proxy error is within +0.03% of
G2. Rounding decisions in a 17408-wide sweep are chaotic in the last ulp, so
the 1% proxy gate is the meaningful one and block agreement is reported
against this floor. fp32 factorisation tracks G2 closer than fp64, which
supports auto_chol_dtype's claim that the 10 GB-card build used fp32 there.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
All 13 L0/L3 units: CPU fp32 GPTQ lands within +0.03% of G2's proxy; block
agreement 97-100% except the 17408-wide down_proj (65% L0, 83% L3).
Side finding: with fp32 BLAS the whole GPTQ of one layer takes ~2 min on
the 20-core orchestra host, not the ~20 h the #62 skill quoted for CPU
(that figure was the fp64 column loop).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Measured on one Blackhole chip, L0 (7 units), device right-looking
propagation: TT/CUDA proxy ratio within 0.9957-1.0033 for both plain fp32
and 3xTF32 operands (gate: +-1%), so the checkpoint quality matches G2.
But bitwise bfp-block agreement is only 24-70% (3xTF32) against a 97-100%
CPU floor on the same units. 3xTF32 barely helps (41% vs 32% on qkv), which
points at the fp32 eltwise update W -= P on the device, not the matmul. The
fix is TTLeftPropagator: the device does only matmuls
(W[:,blk] = W0[:,blk] - E[:,:i1] @ U[:i1,blk]) and the host does the IEEE
fp32 subtraction; the probe now isolates ttnn.subtract's error.

The run then died on L3: load_hessian's fp64 combine of the held-out halves
of the 17408-wide down_proj H is 2x2.4 GB, the host swapped to 0.7 GB free
and the kernel OOM killer took the probe (exit 137). load_hessian_lean
does the same arithmetic per row chunk (bitwise, tested). The log lagged
by minutes because `cut` block-buffers into a pipe; removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Independently queued card-run.sh waiters raced for the lock and could not be
cancelled (TERM waits out their sleep); one chain driver runs stages in
order. ship.sh renames files into place because scp truncates the inode a
queued bash is still reading. The leak guard matched every kernel OOM
report (they list live pinned pages as alloc_chained_sgt_for_pages) and
would have refused runs for 30 min after an ordinary OOM.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Master retired the 136-doc tree, moved the Nix ttnn to nix/sim and pinned public
tt-metal 60053f1f. Took master's flake inputs and lock wholesale (per the PR #68
migration note) and re-added only the two quant outputs on top: bfp-quant (whose
rev lookup nodes.tt-metal.locked.rev still resolves) and tt-quant. The tt-cli /
tt-model-manager outputs this branch carried from its base are dropped with
master. nix run .#tt-quant -- test: 9 passed; check-cited-records: OK.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Stage 1 on hardware (L0 gdn_in, 3 blocks) showed fp32-operand matmuls only ~2x
better than bf16 (P_rel_fro 1.1e-3 vs 2.3e-3) and 3xTF32 only halving that
(5.6e-4), while the device fp32 subtract is bit-exact against the host. So the
FPU does not read fp32 operands at TF32; the right-looking run's low block
agreement is matmul error, not the eltwise op. Only operands that are exactly
bf16 are safe: split each operand into three exact bf16 parts and sum the six
significant products (smallest first) with fp32 dest at HiFi4.

Propagators now take any SPLIT_TERMS mode (fp32, 3xtf32, 6xbf16); the probe
gets --configs/--skip-xtx; new chain runs 6xbf16 next to the host-propagation
fallback (cpu-float32, only X^T X on the card).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
We assumed fp32 operands reach the FPU at TF32, so 3xTF32 would recover host fp32.
Measured: fp32 is only ~2x better than bf16 and 3xTF32 only halves that (5.6e-4
vs host 2e-7); the device fp32 add/subtract is bit-exact. The GPTQ block-agreement
gap is matmul error, which motivates the exact-bf16 6xbf16 split (queued on the
cards). Local records are now cited directly so the cited-record CI checks them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Single-card stages (precision, gptq) held the whole box and both device nodes,
which blocked MTP's TP=1 work on the other card. card-run.sh now goes through
ttx's slot.sh (installed on cfx-llm2): card0 by default for 1-card work with a
single --device, mesh for PROD=1 (Hessian taps, teacher). ttx keeps the legacy
lock in sync for unmigrated drivers; release waits for our container to exit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The 6xbf16 run found layer-0.safetensors left by the right-looking attempt and
silently skipped L0 (scoring included). Skipping is now opt-in.

6xbf16 on hardware: P_rel_fro 2.7-3.4e-4, flip rate 0.9-3.4e-5 -- ~4x better than
fp32 operands but 30x short of the 1e-5 target, with exact bf16 parts. The floor
is therefore not operand precision; it looks like the FPU's accumulate path.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
6xbf16 with exact bf16 parts still left a 3e-4 floor, so operand conversion isn't
the only loss. fpu_probe separates multiplier (one term per output, m-bit operands)
from accumulation (ones x bf16 over K) against host fp64 of the same values, which
decides what split, if any, can reach 1e-5.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
We expected an operand split to recover fp32 on the card. The synthetic FPU probe
shows the HiFi4 multiplier is exact and the loss is in the fp32-dest accumulation
(3.1e-4 on bf16 dot products, flat in K), so no split reaches 1e-5; 6xbf16 stops
at 3e-4. It does not matter for the checkpoint: card 6xbf16 and host fp32
propagation both pass the 1% proxy gate vs CUDA G2 on 14/14 L0+L3 units, and host
propagation is faster end to end on cfx-llm2 (223-236 s/layer vs 313-602 s), so it
is the default; the cards do the forward and X^T X.

Hessians collected by prod TP=2 prefill taps on the 1x2 mesh (same 256x2048
calibration tokens) differ from the CUDA ones by 0.9-19% rel Frobenius, at or
below the CUDA split-half noise; GPTQ on H_tt scored in-sample on H_cuda +0.02..8.7%.
Results go to QUANT.md / STATUS.md; the skill gets the runbook and results.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The CUDA FP8 teacher scored only p>=24576, so this short run cannot be compared
with it; the chain now reruns at every p of arm P.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The teacher machinery is verified on hardware: 44 arm-P continuations at p=1k..32k,
host head argmax == device argmax at T-1 on 43/44. Scored against the CUDA FP8
teacher it gets 0.934 top-1 / KL 0.114 -- but at --precision prod the teacher IS
arm P, and it rates its own arm 0.965 where the FP8 teacher rates it 0.917. That
+4.9 pt self-flattery is the measured reason the teacher must be upgraded away from
the arm, so bf8-hifi4 (cold build, cache_file_name=None) is the usable config; it is
queued behind the mesh slot.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
merge master into tt-quant
All checks were successful
tt-stack-ci / Report upstream drift (pull_request) Successful in 9s
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 52s
0bed4d7b0c
# Conflicts:
#	.claude/skills/bfp-quant/SKILL.md
#	bench/bfpq/tt-arm.sh
#	flake.nix
Grok merged commit c018d31f53 into master 2026-09-25 23:09:38 +02:00
Author
Owner

agent-gateway closeout (merged): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (merged): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Owner

verdict: approve
tier: T2 (adds a new flake app + nix package; runs on the card host)

rationale: The tt-quant pipeline is a faithful, well-scoped CUDA-free port of the existing G2 bfp4 quantizer onto the Tenstorrent cards: it imports the packer/rounder/Hessian/units code from tools/bfp-quant so the TT checkpoint is the same algorithm by construction, and the host tests verify bit-exact agreement with quant.gptq. Net addition to master is 34 files / +2914/-4, all under tools/tt-quant/ + nix/tt-quant.nix + flake wiring + docs — matches the declared scope.

concerns:

  • [warn] flake.nix:71 — tt-quant is added to BOTH packages and apps as claimed; confirmed the duplicate bfp-quant binding was deduplicated and the merge kept the superset. No structural regression.
  • [warn] tools/tt-quant/card-run.sh:40 — the single-card slot.sh acquire returns the released slot name (not a held lock) and HELD is only used in release via an owner string; there is no verification that the slot is still held before docker run. If slot.sh acquire returned a stale/free slot the job would boot on a card another driver is using. The MemAvailable/pinned-page/tenstorrent-serving pre-flight guards are good, but the lock-hold assertion is missing.
  • [warn] tools/tt-quant/card-run.sh:37 — HELD is never asserted non-empty after acquire; slot release "$HELD" on exit would no-op on a failed acquire (fine) but also silently no-op if acquire returned empty for another reason. The rc check on the next line covers the busy/memory cases; the unexpected-empty case is unguarded.
  • [info] tools/tt-quant/tt-quant.sh:35 — detached card jobs run under a bare timeout 30 ssh ... || [ $? = 124 ] with no per-stage failure propagation: if card-run.sh exits non-zero the launch still reports "launched", and the real exit code only lands in the .exit file. Acceptable for a detached prod job, but tt-quant logs is the only way to observe it — no alerting on a failed run.
  • [warn] tools/bfp-quant/bfp.py and quant.py are copied verbatim from the existing G2 tools and imported, not reviewed here for the bfp4 packing path — the correctness of the new code (ttq.py, gptq_tt.py, the propagators) is what this review covers, and it holds.
  • [nit] tools/tt-quant/gptq_tt.py:179 — --resume only skips a layer if its save file exists AND --resume is set; the arg help admits the stale-skip bug but the default (no --resume) is "redo and overwrite," which is the safe default. Fine.
  • [nit] tools/tt-quant/card-run.sh:65 — pinned-page-leak guard uses journalctl -k --since -30min, a reasonable heuristic; acceptable.

Net: clean, scoped, and the host test suite (test_ttq.py) verifies the key numerical claims (bit-exact vs G2, 3xTF32 recovery, LoFi refusal, bf16-split exactness). The one genuine gap is the missing lock-hold assertion in card-run.sh (a [warn], not a block — the pipeline is already merged and the guards in place are sound).

**verdict:** approve **tier:** T2 (adds a new flake app + nix package; runs on the card host) **rationale:** The tt-quant pipeline is a faithful, well-scoped CUDA-free port of the existing G2 bfp4 quantizer onto the Tenstorrent cards: it imports the packer/rounder/Hessian/units code from `tools/bfp-quant` so the TT checkpoint is the same algorithm by construction, and the host tests verify bit-exact agreement with `quant.gptq`. Net addition to master is 34 files / +2914/-4, all under `tools/tt-quant/` + `nix/tt-quant.nix` + flake wiring + docs — matches the declared scope. **concerns:** - [warn] `flake.nix:71` — `tt-quant` is added to BOTH `packages` and `apps` as claimed; confirmed the duplicate `bfp-quant` binding was deduplicated and the merge kept the superset. No structural regression. - [warn] `tools/tt-quant/card-run.sh:40` — the single-card `slot.sh acquire` returns the *released* slot name (not a held lock) and `HELD` is only used in `release` via an owner string; there is no verification that the slot is still held before `docker run`. If `slot.sh acquire` returned a stale/free slot the job would boot on a card another driver is using. The MemAvailable/pinned-page/`tenstorrent-serving` pre-flight guards are good, but the lock-hold assertion is missing. - [warn] `tools/tt-quant/card-run.sh:37` — `HELD` is never asserted non-empty after `acquire`; `slot release "$HELD"` on exit would no-op on a failed acquire (fine) but also silently no-op if acquire returned empty for another reason. The `rc` check on the next line covers the busy/memory cases; the unexpected-empty case is unguarded. - [info] `tools/tt-quant/tt-quant.sh:35` — detached card jobs run under a bare `timeout 30 ssh ... || [ $? = 124 ]` with no per-stage failure propagation: if `card-run.sh` exits non-zero the launch still reports "launched", and the real exit code only lands in the `.exit` file. Acceptable for a detached prod job, but `tt-quant logs` is the only way to observe it — no alerting on a failed run. - [warn] `tools/bfp-quant/bfp.py` and `quant.py` are copied verbatim from the existing G2 tools and imported, not reviewed here for the bfp4 packing path — the correctness of the *new* code (ttq.py, gptq_tt.py, the propagators) is what this review covers, and it holds. - [nit] `tools/tt-quant/gptq_tt.py:179` — `--resume` only skips a layer if its save file exists AND `--resume` is set; the arg help admits the stale-skip bug but the default (no --resume) is "redo and overwrite," which is the safe default. Fine. - [nit] `tools/tt-quant/card-run.sh:65` — pinned-page-leak guard uses `journalctl -k --since -30min`, a reasonable heuristic; acceptable. Net: clean, scoped, and the host test suite (`test_ttq.py`) verifies the key numerical claims (bit-exact vs G2, 3xTF32 recovery, LoFi refusal, bf16-split exactness). The one genuine gap is the missing lock-hold assertion in card-run.sh (a `[warn]`, not a block — the pipeline is already merged and the guards in place are sound).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!81
No description provided.