tensorcad

v0.1.21
io.github.Filip-Pajalic/tensorcad Checked 2 days ago Published 2 months ago

Design transformer LLM architectures and report their parameters, FLOPs, memory and cost

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

tensorcad_list_designs List designs

List the designs this server has open, the built-in reference architectures you can start from, and the .tensorcad.json files it can see on disk. Start here when you do not already hold a design_id.

ParameterTypeDescription
include_filesbooleanAlso scan the working directory for .tensorcad.json files.

tensorcad_new_design New design

Create a design from a reference architecture, or an empty one with just the B and T runtime symbols. Returns the design_id every other tool needs.

ParameterTypeDescription
namestringName for the new design. Defaults to the preset's name.
presetstringOne of: nano-sort, gpt2-small, gpt2-medium, gpt2-large, gpt2-xl, nanogpt, bloom-7b1, t5-small, flan-t5-base, llama-2-7b, mistral-7b, llama-3-8b, llama-3-70b, llama-3.1-405b, qwen2.5-7b, qwen3-8b, gemm…

tensorcad_open_design Open design

Load a .tensorcad.json document from disk and return a design_id for it. Opening the same path twice returns the same handle.

ParameterTypeDescription
path *stringPath to a .tensorcad.json file, absolute or relative to the server's directory.

tensorcad_save_design Save design

Write a design to disk as .tensorcad.json. Overwrites the file it was opened from unless a path is given.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
pathstringWhere to write. Defaults to the path it was opened from.

tensorcad_get_design Get design

Read a design. Use format "outline" (the default) first: it is the whole structure, symbol table and edge shapes in a fraction of the tokens. Use format "full" only when you need the literal JSON document.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
formatstring"outline" is a compact block/edge summary; "full" is the whole document.

tensorcad_get_block Get block

One block of a design: its parameters as written and as resolved, the inferred shape on every port, what each port is wired to, and how many trainable parameters it contributes.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
path *stringBlock path from the outline, e.g. "layers/block" or "embed".

tensorcad_search_catalog Search catalog

Search the block catalog. Returns each block's parameter schema, port patterns and documentation, which is what you need before adding a block with tensorcad_apply_ops.

ParameterTypeDescription
categorystringattention, mlp, norm, embedding, container, io, ...
kindstring
limitintegerDefault 20.
querystringSubstring matched against type, category, summary and formula.

tensorcad_apply_ops Apply edits

Apply a batch of edits to a design. The batch is all-or-nothing: the first rejected operation aborts it and the design is left untouched. Pass expected_revision to be told about a concurrent edit instead of silently overwriting it. Returns the new revision, what changed, and a fresh validation summary.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
ops *arrayEdits applied in order.
expected_revisionintegerRevision you last read. The call is rejected if the design has moved on.

tensorcad_validate Validate design

Run every design rule: shape and symbol errors, kernel-friendly head dimensions, tensor-core multiples, whether training and serving fit the chosen device, Chinchilla sanity and drift from published numbers. Each finding carries a fix hint.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
BintegerMicro-batch size.
SintegerSource length, for an encoder-decoder: the second sequence its encoder runs along. Defaults to the document's own S; ignored by a design that declares none.
TintegerSequence length. Defaults to the document's own T.
concurrencyintegerConcurrent sequences when serving.
dpintegerData parallel degree.
dtypestringTraining dtype. Default bf16.
epintegerExpert parallel degree.
gpusinteger
hardwarestringHardware id: h100-sxm, h200-sxm, b200, a100-80, rtx5080 or rtx4090. Default h100-sxm.
mfunumberModel FLOPs utilization, 0..1.
optimizerstring
packingobjectTraining rows packed with documents, for a design whose mask keeps them apart (doc(b, q) == doc(b, kv)). Moves the training figures and the cost, not serving.
ppintegerPipeline parallel degree.
recomputestring
severitystringOnly return findings at least this bad.
tokensnumberTraining token budget. Defaults to Chinchilla-optimal.
tpintegerTensor parallel degree.
zerointegerZeRO/FSDP sharding stage.

