Needle 3 runs on watches, Raspberry Pis and phones. Each device has a different memory budget, so each wants a different model size. Training one model per size means several training runs, several files and a separate fine-tune for each. Needle 3 is one set of weights. Every depth from 2 to 20 layers is a trained model, and all of them run on the same engine. We call this an intelligence ladder.
Blocks and the residual stream
A transformer is a stack of blocks. Needle 3 has twenty, . They share one running vector, the residual stream. Block reads the stream, computes an update, and adds it:
Because each block only adds to the stream, skipping a block means adding nothing, the same fact that stochastic depth and LayerDrop use during training. The stream passes through unchanged and the model is simply shallower. Two questions remain: which blocks to skip, and how to make the shallow models good.
Which blocks make a subnetwork
A subnetwork of depth is a set of blocks, run in their original order. The sets must nest, , so that one set of weights serves all of them. The chosen blocks must also stay spread through the stack, so that a shallow model sees early and late computation rather than only the first few blocks.
One rule gives both. Start from the two ends, then repeatedly split the widest gap between chosen blocks at its midpoint:
with ties going to the leftmost gap. Each step only adds a block, so the sets nest. Each step halves the largest hole, so the coverage stays balanced.
Twenty blocks give one fixed sequence, . The subnetwork of depth is its first entries.
Running a subnetwork
With equal to 1 when block is in the set and 0 otherwise, the forward pass at depth is
followed by the same final normalisation and the same output layer as the full model.
Three details make this hold in the real architecture:
- Needle's residual stream has four parallel lanes, and blocks read and write them in round-robin order. Inside a subnetwork the order is renumbered over the blocks that remain, so consecutive surviving blocks still alternate lanes.
- The engram memory sites and the global-attention layers belong to specific blocks. They are kept when their block is kept and dropped when it is dropped.
- The KV cache is per block, so a shallower model also has a proportionally smaller cache.
Training every depth at once
Adding one loss term per depth to every training step would cost forward passes per step. Instead, each step samples one path. With probability it is the full model and the step is an ordinary language-modelling step. Otherwise a depth is drawn uniformly from , only the blocks in run, and the loss is scaled by the fraction of the model that took part:
is the next-token distribution at depth , is cross-entropy against the true next token, and is a stop-gradient: the full model's prediction is a fixed target on that step, and no gradient flows into it.
The KL term does most of the work for the shallow depths. Cross-entropy asks a 3-layer subnetwork to predict the next token, which it can barely do, and its gradient is small. The KL term asks it to predict what the whole network predicts. The full model is the teacher, each subnetwork is a student, and because they share every weight, the teacher costs no extra forward pass. This is self-distillation, with .
Each step trains one depth. Averaged over many steps, this gives the same expected loss as training every depth on every step, and it costs one forward pass instead of eighteen.
The ladder also improves the full model. We trained the same 18-layer architecture twice for 3,000 steps on the same data, once with the ladder and once without. With the ladder the full-depth validation loss was 1.958; without it, 2.037. The ladder model was ahead at every checkpoint, and its 16-layer exit alone matched the control's full 18 layers. Every prefix of the stack has to predict well on its own, so the early blocks cannot leave the work to the later ones, and no single block can become one the model depends on.
The numbers behind the figure. Bits per byte is the validation text loss in a unit that does not depend on the tokenizer; lower is better.
| run, 18 layers, 3,000 steps | validation loss (nats) | bits per byte at 18L | at 16L | at 12L | at 8L | at 4L | at 2L |
|---|---|---|---|---|---|---|---|
| control, full depth only | 2.037 | 0.686 | |||||
| ladder from step 0 | 1.958 | 0.660 | 0.689 | 0.769 | 0.855 | 0.991 | 1.538 |
| ladder switched on late in training | 2.059 | 0.694 | 0.736 | 0.836 | 0.908 | 0.996 | 1.675 |
Two things follow. The ladder costs the full model nothing and gains it 0.079 nats, 3.9% of the loss. And the ladder has to be there from the start: switching it on late gives worse subnetworks at every depth and a slightly worse full model, 1.1% above the control, because the blocks have already specialised around a fixed depth.
What each depth of the ladder-trained model keeps and what it costs, against its own full depth. The parameters kept are the surviving blocks with the engram sites and the confidence rows that belong to them; the embeddings and the final layers are shared by every depth.
| depth | 18L | 16L | 12L | 8L | 4L | 2L |
|---|---|---|---|---|---|---|
| parameters kept | 100% | 93% | 80% | 55% | 31% | 24% |
| bits per byte | 0.660 | 0.689 | 0.769 | 0.855 | 0.991 | 1.538 |
| loss change | +4.4% | +16.7% | +29.6% | +50.3% | +133% |
Down to 4 layers the loss grows more slowly than the parameters shrink. At 2 layers it more than doubles.
What each depth scores
Every depth from 2 to 20 layers ships in the one Needle 3 file, and needle build --layers picks any of them. We benchmarked four of them on two tool-calling suites, sliced from the same checkpoint and run through the same engine with the confidence gate on.
The 2-layer subnetwork is absent because at 2 layers the base model's confidence head withholds almost every call, so its gated score is zero, and with calls forced it scores 20.5 on DroidCall. Two layers of a generalist is not a product. Two layers fine-tuned on one product's tools is, which is the next figure.
Fine-tuning lifts every depth by 18 to 36 points on DroidCall, and from 4 layers up the tuned subnetwork passes DeepSeek V4 Flash. The 2-layer model goes from unusable to 56.5. A small network trained on one narrow task reaches frontier accuracy on that task, and the ladder is what lets you choose how small.
Fine-tune once, deploy any depth
Because the subnetworks share weights, one fine-tune is a fine-tune of all of them. The LoRA adapter is trained on the frozen base at the full 20 layers, merged into the weights, then sliced:
where is the low-rank update and keeps the blocks in , the engram tables of their sites, and the rows of the confidence head that belong to them.
A sliced model has its own block numbering, 0 to 15 for a 16-layer slice. Running the bisection rule on that numbering picks a different set of blocks from the parent's, blocks that were never trained together as a subnetwork. Of the 14 depths of a 16-layer slice, 13 differ between the two rules.
So every slice carries its parent's selection order, and slicing a slice equals slicing the original. In the Python package:
needle finetune data.jsonl --epochs 10 --out adapter.safetensors
needle build --lora adapter.safetensors --layers 8 --platform linux-arm64 --out ./piThe same ladder exists along width, where each sampled subnetwork is a depth and a channel prefix of every matrix, as in Matryoshka representations and MatFormer. The shipped Needle 3 exposes depth.
What it costs
At training time, a sampled step is cheaper than a full step, so the ladder adds no wall-clock time per step. The price is that 20% of steps update only part of the model, which the self-distillation term recovers.
At inference time there is no cost. A subnetwork of depth is exactly a -layer model in operations, in cache and in file size. The blocks are the same bytes at every depth, so file size is a straight line in .
A device can hold the full 29 MB file and choose a depth per request, a shallow pass for a simple command and the full stack for a hard one, with no second download. That part is not shipped yet.
References
- He et al., Deep Residual Learning for Image Recognition, 2015.
- Huang et al., Deep Networks with Stochastic Depth, 2016.
- Fan et al., Reducing Transformer Depth on Demand with Structured Dropout, 2019.
- Hinton et al., Distilling the Knowledge in a Neural Network, 2015.
- Kusupati et al., Matryoshka Representation Learning, 2022.
- Devvrit et al., MatFormer: Nested Transformer for Elastic Inference, 2023.
- Cai et al., Once-for-All: Train One Network and Specialize it for Efficient Deployment, 2019.
- Hu et al., LoRA: Low-Rank Adaptation of Large Language Models, 2021.
