/tt-model-bringup:datatype-sweepfrom Tenstorrent Model Bring-up
Sweeps TTNN model precision configurations (weight, activation, KV-cache, CCL datatype, compute-fidelity) to select the fastest setup meeting top-1 and top-5 accuracy bars. Use after optimized full model and before vLLM.
Ships in Tenstorrent Model Bring-up. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Before using this workflow, follow the dependency and environment setup in the model-bringup entrypoint. Resolve its package root from this installed skill's location; do not assume this plugin is copied into the target tt-metal checkout.
This skill starts from a working optimized TTNN full model and chooses the fastest practical precision configuration that still meets a stated full-model accuracy bar. It is normally used after optimized full model and before vLLM so the serving adapter inherits a settled weight, activation, CCL, KV-cache dtype, and compute-fidelity policy.
The selected precision artifact must be complete enough for later stages to consume mechanically. Include weight dtype groups, layer exceptions, compute fidelities, activation/residual dtype, CCL communication dtype, KV-cache dtype, logits/sampling dtype assumptions, and any loader/runtime flags needed to construct that exact policy. A selected config that only says "BFP8 weights" is incomplete.
Recorded policy is not enough. The runtime construction path must actually consume every selected dtype and compute-fidelity field. Prove this with a model summary, config propagation check, or profiler/perf-report rows from the measured candidate. If a field appears in selected_precision_config.json but the code path ignores it or hard-codes a different value, the sweep is incomplete.
The expensive source of truth is full-model top-1/top-5 accuracy. Decoder-layer PCC and component timing are useful only for ordering candidates and debugging surprises.
Datatype selection must preserve the capability and context contract. KV-cache dtype can change the largest feasible context, so recompute models/autoports/<model>/doc/context_contract.json for the selected config. If a candidate only passes by lowering context or another advertised capability, it fails unless a hard physical device limit prevents the advertised capability from fitting or running and evidence proves that the smaller value is the largest feasible one for that candidate.
Datatype selection must also preserve valid non-aligned prompt lengths. If a candidate changes KV-cache dtype, cache layout, trace buffers, or prefill chunking, rerun the non-aligned prompt/prefill check before selecting it. A faster candidate that only accepts aligned prompt lengths fails the capability contract.
If the user does not provide an accuracy bar, use:
Keep top-100 at the existing readiness expectation unless the user or model-specific evidence explicitly changes it.
Produce:
models/autoports/<model>/doc/datatype_sweep/README.md
models/autoports/<model>/doc/datatype_sweep/work_log.md
models/autoports/<model>/doc/datatype_sweep/sweep_results.json
models/autoports/<model>/doc/datatype_sweep/sweep_results.csv
models/autoports/<model>/doc/datatype_sweep/selected_precision_config.json
models/autoports/<model>/doc/datatype_sweep/top1_perf_pareto.png
models/autoports/<model>/doc/datatype_sweep/top5_perf_pareto.png
The README should lead with the selected config, top-1, top-5, top-100, TTFT, trace-verified teacher-forcing decode t/s/u, post-selection token-out decode t/s/u when available, and the exact acceptance thresholds. Label each performance number with its measurement regime and workload shape.
Start from the completed optimized full model. Run and record the current baseline:
--gen-len 100;run_prefill_check and run_teacher_forcing top-1/top-5/top-100;models/tt_transformers/tests/tale-of-two-cities.txt.bz2, several hundred positions), scored per position against HF. The readiness reference is an HF-greedy continuation with large margins; a BFP4 MLP policy scored 0.92 to 0.97 top-1 there and 0.82 to 0.85 on 1468 natural-text positions, and the readiness reference alone would have selected it;If an existing reference has fewer than 100 generated tokens, regenerate the main readiness reference with 100 generated tokens unless a concrete model or memory limit prevents it.
Teacher-forcing decode performance is valid only when the measured path uses traced decode. Eager/untraced teacher-forcing results may be used for temporary correctness debugging, but they are not acceptable sweep evidence and must not be used to rank candidates, draw Pareto charts, or select the fastest passing config. If traced teacher forcing fails, fix tracing before continuing the sweep.
Use this coarse search first. It usually finds most of the available win with a small number of full-model runs.
Restore-order example for dense MLP or MoE-style blocks:
This order is a heuristic, not a law, with the typically most-sensitive parts of the model being tried first. Adjust it for the model architecture, profiler evidence, and observed failures. For MLA, shared experts, unusual norm placement, gated attention, or fused projections, map the groups to the nearest semantic operation and record the mapping.
When backing out a failed BFP4 trial, restore to BFP8 first unless BFP8 itself is known to be the failing precision for that tensor group.
For every material matmul group tested with BFP4 weights, include a LoFi compute-fidelity candidate for that same group. BFP4 with HiFi2 is allowed as a comparison or fallback, but it is not enough by itself. If a BFP4+LoFi candidate cannot be run, record the exact TTNN/runtime blocker and keep the stage open until the blocker is fixed or $autofix fails.
Sweep compute fidelity even when dtype is unchanged. For dominant decode projection groups, include BFP8+LoFi and BFP8+HiFi2 candidates when both are legal. Do not assume HiFi2 is fastest for BFP8, and do not assume LoFi is safe without full-model top-1/top-5 evidence. Record dtype and fidelity together in each candidate id so later stages can construct the exact policy.
Note sometimes different datatypes require small semantic changes to the code. KV cache is a common example of this - paged_fill_cache requires tensors that are the same datatype as the cache but paged_update_cache requires update tensors in BF16/FLOAT32 even when the destination cache is e.g. BFP8. So when changing datatypes first run a quick one-decoder smoketest to check it works correctly and get that right before using it or rejecting it in a full model pareto sweep.
Treat expert matmuls like MLP matmuls:
Router and weighting numerics are expected to be more sensitive. Do not include router logits, top-k selection, routing scores, gate weighting, or expert reduction weighting in the coarse BFP4 sweep, perhaps in BFP8 but with somewhat low priority as they are not typically expected to be a performance bottleneck.
For MoE sweeps, record route/top-k distribution or active expert count when model architecture allows this to vary, since the performance impact depends on how many experts actually run.
Every kept candidate must be validated with full-model accuracy. For each evaluated config record:
Use $qualitative-check for prompt-based evaluation evidence: prompt-format metadata, rendered prompt artifacts or token ids, HF controls, and classification of raw-completion or chat-template behavior.
Always use trace-verified teacher-forcing decode t/s/u to rank datatype candidates - a non-traced path is not useful. If fully-traced decode is not working, use the $autofix skill until it is.
A precision change can fail the resumed-prefill gate of prefill-features.md without a resume bug: the resumed and fresh TT paths agree with each other while both drift from HF at hard positions. Rerun run_prefill_resume_check on the selected policy, and classify any failure with a per-position comparison against HF (the margin probe) before treating it as a cache or position defect.
Teacher-forcing is the selection metric, not necessarily the serving headline. After selecting the winning config, run the same warmed token-out no-readback benchmark used by optimized full model, using the selected config through the normal construction path. Record this separately as post-selection token-out performance. If the model cannot run that benchmark, state why instead of presenting teacher-forcing performance as token-out performance.
If layer-level decode evidence, reduced token-out evidence, or a prior optimized full-model token-out artifact points to a different fastest passing policy than teacher-forcing does, resolve the conflict before selecting. Run the same token-out benchmark for the baseline and the top conflicting candidate through the normal construction path. If token-out cannot run because the generator or trace-feedback path fails, treat that as a bug to fix or a recorded blocker; do not silently use teacher-forcing throughput as the serving-policy answer.
Use matplotlib/pyplot to generate two elegant, delightful Pareto charts:
top1_perf_pareto.png: x-axis top-1 accuracy, y-axis performance.top5_perf_pareto.png: x-axis top-5 accuracy, y-axis performance.Use trace-verified teacher-forcing decode t/s/u as the default performance metric. If only traced latency is available, convert to a higher-is-better performance metric or clearly label the axis. Do not plot eager/untraced decode performance as a Pareto candidate.
Plot every evaluated full-model config as a point. Fit or draw the non-dominated Pareto frontier through the evaluated points. Mark the selected config in red. Draw a vertical dotted line whose x-intercept is the minimum allowed accuracy level for that chart. Label or annotate enough points that the selected tradeoff and rejected candidates are clear without reading the raw JSON. Show these prominently in the README.md.
Compute fidelity is part of the selected precision policy, not only documentation.
For reduced-precision matmuls, sweep legal compute fidelities in the same candidate matrix as datatypes once the promising dtype groups are known. Use the tt-perf-report output from individual decoder or reduced full-model runs and full-model accuracy to guide this decision. BFP4 weights are expected to use LoFi unless measured evidence says otherwise. BFP8 weights should compare HiFi2 and LoFi for dominant decode projection groups instead of assuming one fidelity is best. HiFi4 is usually reserved for accuracy-sensitive operations with BF16 weights. FP32 destination accumulation is also an option.
Before selecting a config:
Pass a candidate's precision config to the readiness runners through --build-kwargs or --build-kwargs-file (a JSON object forwarded to build_generator), not through environment variables or an edited default file. If the runtime does not currently expose fidelity as a policy field, add that plumbing before ranking candidates. Do not satisfy this requirement by writing compute_fidelities into JSON that the measured model ignores.
Select the fastest config that satisfies the acceptance bar on every reference. Measurement noise is the spread between the repeated serial baseline runs recorded in the baseline section; a candidate counts as a gain only when it beats the baseline by more than that spread, and two configs inside it are a tie, where the simpler and safer one wins.
Before finishing:
build_generator, full-model, and vLLM paths actually consume by default;$qualitative-check to rerun the shared qualitative prompt suite on the selected config, with HF controls. If visible text quality selects or rejects a dtype/fidelity candidate, the verdict must come from this prompt-correct suite;build_generator and the vLLM adapter load the same selected weight/activation/CCL/KV/fidelity policy used by the winning sweep result.If no lower-precision config passes, keep the baseline and leave evidence that the sweep actually tested the likely wins.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tenstorrent/skills --plugin tt-model-bringup14 skills in this plugin
/benchmark-modelReport a text model's accuracy on fixed lm-eval subsets and 4K-input vLLM serving performance at concurrency 1 and 32. Use after optimized-vLLM for the final model-bringup report or to benchmark a supported model./full-modelBuild a complete TTNN autoregressive model and generator from a HuggingFace model plus one or more working TTNN block or decoder implementations. Use when assembling embeddings, block stack, final norm, logits, KV-cache handling, and generation into a full model, validating end-to-end behavior, and reporting full-model accuracy plus generator-level performance. Repo-specific file contracts belong in a project orchestration skill such as model-bringup./Other plugins' skills for the same job