tt-quant: CUDA-free GPTQ/LDLQ bfp4 pipeline on the TT cards (#67) #81
No reviewers
Labels
No labels
cards:go
hermes-approved
human-approved
human-approved
iter
0
iter
1
iter
2
iter
3
prio:high
prio:low
prio:med
priority/high
state
blocked
state
doing
state
done
state
review
state
todo
x280
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitpartner/tt-stack!81
Loading…
Reference in a new issue
No description provided.
Delete branch "tt-quant"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 stagedrivers (precision probe, GPTQ, TT Hessians, TT teacher), stages running in the vllm-tt
image on the card host.
probe separating multiplier width from accumulation; exact-bf16 3-way split (6×bf16)
propagation and generic split schemes.
argmax == device argmax 12/12, and a prod-precision control quantifies the bias.
/tmp/ttlock..claude/skills/tt-quant/SKILL.md, including the traps paid for (FPU operand precision,OOM, log pipes, lock races).
docs/QUANT.mdanddocs/STATUS.mdupdated.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 thebfp-quantbinding — deduplicated, withtt-quantkept in bothpackagesandapps.bench/bfpq/tt-arm.shand.claude/skills/bfp-quant/SKILL.mdwere 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_HELDand thebfp4-packed-v1publish section.Verified after the merge:
docs/still 11 files, no rootCLAUDE.md,AGENTS.mdis thelean rewrite,
QWEN36_PREFILLED_SLOTS_FIXstill inqwen36_vllm.py, no PR #68 deletionresurrected. Locally green:
nixfmt --check,check-cited-records.py,shellcheck,nix flake check, andnix build .#bfp-quant .#tt-quant.Refs #67.
🤖 Generated with Claude Code
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>agent-gateway closeout (merged): cleared
agent:*labels.Hermes kanban card (if any) is left for Hermes to archive/complete.
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-quantso the TT checkpoint is the same algorithm by construction, and the host tests verify bit-exact agreement withquant.gptq. Net addition to master is 34 files / +2914/-4, all undertools/tt-quant/+nix/tt-quant.nix+ flake wiring + docs — matches the declared scope.concerns:
flake.nix:71—tt-quantis added to BOTHpackagesandappsas claimed; confirmed the duplicatebfp-quantbinding was deduplicated and the merge kept the superset. No structural regression.tools/tt-quant/card-run.sh:40— the single-cardslot.sh acquirereturns the released slot name (not a held lock) andHELDis only used inreleasevia an owner string; there is no verification that the slot is still held beforedocker run. Ifslot.sh acquirereturned a stale/free slot the job would boot on a card another driver is using. The MemAvailable/pinned-page/tenstorrent-servingpre-flight guards are good, but the lock-hold assertion is missing.tools/tt-quant/card-run.sh:37—HELDis never asserted non-empty afteracquire;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. Therccheck on the next line covers the busy/memory cases; the unexpected-empty case is unguarded.tools/tt-quant/tt-quant.sh:35— detached card jobs run under a baretimeout 30 ssh ... || [ $? = 124 ]with no per-stage failure propagation: ifcard-run.shexits non-zero the launch still reports "launched", and the real exit code only lands in the.exitfile. Acceptable for a detached prod job, buttt-quant logsis the only way to observe it — no alerting on a failed run.tools/bfp-quant/bfp.pyandquant.pyare 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.tools/tt-quant/gptq_tt.py:179—--resumeonly skips a layer if its save file exists AND--resumeis set; the arg help admits the stale-skip bug but the default (no --resume) is "redo and overwrite," which is the safe default. Fine.tools/tt-quant/card-run.sh:65— pinned-page-leak guard usesjournalctl -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).