Vision transformers compare every image patch with every other patch. Doubling image resolution therefore multiplies attention cost by sixteen. A popular remedy is token pruning: partway through the network, drop or merge the patches that seem unimportant, so later layers work on a shorter sequence. The best learned pruners have a hidden dependency, though. DynamicViT trains a small network that decides which tokens to keep, and it stays accurate only because a separately trained, unpruned teacher network supervises it. That teacher has to exist before training starts and must be held in memory throughout. When no such teacher exists, as in training from scratch, in new domains, or at new resolutions, the method has nothing to lean on.
We propose to use the model as its own teacher. At each training step, the same weights run twice: once on all tokens with gradients switched off (a stop-gradient, meaning the output is treated as a fixed target), and once with pruning, with gradients on. The pruned pass is trained to match the full pass token by token, alongside the usual classification loss. Because of the stop-gradient, the full-token pass is never pulled toward the poorer pruned features. The weights therefore keep a good full-token mode while learning a good pruned mode. The full pass needs no backward computation, so the overhead is a single extra no-gradient forward pass, with no second network in memory. The result we aim for is a single set of weights that can be run at any keep rate, trained without any pretrained teacher.
Core Claim
Stop-gradient self-alignment between a model's full-token pass and its pruned pass can replace the external teacher that learned token pruning currently needs. It should also keep full-token accuracy intact when the two passes share weights. The stop-gradient is what makes the second property possible. Without it, the alignment loss is symmetric, and both passes can satisfy it by drifting toward each other, which means the full pass degrades.
Dual Perspectives on Non-Contrastive Self-Supervised Learning motivates this prediction. It proves that symmetric two-branch objectives collapse in the linear setting, while stop-gradient updates have stable non-collapsed equilibria. Our setting differs in one important way: the classification loss anchors the representation, so total collapse is unlikely. The failure we expect without stop-gradient is a milder "meet in the middle" degradation of the full-token pass, and that is the effect we will measure.
How it differs from prior work
LayerSync, Self-aligning Intermediate Layers, supplies the core technique. It aligns a shallow layer of a diffusion transformer to a deeper layer of the same model using patch-wise cosine similarity with a stop-gradient on the deep layer, and it reports 8.75× faster training. LayerSync aligns across depth and keeps the sequence length fixed. We instead align across sequence length, from a pruned pass to a full pass at the same layer, which is exactly the setting LayerSync leaves untouched.
This forces us to solve a correspondence problem LayerSync never faces: after pruning and merging, the token sets no longer match one-to-one. We handle it as follows. Each kept token is aligned to the detached full-pass token at the same position. Each merged summary token, in the style of EViT, is aligned to the attention-weighted mean of the detached full-pass tokens it absorbed.
DynamicViT supplies the token-selection machinery: a small network that scores tokens, trained with Gumbel-Softmax, pruning at three stages. It also defines the dependency we remove. Its teacher is a frozen, separate, pretrained model, whereas ours is the live model itself with gradients blocked.
Learning to Focus (LeaF) prunes text tokens using gradients from a 70B teacher and names self-improvement without such a teacher as future work. We address that gap in vision.
NAPE and Guided Stop-gradient show that stop-gradient targets work without momentum teachers in audio and instance-level learning. Neither changes sequence length.
Method
Take a plain vision transformer such as DeiT-S, with a token-scoring module inserted after blocks 4, 7 and 10, as in DynamicViT. For each image, compute two passes with the same parameters $\theta$:
- a no-gradient full pass producing token features $\bar z^{(l)}_i$ at layer $l$ and position $i$;
- a pruned pass producing features $z^{(l)}_j$ for the set $S_l$ of surviving tokens, which includes merged summaries.
The training loss is
$$\mathcal{L} = \mathrm{CE}(y, \hat y_{\text{pruned}}) + \lambda \sum_{l \in \mathcal{A}} \frac{1}{|S_l|}\sum_{j \in S_l} \Big(1 - \cos\big(z^{(l)}_j,\ \mathrm{sg}(\textstyle\sum_i w_{ji}\, \bar z^{(l)}_i)\big)\Big).$$
The terms are as follows. $\hat y_{\text{pruned}}$ is the pruned pass's prediction. $\mathcal{A}$ is the set of alignment layers, which are the blocks after each pruning stage plus the final block. $w_{ji}$ is one-hot for a kept token and holds the merge weights for a summary token. $\lambda$ is a scalar weight. $\mathrm{sg}$ blocks gradients.
A second variant adds a KL term between the pruned and full-pass class predictions, which matches DynamicViT's output distillation. An optional cross-entropy term on the full pass, which requires its own backward pass, is treated as an ablation rather than as part of the method.
Research Program
The work has three parts.
From-scratch training. We first establish that the method works where no teacher can exist: ImageNet-1K from scratch with pruning active from early in training, using a schedule that ramps the keep rate down.
Fine-tuning regime. We repeat DynamicViT's setting, starting from pretrained DeiT-S, to compare directly against published numbers.
Stop-gradient as the active ingredient. The analysis tracks full-pass accuracy of the shared weights throughout training, under three conditions: with stop-gradient, without it, and with a momentum (exponentially averaged) copy as the target. As a diagnostic for the instability described in Stabilizing Transformer Training by Preventing Attention Entropy Collapse, we also log attention entropy in the post-pruning blocks. That paper links sharply concentrated attention to divergence, and pruning plausibly concentrates attention by construction.
Dense prediction is a secondary test. ADE20K segmentation with the same backbone checks whether token-level alignment leaves pruned-pass features more usable for pixel decoders than classification-only pruning does.
Baselines
Unpruned DeiT-S. This is the naive reference point: the unpruned backbone trained with the same recipe and epochs. It sets the accuracy ceiling and the FLOP and throughput floor. DynamicViT reports 79.8% top-1 for DeiT-S.
Training-free Top-K. Top-K pruning by attention score with no extra training. Which Tokens to Use? reports that at a 90% keep rate, Top-K, EViT and ToMe "outperformed the baseline DeiT model by up to 0.5%". Any learned method must clearly beat this baseline at aggressive keep rates, where it is weakest. It will be run on the same checkpoints at matched FLOPs.
DynamicViT with its pretrained teacher. This is the strongest learned competitor. It reports a 37% FLOP reduction and 54% throughput gain on DeiT-S, with accuracy going from 79.8% to 79.3%. We will rerun it with the same selector, keep schedule, epochs, augmentation and an equal hyperparameter search budget, so the only difference is the target source.
EViT. This is the strongest selector-free competitor. It reports +50% throughput on DeiT-S, from 2923 to 4385 images/s, at a 0.3% top-1 cost. It will be fine-tuned under the same budget.
Success criteria. In fine-tuning, the method should match DynamicViT within 0.2 points at equal FLOPs, without the separate teacher, while using less peak memory. In from-scratch training, it should beat pruning trained with cross-entropy alone, for which no reported result was found on Lacuna. The shared weights' full-token accuracy should also stay within 0.3 points of the unpruned baseline.
Ablations. Four ablations isolate the key ingredient:
- removing the stop-gradient, so gradients flow into the full pass;
- replacing the live detached target with a momentum-averaged copy, as in BYOL;
- dropping the token-level term and keeping only output KL;
- swapping the learned selector for Top-K under our loss.
Why not just…?
Why not just use Top-K or EViT, which need no new loss? These methods are cheap and genuinely strong at mild keep rates. Which Tokens to Use? also reports that the tokens they select change with model size and transfer poorly to off-center tasks. Our Top-K-under-our-loss ablation settles whether the gain comes from the alignment target or from learning the selector. If plain EViT matches us at keep rates of 50% and below, the proposal's value reduces to the from-scratch regime, and we will say so.
Why not just keep the external teacher, as DynamicViT does? In the fine-tuning regime the teacher is simply the starting checkpoint, and this baseline may tie us on accuracy. Our claims there are about memory and the absence of a second network. The decisive case is from-scratch training and high-resolution training, where no matched teacher exists.
Why not just use a momentum teacher instead of a stop-gradient copy? This is the most serious threat, because exponentially averaged targets are the standard non-contrastive tool. We run it as a direct variant. If it matches the live stop-gradient target, the paper's finding becomes "a detached internal target, live or averaged, removes the teacher." That remains new relative to DynamicViT. NAPE's success without momentum teachers suggests the live target is enough and avoids the momentum copy's extra parameter memory.
Why not just stabilize training with σReparam? That paper notes its fix targets attention entropy collapse, not rank collapse. It also provides no supervision for the pruned pass. We will combine it with the cross-entropy-only pruning baseline to check whether stability alone closes the gap.
Decisive checks
The proposal rests on three experiments.
Fine-tuning equivalence. DeiT-S fine-tuning on ImageNet-1K at DynamicViT's 66% pruning. Our method must reach about 79.3% with no teacher.
From-scratch gap. DeiT-S trained from scratch with pruning active. Our method must beat cross-entropy-only pruning by a margin larger than seed variance across three seeds.
Stop-gradient ablation. Without the stop-gradient, the full-token accuracy of the shared weights should fall measurably below the stop-gradient version, while pruned accuracy changes little. If that drop does not appear, the dynamical-systems motivation does not carry over to this setting, and the method is ordinary self-distillation.
Wall-clock throughput will be reported alongside FLOPs. As FastV notes, variable-length sequences do not automatically translate FLOP savings into speed. ADE20K mIoU with a fixed decoder is the secondary test.
References
- DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification
- Dual Perspectives on Non-Contrastive Self-Supervised Learning
- LayerSync: Self-aligning Intermediate Layers
- EViT: Expediting Vision Transformers via Token Reorganizations
- Learning to Focus: Causal Attention Distillation via Gradient‐Guided Token Pruning
- Listening Forward: Next Patch Embedding Prediction Enables Scalable Audio Learners
- Implicit Contrastive Representation Learning with Guided Stop-gradient
- Stabilizing Transformer Training by Preventing Attention Entropy Collapse
- Which Tokens to Use? Investigating Token Reduction in Vision Transformers
- Bootstrap Your Own Latent - A New Approach to Self-Supervised Learning
- An Image is Worth 1/2 Tokens After Layer 2: Plug-and-Play Inference Acceleration for Large Vision-Language Models