Skip to main content
Most users never write a spec: the Model Specs on Spec Hub are written by us or by model vendors. Read this page if you need a spec for a model that is not on the Hub yet, or a private spec for an unreleased model.

Draft from a reference implementation

spec new reads a graph exported with torch.export. It strips engineering nodes (KV-cache updates, device and dtype moves, views that only reorganise memory, backend branches) and maps recognised subgraphs onto Op Specs: Unrecognised compute nodes are kept as placeholders marked -- REVIEW:. The draft is a starting point: publish it only after a human review and a conformance check.

How models are defined in the library

The spec library (specs/) defines each architecture family as a function from its Hugging Face hyperparameters to a model configuration (ModelCfg). That is where the architecture knowledge lives: which norms, which RoPE variant, which multipliers. specs/TheFormalEra/Spec/Families.lean has five families today: Qwen3Hyper, Qwen35Hyper, GraniteHyper, Gemma4Hyper and MuseHyper. A model is then one record of hyperparameters plus one registry entry (specs/TheFormalEra/Spec/Registry.lean):
Every family also has toHF, which renders the hyperparameters back in config.json form. The conformance check compares that rendering with the published config.json, field by field. To add a checkpoint of an existing family, add its record, a reduced record with the same layer pattern, and a registry entry. To add a new architecture, add a family. The compute graph (TheFormalEra.Models.Graph), the executable oracle and the CLI then pick it up.
The reduced configuration must have the same architecture: the same layer-type pattern, attention variants, norms and multipliers, at a small width. The theorem reduced_same_architecture checks this for every registry entry.

Check a spec package

spec check:
  1. runs lake build: the definitions type-check and every proof is checked;
  2. runs the axiom audit (Audit.lean): every listed theorem depends only on propext, Classical.choice and Quot.sound;
  3. exports each model’s graph and checks it is connected: every node input is produced by another node, except the graph’s inputs (tokens, positions, seq_lens) and cache values.

Check it against the reference implementation

This runs the official Hugging Face implementation against your spec, layer by layer, in float64. See Model conformance. The spec and the reference must agree before the spec is published.

Publish

See Publish specs. Published versions are immutable: publishing an existing version with a different digest is refused. Bump the version instead.