tensorcad_analyze Analyze design

Parameters, FLOPs per token, KV cache, training and serving memory, decode throughput, training cost and Chinchilla position, for a given sequence length, batch, dtype, device, GPU count and parallel plan.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
BintegerMicro-batch size.
SintegerSource length, for an encoder-decoder: the second sequence its encoder runs along. Defaults to the document's own S; ignored by a design that declares none.
TintegerSequence length. Defaults to the document's own T.
concurrencyintegerConcurrent sequences when serving.
dpintegerData parallel degree.
dtypestringTraining dtype. Default bf16.
epintegerExpert parallel degree.
gpusinteger
hardwarestringHardware id: h100-sxm, h200-sxm, b200, a100-80, rtx5080 or rtx4090. Default h100-sxm.
mfunumberModel FLOPs utilization, 0..1.
optimizerstring
packingobjectTraining rows packed with documents, for a design whose mask keeps them apart (doc(b, q) == doc(b, kv)). Moves the training figures and the cost, not serving.
ppintegerPipeline parallel degree.
recomputestring
tokensnumberTraining token budget. Defaults to Chinchilla-optimal.
tpintegerTensor parallel degree.
zerointegerZeRO/FSDP sharding stage.

tensorcad_generate_code Generate code

Emit a runnable PyTorch module plus the design document. Without out_dir the file contents come back in the result; with out_dir they are written to disk and only a manifest comes back.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
class_namestringClass name for the top-level module.
include_smoke_testbooleanEmit a __main__ block that checks the size.
out_dirstringDirectory to write into. Omit to get the contents inline.

tensorcad_checkpoint Checkpoint design

Snapshot a design under a name you can come back to. Take one before an experiment so tensorcad_restore can put it back exactly.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
labelstringWhat this snapshot is, e.g. "before widening the FFN".

tensorcad_restore Restore design

Put a design back. With a checkpoint_id it restores that snapshot; without one it undoes the most recent tensorcad_apply_ops batch. Either way the revision moves forward, so a stale expected_revision still fails.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
checkpoint_idstringOmit to undo the last batch of edits.

tensorcad_explain Explain a block

What one block is and what it contributes: its parameters as written and as evaluated, the shape on every port, its share of the model's weights and compute, and its documentation. Use it to answer "why is this block this size" without reading the whole design.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
path *stringFull path of the block, e.g. "layers/block/attn".
BintegerMicro-batch size.
SintegerSource length, for an encoder-decoder: the second sequence its encoder runs along. Defaults to the document's own S; ignored by a design that declares none.
TintegerSequence length. Defaults to the document's own T.
concurrencyintegerConcurrent sequences when serving.
dpintegerData parallel degree.
dtypestringTraining dtype. Default bf16.
epintegerExpert parallel degree.
gpusinteger
hardwarestringHardware id: h100-sxm, h200-sxm, b200, a100-80, rtx5080 or rtx4090. Default h100-sxm.
mfunumberModel FLOPs utilization, 0..1.
optimizerstring
packingobjectTraining rows packed with documents, for a design whose mask keeps them apart (doc(b, q) == doc(b, kv)). Moves the training figures and the cost, not serving.
ppintegerPipeline parallel degree.
recomputestring
tokensnumberTraining token budget. Defaults to Chinchilla-optimal.
tpintegerTensor parallel degree.
zerointegerZeRO/FSDP sharding stage.

tensorcad_scale Scale a design

Shrink a design towards a parameter budget while keeping its proportions, and save the result as a new design. Use it to get a bench-sized proxy of a large architecture: the widths and depth move together, the head dimension stays sane, and the result is reported with how close it landed.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
target_params *numberThe parameter count to aim for.
keep_depthbooleanHold the layer count fixed and move only the width.
target_basisstringWhether target_params counts the embedding tables. At bench sizes "non-embedding" is usually meant.
tie_headbooleanShare the output projection with the embedding.
vocabintegerReplace the vocabulary, for a smaller tokenizer.

