/tt-model-bringup:full-modelfrom Tenstorrent Model Bring-up
Assembles a complete TTNN autoregressive model from HuggingFace weights and working block implementations, including embeddings, KV-cache, generation loop, and accuracy validation.
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 working TTNN block or decoder code and turns it into a complete autoregressive model that can run end-to-end on real weights. The output should be a model wrapper plus a generator appropriate to the project. If a project-specific orchestration skill defines filenames, class names, readiness runners, or artifact locations, follow that contract there; this skill describes the general engineering work.
The full model stage does not implement the vLLM adapter, but it must design the model and generator so a later serving adapter can drive the same low-level prefill/decode path without duplicating model logic. Treat the generator as a serving component, not only as a demo loop: external callers may own scheduling, cache/page-table state, prompt lengths, positions, sampling parameters, fixed request slots, inactive rows, and mixed-length prompts.
Implement the model-specific pieces around the working block stack:
Use the strongest correct implementation available as your block stack. If there are several candidates, choose the one with the best evidence for the target mesh and explain the choice.
The full model must support the context length advertised by the HF config. Start from models/autoports/<model>/doc/context_contract.json, then recompute it for the full layer stack. Include all loaded weights, the full-layer KV cache, page tables, trace buffers, persistent CCL buffers, and other long-lived tensors that consume device DRAM. Byte arithmetic is a plan, not the measurement: after the model loads, record the device memory view (ttnn.get_memory_view or the runtime's equivalent) and derive the KV budget from the measured free DRAM. Per-layer RoPE tables and allocator padding put Qwen3-8B 2.1 GB above its arithmetic.
Also preserve the rest of the advertised model capability contract established by earlier stages: cache/state semantics, layer kinds, mode switches, and the externally visible generation behavior. Do not reduce the advertised model capability to make bringup, tests, profiling, or serving easier. A reduction is acceptable only when a hard physical device limit prevents the advertised capability from fitting or running, such as device DRAM capacity for weights + KV/cache/state + required persistent buffers. If reduced, record the byte calculation or failed capacity probe, the largest feasible supported value, and the exact construction/serving setting that uses it.
Prompt length is a logical API input. The full model and generator must accept valid prompt lengths up to the supported context, including lengths that are not divisible by internal prefill chunk, tile, block, page, or trace sizes. If an op path needs aligned physical shapes, pad or chunk internally, mask padded tokens, and slice returned logits/output state back to the logical prompt length. Do not expose assertions such as seq_len % chunk_size == 0 unless the HF model itself has that semantic restriction.
Batch handling is part of the capability contract. Optimize primarily for batch-1 single-user latency, but do not hard-code batch 1 into the model, generator, cache, page tables, position handling, sampling, or output formatting. Support larger batches through the same low-level API and test up to batch 32 when the target hardware, memory, and harness allow it. If batch 32 cannot run, record the largest tested batch and the hard physical limit.
Find serving gaps before the generator, sampler, and datatype policy are optimized and frozen. Before you choose the sampler and fix the low-level generator API, resolve and pin the serving stack as serving stack setup describes. This check only reads the pinned plugin checkout. It does not install the stack or launch a server, and it is not vLLM integration work.
Read the pinned plugin's model interface guide (currently docs/MODEL_INTERFACE.md) and every document it links for setup, execution, lifecycle, capabilities, decode reload, and other extension contracts that the model could use. Inspect the pinned plugin source where those documents do not say which adapter calls or declarations the plugin uses. Read its device test suite (tests/tt). When the pinned plugin has no interface guide, read its model-runner and sampling source and tests/tt instead, and list every file read in documents_read; the gate checks that each supported row's evidence path exists under the model directory. Then write models/autoports/<model>/doc/full_model/serving_contract.json:
{
"plugin": {"repository": "tenstorrent/vllm-tt-plugin", "commit": "<40-character SHA>"},
"vllm": {"version": "<recommended release or ref>"},
"documents_read": ["docs/MODEL_INTERFACE.md", "docs/MODEL_SETUP.md"],
"rows": [
{"item": "logprobs", "kind": "request_feature", "status": "supported", "evidence": "<test or artifact path>"},
{"item": "supports_prefix_caching", "kind": "capability", "status": "supported",
"evidence": "readiness/prefill_resume_check.json"},
{"item": "batched_prefill", "kind": "call", "status": "supported", "evidence": "<batched-equals-solo test>"},
{"item": "supports_device_penalties", "kind": "capability", "status": "not_supported",
"declaration": "<key and value, or documented default>", "reason": "<why the model does not implement it>"}
]
}
Prefix caching and batched prefill are required rows. supports_prefix_caching may be not_supported only for an exclusion named in prefill features (block_output or recurrent_state), and the reason must name it; the gate rejects any other reason.
Add one row for each adapter call, model_capabilities declaration, and request feature that the plugin calls or tests, such as sampling parameters, seeds, logprobs, penalties, chunked prefill, prefix caching, and async decode. kind is call, capability, or request_feature. status is one of:
supported: the generator provides it; evidence names the test or artifact;not_supported: an existing documented declaration or its documented default states it; declaration names it, and reason explains the effect on requests and why the model does not implement it;plugin_owned: the plugin changes rules assign the gap to the plugin; record is the justification record path relative to the model directory;missing: the plugin test suite or the serving goal requires it, and the generator does not provide it.Missing rows are full-model work, and the stage gate rejects them. Do not plan to close a row with a new plugin capability, environment variable, or --additional-config option. A gap that is smaller to close in the plugin is still a model gap when the model owns the behavior.
Read the HuggingFace reference model and the reports for the working TTNN blocks before writing the wrapper. Understand the whole autoregressive path: input IDs, embeddings, masks, position IDs, cache layout, block calls, logits, sampling, and generated token feedback.
Keep setup-time work outside the hot runtime path: weight conversion, dtype choices, tensor layout preparation, cache construction, and tokenizer loading should not be hidden inside a measured prefill or decode forward.
Do not use repeated full-stack model runs as the normal debugging loop. After one or two expensive full-model failures, build a reduced reproducer before continuing: for example, load the same full-model wrapper with one real layer of each kind, real tensor shapes, real cache/page-table shapes, real terminal norm/LM head/sampling, and a short prompt/generation length. Use that reduced full-model path to localize wrapper, trace, cache, page-table, LM-head, or sampling bugs, then return to the all-layer model for final evidence. If the reduced reproducer cannot expose the failure, record why before spending more full-stack runs.
Avoid hidden host fallback in a single prefill or decode pass. The final decode path uses traced TTNN execution. Teacher-forcing readiness runs through traced decode. Eager decode is useful only while debugging and is not completion evidence. When adding trace capture/replay or debugging trace execution failures, use $tt-enable-tracing. Before accepting the full-model trace, run representative repeated token-out replay with TT_METAL_TRACE_ALLOC_TRACKING=1. Exercise every captured trace key in the ordering used by the generator, including persistent decode and sampling inputs/outputs, and resolve every unsafe allocation under the contract in the target tt-metal checkout's tech_reports/AdvancedPerformanceOptimizationsForModels/TraceCorrectness.md.
The full-model stage owns sampling. A full model is complete only when token-out decode uses the canonical split-sampling contract:
models/common/sampling/ and models/common/modules/sampling/sampling_1d.py. Compare their contracts against this model: state ownership, trace behavior, mesh/topology support, sampling-param/seed/logprob/penalty handling, tt_out_tok support, top-k/layout/padding expectations, and fit with the generator. Choose the implementation that best fits the model. Record the choice and the rejected alternative in the full-model docs. If neither common implementation fits, explain the exact missing contract before writing custom sampler code;tt_out_tok pointing at the persistent decode token input tensor, so the sampled token becomes the next decode input on device;The same path supports top-k/top-p sampling. Do not complete the full model with a one-off greedy-only path and leave sampled serving to be invented in vLLM.
The delivered token-out path has no host argmax, full-logits readback, untraced sampling inside the model trace, or Python readback/writeback loop. If this contract does not work, keep the full-model stage failing and debug it there before starting vLLM.
Some shared tests require host-side sampling. Support that as an explicit compatibility mode in the generator when needed, but keep it separate from the optimized measured path. Host sampling must never replace the on-device traced sampling path used for token-out performance or vLLM serving.
Build decode around persistent device state:
$tt-enable-tracing; restore warmup-mutated KV/request and RNG state;$tt-enable-tracing;tt_out_tok, not a host reconstruction path;If TTNN or the runtime API blocks one of these items, keep the stage incomplete until it is fixed or you have the smallest repro for the blocked item. Do not treat a full-model decode result as complete while it still has avoidable host work between trace replays.
Use $multichip and $optimize for full-model pieces added around the decoder stack. Match the decoder's multi-chip sharding and keep the full model optimized. For profiling, build a reduced variant with one real layer of each kind, such as one sliding-attention layer and one full-attention layer. Keep real tensor shapes, sequence shapes, sharding, dtypes, KV-cache/page-table shapes, final norm, LM head, sampling, and trace behavior. Do not run Tracy or device-profiler collection on the full all-layer model stack. This keeps profiling fast and avoids multi-GB profiler dumps and Tracy buffer limits. Final evidence should include a tt-perf-report for the reduced-layer profiling variant.
The generator should expose two conceptual levels:
The standard Metal generator interface is:
def build_generator(model_dir, mesh_device, **kwargs): ...
with a concrete generator class implementing readiness_check.contract.Generator from this plugin.
Expose both API levels with signatures along these lines:
def prefill_forward(tokens, *, page_table, kv_cache, prompt_lens, start_pos=None, ...): ...
def decode_forward(tokens, start_pos, *, page_table, kv_cache, ...): ...
def prefill_logits(prompt_token_ids): ... # high-level, owns cache/page-table setup
def prefill_logits_continuation(prompt_token_ids, start, *, positions=None, prefill_prefix=True): ...
def generate(prompt_token_ids, max_new_tokens, *, next_input=None, enable_trace=True, **kwargs): ...
prefill_forward takes several rows per call, each with its own absolute start_pos and absolute prompt_lens end, and computes tokens[i, start_pos[i]:prompt_lens[i]] at absolute cache and RoPE positions. That one path serves prefix-cache hits, chunked continuations, and preemption resumes; prefill features lists the invariants. prefill_logits_continuation is the high-level driver the resumed-prefill readiness check calls. The exact arguments can vary by model, but keep them keyword-friendly and explicit. enable_trace must be an explicit keyword on generate; accepting it only through **kwargs is not enough because the readiness teacher-forcing runner requires traced decode. The high-level generate path should be a thin deterministic loop over the low-level methods.
Make cache ownership explicit. Standalone generation often owns its cache internally; serving or other external callers may need to pass an already-allocated cache and page table. Do not bake in assumptions that prevent either mode unless the project contract intentionally does so.
Preserve the decoder's inter-layer data layout unless changing it is faster end to end (and measured evidence proves it). If the optimized multichip decoder keeps the residual stream sharded/fractured across devices, do not force every layer to all-gather back to a replicated full hidden state simply because that is easier for the wrapper. Prefer the same layout contract and fused collective/matmul patterns used by the mature implementation; if a final gather is needed for norm, LM head, or sampling, localize it to the terminal path and measure it separately.
Compare full-model behavior against the HuggingFace reference with real weights. Use the project's readiness or evaluation harness when one exists. At minimum, gather evidence for:
Run correctness from the smallest useful surface to the full gate. Start with a short smoke check on the reduced full-model probe when the all-layer gate is slow, then move to the complete all-layer model after the smoke check passes. If a test, prompt, or command fails, rerun that failing item directly while debugging; do not rerun the whole suite after every edit. Once the targeted failure is fixed, rerun the smoke check, then rerun the full all-layer correctness gate for final evidence.
Include both batch-1 and larger-batch correctness coverage. Batch 1 is the primary latency target, but the model must still handle batch dimensions correctly. Add at least one batch >1 test for prefill, decode, cache/page-table indexing, token feedback, and output formatting; test up to batch 32 when the hardware and harness allow it. Two more tests are required here, because serving depends on them: a resumed-prefill test through prefill_logits_continuation (run run_prefill_resume_check and keep its output under readiness/), and a multi-row prefill test where one prefill_forward call carries rows of different lengths and the per-row outputs equal the single-row results. Implement prefill_logits_continuation in the generator; see prefill features. A prefill kernel selected by chunk length can fail the resumed-prefill check with a correct cache, because the continuation and the full prefill then compute the prefix differently; the reference names it as a cause to rule out first.
For instruction/chat models, prefer a teacher-forcing reference generated from a normal chat-template prompt over raw book text. In tt-metal autoports, use the DeepSeek AIME24 prompt set rendered by the HF tokenizer chat template as the main readiness reference, for example:
python -m readiness_check.generate \
--hf-model <hf-model-id> \
--prompt-source aime24 \
--chat-template \
--gen-len 100 \
--top-k 100 \
--output <model_dir>/readiness_aime24_chat.refpt
Raw Tale-of-Two-Cities/book references can still be useful as extra stress coverage, but they should not be the main quality gate for an instruct model unless the model lacks a usable chat template. Use $qualitative-check for all prompt-based quality checks, prompt-format evidence, HF controls, and raw-completion versus chat-template classification.
Generate the main reference fresh by default. Reuse a reference only when metadata under the current autoport directory proves the same HF model id and revision, tokenizer, prompt source, chat-template flag, generation length, top-k, and generation command. If any of that is missing or mismatched, regenerate the reference rather than carrying forward a possibly contaminated artifact.
Free-running comparison must be strong enough to catch feedback bugs; teacher forcing cannot see them by construction (it overrides the token-feedback path every step). Use several prompts and the longest feasible generation - at least 64-128 tokens when runtime allows - not a single short continuation. Then run:
python "${TT_MODEL_BRINGUP_ROOT}/runtime/readiness_check/check_degenerate_output.py" \
--hf-model <hf-model-id> --missing-artifacts critical --scope autoregressive
and include its verdict in the stage evidence. Mechanical degeneracy - doubled tokens, single-token collapse - is a decode-loop bug, never a model property. The runner-side stage gate runs the same check.
Shift qualitative checks left: as soon as the full model can generate text, use $qualitative-check to run the shared qualitative prompt suite through both the HF reference and TT generator. Later stages may add serving-specific checks, but they should not be the first place these prompts are tried. No packaged runner sends the suite through a generator before the vLLM stage; keep the script that does it under doc/full_model/qualitative/ with its outputs, so later stages rerun the same prompts.
Add a focused split-sampling trace test before marking the stage complete:
Build the fast probe before any repeated debugging loop: a reduced full-model variant (one layer of each kind, short generation, real tensor/cache/page-table shapes, and the real terminal path) with a documented runtime of a couple of minutes or less. Repeating a multi-minute all-layer pass to answer single-bit questions wastes the budget the debugging loop needs; the probe pays for itself within a few iterations. This probe is for debugging only. Final correctness and performance evidence still comes from the complete all-layer model.
When full-model accuracy is poor, debug the new wrapper first: embeddings, final norm, LM head/tied weights, positions, masks, cache indexing, prompt lengths, page tables, and sampling all commonly fail outside the decoder itself. If the failure spans several of these boundaries and the causal chain is unclear, use $autofix; it will run $autodebug if needed, then verify or refute each proposed bug before keeping any fix. Escalate back into decoder precision or fidelity only when evidence points there.
When an accuracy failure appears to follow a dtype, cache dtype, math fidelity, or CCL payload change, treat that as a precision-policy diagnosis, not as a root cause. Write down the whole active policy first: activation dtype, every weight dtype group, math fidelity per projection, cache dtype, CCL payload dtype, page/block size, cache layout, page-table policy, and decode update op. Then run controls that can distinguish a true cache/kernel defect from a policy-margin problem:
"BF16 fixes it" localizes an error-budget boundary. It does not by itself prove that BFP8 cache is inherently unstable, that paged_update_cache is defective, or that accumulated numerical error is the root cause. State those as hypotheses until the controls above isolate them. If a reduced cache probe uses different page block size, batch width, local KV head count, update row shape, mesh mapper, or page-table policy from the full model, label it as smoke evidence only and do not use it as causal proof.
For paged decode, validate the cache/page-table allocation contract against the attention op's rounded read window, not just the requested token count rounded to page size. Record the first top-k miss index, absolute sequence position, page/block id, and dynamic attention chunk boundary before blaming dtype drift. If misses cliff at a page, tile, power-of-two, or chunk boundary, run an over-allocation control where the cache/page table covers the next SDPA decode rounded read window. A passing over-allocation control is an allocation/attention-window bug, even if BF16 happened to mask the shorter allocation.
Measure warmed full-model prefill and decode behavior, not just block latency. Include generator overhead, cache management, final norm, LM head, logits, and sampling in the reported numbers unless the project specifically asks for device-only timing. Use the $optimize skill to ensure on-device performance is as high as you can get it, but in addition now we care about the end-to-end time as measured from the host. Section 4.5 of tech_reports/LLMs/llms.md has great advice on this that you should read, understand and follow.
The figures you must report are:
Report two decode metrics when they differ:
Be precise about the local harness. readiness_check.run_teacher_forcing drives generator.generate(..., next_input=..., enable_trace=True): it teacher-forces the next input, but the predicted token still comes from the generator token-out path. It is therefore a token-out correctness/performance gate, not a pure logits-only decoder timing. If you need a PERF.md-style logits-only comparison, create and label a separate traced no-sampling measurement.
Do not compare a sampling-inclusive serving result against a teacher-forcing/logits-only reference without naming the boundary. If token-out decode is slower, profile terminal work separately: final norm, LM head, logits movement/all-gather, argmax/top-k/sampling trace, token readback, and trace orchestration.
Treat host steps between decode iterations as implementation bugs to remove from the steady-state path, not just performance terms to report. Add counters for trace replays, token-input refreshes, current-position/RoPE refreshes, page-table refreshes, synchronizations, and readbacks, then drive the steady-state refresh counts to zero except where the caller-visible API truly requires a readback or the scheduler changes state. If current-position/RoPE refreshes happen once per generated token, the full model still has a host-stepped decode loop; fix it with device-side state advance where possible before claiming optimized full-model performance.
Measure the primary batch-1 TTFT and trace-verified decode t/s/u with the same workload shape as the vLLM primary single-user profile (prompt 128 / generate 128 by default unless the project specifies otherwise), separate from the accuracy workload, and record the workload shape next to every number. Compare this to vllm_benchmark.json in later stages. The larger-batch or concurrent-serving checks prove capability and serving behavior; they are not a replacement for the batch-1 latency target.
If performance regresses badly from block-level evidence, inspect data movement between embeddings, blocks, final norm, LM head, and sampling before changing precision.
For greedy decode, the perf report must not show avoidable sampler work as the dominant token-out cost. If ArgMaxDeviceOperation, full-vocab all-gather, generic TopKDeviceOperation, or another sampling op dominates token-out decode, fix the LM-head/sampling contract before treating dtype, CCL, or LM-head tuning as the primary optimization target. The alternate benchmark must be a semantically equivalent greedy split-sampling path, not a slower generic sampled mode that does extra work.
Compare full-model decode against the best decoder-layer stack lower bound before declaring the result good enough:
If the lower bound says the requested target is plausible but the full model misses it, the optimized-full-model pass must close that specific gap. If the lower bound itself misses the target, return to decoder/multichip optimization or a targeted precision/fidelity policy rather than spending the budget on generator code.
Done means all of these are true and recorded:
doc/full_model/serving_contract.json with no missing rows;readiness/prefill_resume_check.json from run_prefill_resume_check with every resume start passing and both negative controls failing, or the serving-contract exclusion that explains its absence;$qualitative-check evidence, including prompt-format metadata, rendered prompt artifacts, HF controls, and the shared qualitative prompt suite run through the TT generator;tt_out_tok feedback into the persistent decode token input, current-position coherence, and page-table refresh coverage;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./datatype-sweepSweep and select TTNN model weight, activation, KV-cache, CCL datatype, and compute-fidelity policies for the fastest configuration that satisfies minimum full-model top-1 and top-5 accuracy. Use after optimized-full-model and before vLLM, or whenever a runnable TTNN full model needs evidence-backed precision selection./functional-decoderBring up a functionally correct TTNN implementation of HuggingFace transformer decoder layers under the model-specific autoport directory. Use when producing a functional_decoder.py implementation, reading the HF decoder architecture, validating paged prefill/decode against the HF reference, and leaving compact correctness and performance evidence./graph-fusingFuse a TTNN op graph into a faster numerically-equivalent one by (1) replacing a primitive op sequence with a dedicated tt-metal op, (2) simplifying/merging structural ops, and (3) folding adjacent ops into an existing op./model-bringupImplement Hugging Face text models in TTNN through staged decoder, multi-chip, full-model, datatype, vLLM and benchmark work. Use for model bring-up or resuming its staged goals; requires separately installed tt-autodebug./multichipParallelize single-chip TTNN code across the available multi-chip hardware. Use when parallelizing a model or module, choosing a tensor/mesh parallel strategy, comparing to a single-chip TTNN baseline, and leaving correctness plus performance evidence.Other plugins' skills for the same job