> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infercrane.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Right-size your model (design)

> Serve a workload on a smaller model trained on your current model's answers to your own prompts, inside your account, and switch only after your traffic proves quality holds. A design, not built.

# Right-size your model

Many workloads run on a model far larger than they need. A model a quarter of the size, trained on
your current model's answers to your own prompts, may serve the same workload on fewer GPUs and
answer faster. This design moves a workload to that smaller model only when a check on your own
traffic says quality holds, and always with the large model kept as the fallback until you retire
it.

> [!WARNING]
>
> This is a design for what comes next. Built today: [evals from your own
> traffic](https://docs.infercrane.com/features/evals-from-your-traffic.md), the dataset manifests and their registration, and the
> tokenizer check on the KL reading. Everything
> else on this page is planned. No smaller model has been trained or proven through InferCrane, so the
> savings, speed, and quality of a right-sized model are **unknown** until a run measures them. Model and dataset facts below were read on 2026-11-26
> from their Hugging Face cards and API; read them again before a run.

## The question it answers

"Can a smaller model do this workload at the quality you need, and what does it save?" The answer
is one of three, as in a [migration Proof](https://docs.infercrane.com/features/migration.md):

| Answer | Meaning |
| - | - |
| **Switch** | A signed PASS on your graded set, with the smaller model's measured cost and speed on your traffic |
| **Do not switch** | BLOCK: the quality drop is above your margin |
| **Not known yet** | UNKNOWN, with what is missing: too few graded prompts, an interval that straddles the margin, a proof set that overlaps the training set, or a measurement that did not settle |

## Two ways in, one proof

The smaller model can come from two places, and the proof treats them the same:

1. **Right-sizing in your account**: InferCrane's fine-tune on your current model's answers to your
   prompts, with open tools (steps 3 to 5 below).
2. **A model trained anywhere else**: a training service, a partner, or your own team trains a model
   or LoRA adapter and brings it through today's [model import](https://docs.infercrane.com/features/model-artifacts.md). A
   provenance file that names its base, teacher, data, and licence is planned.

Both come in through the same model import, enter the same proof, and roll out the same way.
InferCrane does not run post-training such as reinforcement learning; that stays with the trainer
you choose.

## What it builds on

| Part | State | Used for |
| - | - | - |
| Migration Proof: graded check, paired bootstrap verdict, signed PASS/BLOCK/UNKNOWN, canary, primary, rollback (`internal/qualitycheck`, `internal/controlapi/migration_proof.go`) | Built, for a baseline that is a closed API or a deployment the control plane reaches; not yet one served through the agent in your own cloud | The proof and the staged switch |
| [Task sets](https://docs.infercrane.com/features/semantic-quality.md#task-sets) and the paired task comparison (`qualitycheck.PairedTask`) | Built | A general-ability guard beside your graded set |
| [Divergence](https://docs.infercrane.com/features/semantic-quality.md#divergence-of-a-precision-change) (forced-decoding KL, top 16) | Built, evidence only; read only when both servers' tokenizer files match | How far the student is from the teacher, token by token |
| Agent-local eval sets (`local:NAME`, Helm `executor.evalSets`) | Built | Proof prompts that never leave your cluster |
| [LoRA adapters](https://docs.infercrane.com/features/model-artifacts.md#lora-adapters) and [weights in your own bucket](https://docs.infercrane.com/features/model-artifacts.md#weights-in-your-own-bucket) | Built | Serving the trained student |
| Prompt capture and the bounded training Job ([drafts trained on your traffic](https://docs.infercrane.com/features/trained-drafts.md)) | Job built; capture designed, not built | The same capture and the same Job shape |
| Provenance (`optimizedartifact` plan and attestation) | Built, four kinds | A new kind for a distilled checkpoint |
| [Evals from your own traffic](https://docs.infercrane.com/features/evals-from-your-traffic.md): a task set built from graded requests, with a held-out split and an overlap check | Built | The graded set the proof is gated on |
| A Data area for evaluation and training sets | Partly built: [Data](https://docs.infercrane.com/architecture/data-area) | Where sets, licences, and retention live |
| [Model imports](https://docs.infercrane.com/features/model-artifacts.md) | Built; a provenance file for trained models is planned | How a student from either source comes in |
| Reviewed licences as data | Planned | Which licences may serve, teach, or train, and their obligations |

## The flow

```text theme={"theme":"css-variables"}
1 current model -> 2 smaller candidates -> 3 data source -> 4 teacher answers
  -> 5 fine-tune -> 6 prove on your traffic -> 7 canary, primary, retire (rollback at any step)
```

### 1. Pick the current model

The current model is a binding on an endpoint: an open model you serve (the usual case), or a
closed API. Its traffic shape is already recorded per binding (`request_records.binding_id`).

When the current model is a closed API, right-sizing does not train on its answers by default:
most closed-API terms restrict using outputs to build another model, and InferCrane cannot read
your contract. Move to an open model first with a [migration Proof](https://docs.infercrane.com/features/migration.md), then
right-size from that model. Training on a closed API's answers is a decision for you and your
counsel, recorded on the dataset (see [Data](https://docs.infercrane.com/architecture/data-area#who-wrote-the-content)).

### 2. Pick smaller candidates

Candidates are listed in this order and filtered:

1. **The current model's own family, same tokenizer.** The student starts from the same chat
   template, and the [KL reading](#the-proof) is possible only when both models read text into the
   same tokens.
2. **Popular families next: Qwen, then DeepSeek, then GLM**, by downloads in the last 30 days.
3. **Filters:** a licence the checkpoint catalog approves for serving (Apache-2.0, MIT, or
   BSD-3-Clause today, `checkpointcatalog/policy.json`); an architecture the
   runtime registry serves; at most half the current model's active parameters (otherwise it is
   not right-sizing); fits the target GPU with room for the KV cache.

Read on 2026-11-26 (parameters from the safetensors header, downloads over 30 days):

| Model | Parameters | Licence | Tokenizer group | Downloads |
| - | - | - | - | - |
| `Qwen/Qwen3-0.6B` | 0.75B | Apache-2.0 | Qwen3 | 14.4M |
| `Qwen/Qwen3-1.7B` | 2.0B | Apache-2.0 | Qwen3 | 2.7M |
| `Qwen/Qwen3-4B` | 4.0B | Apache-2.0 | Qwen3 | 3.0M |
| `Qwen/Qwen3-8B` | 8.2B | Apache-2.0 | Qwen3 | 5.9M |
| `Qwen/Qwen3-14B` | 14.8B | Apache-2.0 | Qwen3 | 13.4M |
| `Qwen/Qwen3-32B` | 32.8B | Apache-2.0 | Qwen3 | 3.7M |
| `Qwen/Qwen3.5-4B` | 4.7B | Apache-2.0 | Qwen3.5 | 3.7M |
| `Qwen/Qwen3.5-9B` | 9.7B | Apache-2.0 | Qwen3.5 | 6.0M |
| `Qwen/Qwen3.6-27B` | 27.8B | Apache-2.0 | Qwen3.5 text, own chat template | 2.3M |
| `Qwen/Qwen3.6-35B-A3B` | 36.0B, about 3B active | Apache-2.0 | Qwen3.5 text, own chat template | 3.2M |
| `Qwen/Qwen3.8-27B` | 27.8B | Apache-2.0 | its own | 6.0M |
| `deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B` | 1.8B | MIT | Qwen2.5-based | 0.4M |
| `deepseek-ai/DeepSeek-R1-Distill-Qwen-7B` | 7.6B | MIT | Qwen2.5-based | 0.3M |
| `zai-org/GLM-4.7-Flash` | 31.2B | MIT | GLM | 1.1M |

Tokenizer groups were read by comparing the files' hashes: `tokenizer.json`, `vocab.json`, and
`merges.txt` are identical across Qwen3 0.6B to 32B, and so is `tokenizer_config.json` (which
holds the chat template). Qwen3.5 4B and 9B and Qwen3.6 share another `tokenizer.json`, but Qwen3.6's
chat template differs from Qwen3.5's. Qwen3.8-27B has a `tokenizer.json` of its own.

The current DeepSeek and GLM releases are large (DeepSeek-V4-Flash 291B, GLM-5.3-Flash 321B, both
MIT). They are teachers more often than students. A student for them usually comes from the Qwen
family, with a different tokenizer, so the proof relies on graded and task sets and the KL reading
stays unknown.

### 3. Choose a data source

| Source | What it is | Where it lives |
| - | - | - |
| **Your traffic** | Prompts sampled from an endpoint after an operator turns capture on. The same capture [trained drafts](https://docs.infercrane.com/features/trained-drafts.md#capture-from-an-endpoint-designed-not-built) use; one capture serves both | A volume or bucket in your account |
| **A file you own** | Prompts, or prompt and answer pairs you already keep (for example, answers your staff reviewed) | A volume, a bucket, or a private repository of your organisation |
| **Reviewed open datasets** | A catalog entry with its licence checked, pinned to a commit | Copied into your storage by a job in your account |

Every set is described by a [dataset manifest](https://docs.infercrane.com/architecture/data-area#the-manifest): counts,
digests, licence, retention, and location. Its text never reaches InferCrane. Open datasets fill
gaps (a guard set, or a warm start); the student learns your workload from your traffic.

### 4. Generate teacher answers

The current model answers every training prompt inside your account: a batch Job sends the prompts
to your current deployment (or a replica started for the job), with greedy decoding and the
production system prompt, thinking mode, and answer limit. Running at a quiet hour keeps it from
competing with live traffic. The answers stay in the job's working volume and are deleted when the
job ends, unless the operator keeps them as a pairs set with its own expiry.

Prompts are captured, answers are not. Capture keeps one retention promise for both drafts and
right-sizing, and the answers always come from the exact model and revision being replaced.

### 5. Fine-tune

The student trains in your cluster in a bounded Job, the same shape as `speculator.TrainingJob`:
a trainer image pinned by digest that the operator allows, the data mounted read-only, no service
account token, a non-root user, `backoffLimit: 0`, a deadline, and deletion after it ends.

| Method | When | Tokenizer |
| - | - | - |
| **LoRA SFT on teacher answers** (default) | Most workloads; the least training compute; served as an adapter on the base model | Any |
| **Full SFT on teacher answers** | LoRA does not close enough of the gap on the held-out set | Any |
| **On-policy distillation** (later) | The student writes, the teacher scores each token | Same tokenizer only |

Tools, all open source: Hugging Face Transformers, TRL (`SFTTrainer`, and its GKD
trainer for on-policy distillation), PEFT for LoRA, and Accelerate (all Apache-2.0); PyTorch FSDP for
multi-GPU full SFT (BSD-3-Clause). Exact versions are pinned in the trainer image and read from
the package index on the day the image is built.

The Job writes a numbers-only report (schema decoded with unknown fields refused, as the draft
report is): base model and revision, method, LoRA rank, epochs, examples and tokens, the dataset
fingerprint, training and held-out loss, the files and their sha256, and the artifact digest. The
student is kept where you keep the data: a LoRA adapter or merged weights in your bucket, pinned by
manifest digest, or a private repository of your organisation, pinned by commit. Both serve today.
The Job will also record its provenance beside the files (who trained it, the teacher, the training
sets by digest), so the student is imported exactly as a model trained elsewhere would be.

A student trained on your prompts can reproduce phrases it saw often. Keep it under the same
access as the prompts and delete it when you delete them (see
[Data](https://docs.infercrane.com/architecture/data-area#retention)).

### 6. Prove on your traffic

See [The proof](#the-proof). Nothing switches without a signed PASS.

### 7. Roll out in stages

| Step | Routing | Admitted on |
| - | - | - |
| canary | weighted: the student at most 5%, the current model the rest | The signed PASS for that student's revision |
| primary | primary-fallback: the student first, the current model as fallback | Release Guard on the two bindings' requests from the canary |
| retire | the student alone (`infercrane migrate finish`, built), then the current model's deployment scaled down by you | The operator, after primary while the student is ready (built); a hold period (default 7 days at primary with Release Guard healthy) is planned |
| rollback | the current model alone | While the current model can still serve (built). After finish there is no rollback step: going back is a new migration |

Savings begin at **retire**, when the large model's GPUs are released. Until then you pay for
both. After retire, a scheduled check re-runs the graded set on new traffic; a BLOCK there raises a
rollback alert, never a silent switch.

## The proof

The student is compared with the current model, which is the reference, on the same prompts with
greedy decoding.

| Reading | Role | From |
| - | - | - |
| **Graded set from your traffic** | **The gate.** PASS, BLOCK, or UNKNOWN by the migration rule: paired bootstrap, 10,000 resamples, 95% interval, fixed seed, your margin (default 5%), at least 30 prompts | [Evals from your own traffic](https://docs.infercrane.com/features/evals-from-your-traffic.md): requests you graded with a number, a letter, or a label |
| **Task set guard** | Must not be `worse` than the untrained student; a `worse` verdict needs an operator's acknowledgement before the canary | A public set from the [catalog](https://docs.infercrane.com/architecture/data-area#open-dataset-catalog-planned) |
| **KL to the teacher** | Evidence, never a gate: generation mean KL on held-out prompts, before and after training | `qualitycheck.MeasureDivergence`, same tokenizer only |
| **Speed and cost** | Measured like any setup: each on its own server, in the same window as the control, on your replayed traffic shape | The optimization run |
| **Overlap check** | Built: the task-set build removes requests that overlap an item from the training side. Planned: a proof set that overlaps a training set makes the verdict UNKNOWN | The task-set build, on your machine |

Rules that keep the proof honest:

* **Time split.** The proof set comes from traffic captured after the training window ended.
* **Overlap.** The task-set build compares every request before the split with the held-out items
  on what the user sees (system prompts left out): the same words (exact), a shared run of 13 words
  (near), or a whole item of 4 to 12 words inside the request. It removes them from the training
  side and reports counts only (built). It does not find an item asked again in other words, an item
  of 3 words or fewer inside a longer request, a short request that is only part of a longer item,
  or an item's text inside another request's system prompt, so those may still be trained on. For a model trained on other data, its
  training sets are compared the same way before the proof (planned): any exact overlap, or near
  overlap above 1% of the proof set, makes the verdict UNKNOWN.
* **Same tokenizer for KL.** The divergence check compares token IDs, so it reads KL only when both
  servers' tokenizer files are known to be the same (built). Otherwise KL is unknown, with that
  reason. KL between a large and a small model is expected to be far above a precision change's,
  so no threshold is set.
* **Binding.** The verdict binds the student's artifact digest, the training and proof sets'
  fingerprints, the reference's revision, and both sides' evidence digests.

## Where each step runs and who holds the data

Right-sizing on your traffic needs an InferCrane agent in your cluster serving the endpoint
(`customer-cloud`). The hosted gateway never captures, and training on traffic of hosted or
dedicated endpoints is out of scope until there is a written data-processing promise for it.

| Step | Runs in | Holds text | InferCrane's control plane sees |
| - | - | - | - |
| 1. Current model | Control plane | Nothing | Endpoint, binding, model, revision |
| 2. Candidates | Control plane (catalog, model check) | Nothing | Candidate list, licences, sizes, tokenizer digests |
| 3. Capture | The agent's data plane, your cluster | Your volume or bucket | On or off, counts, bytes, oldest age, digest of record IDs |
| 3. Open dataset | A download job in your account | Your volume or bucket | The manifest: repository, commit, licence, counts |
| 4. Teacher answers | A Job in your cluster, on your current deployment's GPUs | The job's volume, deleted at the end | Counts, tokens, GPU seconds, digests |
| 5. Fine-tune | A Job in your cluster | Your volume; the student in your bucket or private repository | The report: numbers and digests |
| 6. Proof | The agent's executor in your account, with `local:` sets | Your cluster | Per-prompt scores, verdicts, KL reading, digests (as today) |
| 7. Rollout | The agent's data plane | Requests in flight only | Request shapes and Release Guard figures (as today) |

The invariant "prompts, completions, and request content never leave an agent's machine or
cluster" holds as written. Every new field the control plane receives is a count, a digest, a
licence identifier, or a time.

## What it costs, per model size

A run has three parts. All figures are **estimates** from the formulas below, not measurements.

* **Teacher answers:** answer tokens ÷ your deployment's output tokens per second at load. The
  optimization run already measures that figure for your deployment.
* **Training:** about 4 × parameters × tokens processed for LoRA, 6 × for full SFT (active
  parameters for a mixture of experts), divided by the GPU's dense BF16 peak times the share of it
  training reaches. The share is assumed: 35% on an H100, 30% on an L40S or L4. It is unmeasured.
* **Proof:** the same as a migration run: each candidate's GPU time for the replay windows and the
  checks. A run's spend cap bounds it; it is unknown until a right-size run is measured.

Assumed set: 10,000 conversations of about 2,000 tokens each (20 million tokens, half of them
answers), trained for 2 epochs (40 million tokens processed). Dollars at an on-demand list price
read on 2026-11-26 that includes CPU and memory: \$4.71 an H100 hour. Your own price replaces it.

| Student | LoRA, H100 hours | LoRA, dollars | Full SFT, H100 hours | GPUs full SFT needs (about 16 bytes a parameter) |
| - | - | - | - | - |
| Qwen3-1.7B | 0.26 | \$1.23 | 0.39 | 1 |
| Qwen3.5-4B | 0.60 | \$2.82 | 0.90 | 1 to 2 |
| Qwen3-8B | 1.05 | \$4.95 | 1.58 | 2 to 4 |
| Qwen3.5-9B | 1.24 | \$5.84 | 1.86 | 2 to 4 |
| Qwen3-14B | 1.90 | \$8.93 | 2.84 | 4 |
| Qwen3.8-27B | 3.57 | \$16.80 | 5.35 | 8 |
| Qwen3-32B | 4.21 | \$19.81 | 6.31 | 8 |
| Qwen3.6-35B-A3B (about 3B active) | 0.39 or more | \$1.81 or more | 0.58 or more | 8 |

A mixture of experts trains well below the dense share, so its row is a floor. LoRA fits one GPU up
to about 14B on an L40S (48 GB) and about 32B on an H100 (80 GB) with activation checkpointing.

Teacher answers for 10 million answer tokens, from the bandwidth roofline at 64 requests at once
and half its rate (estimates, unmeasured):

| Teacher | Tokens a second | Hours | Dollars |
| - | - | - | - |
| Qwen3-8B, BF16, one L40S (\$2.40 an hour, GPU price assumed) | about 1,700 | 1.7 | about \$4 |
| Qwen3-32B, FP8, one H100 | about 3,300 | 0.85 | about \$4 |
| A 300B-class MoE on 8 GPUs | unknown | unknown | unknown |

So training a small student costs a few GPU-hours. The decision rests on the proof and on serving
cost after retire, which is measured, not estimated.

## What has to be built

1. **The rest of the open-model baseline for the Migration Proof.** A deployment you serve on the
   endpoint can be the baseline when the control plane reaches it (built). Still to build: a
   baseline served through the agent in your own cloud, its price from its GPU hours (its cost is
   unknown today), and scaling the current model down after `migrate finish` (today you do that
   yourself).
2. **Capture in the agent's data plane**, shared with trained drafts, and the
   [Data area](https://docs.infercrane.com/architecture/data-area).
3. **Two Job specs and a trainer image**: teacher answers and fine-tuning, bounded like
   `speculator.TrainingJob`, with numbers-only reports.
4. **An artifact kind for a distilled checkpoint** (`optimizedartifact`, tool `trl`). The store's
   kind check needs a new forward-only migration.
5. **The overlap check for imported models**, whose training sets come from elsewhere (the build
   already does it for sets cut from your traffic).
6. **A provenance file for model imports**: the base, teacher, training data, and licence of a
   trained model, read by the model import that exists, so there is one import path.
7. **Dashboard:** one screen per step (pick, data, train or bring a model, prove, switch); depth
   such as KL and fingerprints under Advanced.

Nothing here makes the control plane read text, and nothing branches on a provider or runtime name.

## What is unknown

* Whether a smaller model holds quality on any given workload. That is what the proof answers.
* Savings: they depend on the GPUs before and after and on your traffic, and exist only after
  retire.
* How many examples a workload needs. 10,000 conversations is a starting assumption.
* Training and teacher throughput on each GPU; the shares in the cost formulas are assumed.
* How much of the gap LoRA closes compared with full SFT, per size, and whether training on
  teacher answers is enough or on-policy distillation is needed. Qwen3's own small models were
  already distilled from larger ones by their publisher, so gains on general chat may be small; a
  narrow workload is where right-sizing is expected to matter, unmeasured.
* Thinking models: answers with reasoning are long, so teacher and training cost scale with them.
* Requests with tools: a graded set cannot hold tool cases today, so tool-calling workloads need a
  graded tool check first. Requests with images, audio, or tool results are not captured.
* How fast a right-sized model's quality falls as traffic changes.
* Legal: whether a closed API's terms allow training on its answers (default: not used); whether a
  share-alike licence reaches model weights (not decided; no such set is registered today); your own
  data-processing obligations for captured prompts.

## First proof: the ladder

Each rung's rules, pass bar, and spend cap are written before any server runs, and a result is
published only with its receipt.

| Rung | What | Cap |
| - | - | - |
| 0 | Offline on a laptop CPU, tiny random models and stand-in servers: data splits, overlap check, manifests, a 10-step LoRA run, the task comparison and verdict wiring, the tokenizer guard | \$0 |
| 1 | One L40S: Qwen3-8B teaches Qwen3-1.7B (LoRA) on public chat prompts (oasst1) and grade-school maths (GSM8K train); judged on GSM8K test, an MMLU guard, and KL on held-out chat | \$5.00 |
| 2 | End to end through the Migration Proof on the real control plane: Qwen3-8B served as the current model, the rung-1 student as the candidate, a 500-item graded set | \$6.00 |

Each rung climbs only when the one below passed its bar.

## Licences

| Component | Licence | Role |
| - | - | - |
| Transformers, TRL, PEFT, Accelerate | Apache-2.0 | Training |
| PyTorch (FSDP) | BSD-3-Clause | Multi-GPU training |
| vLLM | Apache-2.0 | Teacher answers, serving the student and its adapter |
| The Qwen models listed above | Apache-2.0 (cards read 2026-11-26) | Teachers and students |
| DeepSeek-V4-Flash, the DeepSeek R1 distills, GLM-4.7-Flash, GLM-5.3-Flash | MIT (cards read 2026-11-26) | Teachers and students |
| Axolotl, LLaMA-Factory | Apache-2.0 | Not in the reviewed trainer image (configuration layers over the same libraries); their adapters and weights come in through the model import |
| Unsloth | Apache-2.0 | Not used: it patches model code, which would put another reviewed layer between the pinned model and its training |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.