tensorcad_mup Build a width ladder

The same design at several widths, with what to multiply the initialization and the learning rate by at each, following Tensor Programs V. Sweep hyperparameters at the narrow end and carry the answer up: a learning rate tuned at the base rung is the right one at every rung, scaled per class. Every rung is saved as a design of its own, ready to analyze or generate. It does not choose a learning rate; that is what the sweep is for.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
base_widthnumberThe width the sweep happens at. Omit for the narrowest.
widthsarrayThe widths to build. Omit to halve the design's own width down to a width worth sweeping at.

tensorcad_plan Plan a cluster

Every way of splitting the training across a cluster that fits, least demanding first. Prices data, tensor, pipeline and expert parallelism, the four ZeRO stages, sequence parallelism and the three recompute settings. Memory is the claim and it is arithmetic; which plan is fastest is not claimed, so each one carries a note about what it costs to run.

ParameterTypeDescription
design_id *stringHandle returned by tensorcad_new_design or tensorcad_open_design, e.g. "dsn_1".
gpus *integerHow many devices there are.
BintegerMicro-batch size.
SintegerSource length, for an encoder-decoder: the second sequence its encoder runs along. Defaults to the document's own S; ignored by a design that declares none.
TintegerSequence length. Defaults to the document's own T.
concurrencyintegerConcurrent sequences when serving.
dpintegerData parallel degree.
dtypestringTraining dtype. Default bf16.
epintegerExpert parallel degree.
gpus_per_nodeintegerBounds the tensor-parallel degree. Default 8.
hardwarestringHardware id: h100-sxm, h200-sxm, b200, a100-80, rtx5080 or rtx4090. Default h100-sxm.
headroomnumberFraction of device memory left free. Default 0.1.
limitintegerHow many plans to return. Default 8.
mfunumberModel FLOPs utilization, 0..1.
optimizerstring
packingobjectTraining rows packed with documents, for a design whose mask keeps them apart (doc(b, q) == doc(b, kv)). Moves the training figures and the cost, not serving.
ppintegerPipeline parallel degree.
recomputestring
tokensnumberTraining token budget. Defaults to Chinchilla-optimal.
tpintegerTensor parallel degree.
zerointegerZeRO/FSDP sharding stage.

tensorcad_diff Compare two designs

What changed between two designs and what it cost: the symbols, blocks and wires that moved, then the parameters, FLOPs, cache and memory. Both sides are measured at one operating point, so the attention terms are comparable. Use it after an edit, or against a preset, to check the change did what was meant.

ParameterTypeDescription
a *stringThe design to compare from.
b *stringThe design to compare to.
BintegerMicro-batch size.
SintegerSource length, for an encoder-decoder: the second sequence its encoder runs along. Defaults to the document's own S; ignored by a design that declares none.
TintegerSequence length. Defaults to the document's own T.
concurrencyintegerConcurrent sequences when serving.
dpintegerData parallel degree.
dtypestringTraining dtype. Default bf16.
epintegerExpert parallel degree.
gpusinteger
hardwarestringHardware id: h100-sxm, h200-sxm, b200, a100-80, rtx5080 or rtx4090. Default h100-sxm.
mfunumberModel FLOPs utilization, 0..1.
optimizerstring
packingobjectTraining rows packed with documents, for a design whose mask keeps them apart (doc(b, q) == doc(b, kv)). Moves the training figures and the cost, not serving.
ppintegerPipeline parallel degree.
recomputestring
tokensnumberTraining token budget. Defaults to Chinchilla-optimal.
tpintegerTensor parallel degree.
zerointegerZeRO/FSDP sharding stage.

tensorcad_import_hf Import a Hugging Face config

Read a Hugging Face `config.json` into a design and save it in this session. Covers the Llama, Mistral, Qwen, Gemma, Mixtral, DeepSeek and GPT-2 families. Anything the importer cannot model faithfully comes back as a warning rather than being approximated silently.

ParameterTypeDescription
config *stringThe contents of config.json.
namestringA name for the design; the config's own is used otherwise.