# Hidden State Mixing and Gradient Detach

> Source: https://aiwiki.ai/wiki/hidden_state_mixing_and_gradient_detach
> Updated: 2026-11-29
> Categories: AI Inference, Model Architecture
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "Hidden State Mixing and Gradient Detach." aiwiki.ai, 29 Nov 2026. https://aiwiki.ai/wiki/hidden_state_mixing_and_gradient_detach
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

**Hidden state mixing (HSM)** and **hidden state gradient detach (HSGD)** are two ways to train a drafter for [speculative decoding](https://aiwiki.ai/wiki/speculative_decoding). NVIDIA researchers introduced them in a November 2026 preprint on drafters that use the target language model's hidden states. HSM changes which hidden states the drafter receives during training. HSGD changes where gradients flow during training. Both leave the inference procedure unchanged.[1]

## Why training and inference differ

A recurrent [multi-token prediction](https://aiwiki.ai/wiki/multi_token_prediction) drafter predicts several tokens before the target model checks them. The next draft step can use hidden states from earlier draft steps. At inference, its attention can see a prefix made from target-model states followed by a tail made from the drafter's own states. Conventional training typically exposes a draft step to a sequence of states from the target alone or from one earlier draft step. The difference can matter more later in a draft, when the drafter must rely on more of its own output.[1]

EAGLE-3's training-time test explicitly recreates this mixed context during training. HSM approximates the exposure using states the training process already computes.[1][2]

## How the methods work

HSM aligns the target's states and the states from earlier draft steps so that the candidates at a given position predict the same token. One implementation samples a source independently at each position. A second starts with the target states and replaces randomly selected positions after each draft step, replacing fewer positions at later steps. NVIDIA publishes HSM code in Megatron-LM and NVIDIA Model Optimizer.[1][3][4]

HSGD randomly stops backpropagation through selected connections between draft steps and through the token embeddings supplied to those steps. The values reaching a step during the forward pass stay the same, and each step still has its own prediction loss.[1]

## Reported results

<figure>
<a href="/images/hidden-state-mixing-and-gradient-detach-c3d4d23d7d58.png"><img src="/images/hidden-state-mixing-and-gradient-detach-c3d4d23d7d58.png" alt="Two charts compare acceptance by draft position for four training settings and mean acceptance length before and after drafter post-training across five target models." /></a>
<figcaption>The authors compared acceptance by draft position after joint training and fine-tuning. They also measured acceptance length before and after retraining the drafter with the target model frozen. [6]</figcaption>
</figure>

In joint pretraining followed by supervised fine-tuning, the authors reported higher acceptance rates with HSGD near the start of a draft and with HSM near the end. A separate experiment kept the target weights frozen and retrained the drafter using HSM with [knowledge distillation](https://aiwiki.ai/wiki/knowledge_distillation). Across four Nemotron checkpoints and [DeepSeek V4-Pro](https://aiwiki.ai/wiki/deepseek_v4_pro), the largest relative gain in mean acceptance length was 52.2% for DeepSeek V4-Pro at temperature 1 with seven draft positions on the SPEED-Bench qualitative split. That result measures tokens advanced per verification step. Actual decoding latency also depends on the cost of the draft and verification steps.[1][5]

In a four-step EAGLE-3 training comparison for Qwen3-8B on a four-GPU GB300 node, HSM used 36.3 GiB of peak reserved training memory per GPU versus 70.3 GiB for training-time test. The result measures training memory for that setup.[1]

## References

1. Galron, Y., Karimi Mahabadi, R., Ashkenazi, M., et al. [Improving Tail-Augmented Speculative Drafting with Hidden State Mixing and Gradient Detach](https://arxiv.org/html/2611.34092v1). arXiv preprint, November 25, 2026. Sections 2 through 7, Table 4 and Figure 12.
2. Li, Y., Wei, F., Zhang, C., and Zhang, H. [EAGLE-3: Scaling up Inference Acceleration of Large Language Models via Training-Time Test](https://arxiv.org/abs/2503.01840). March 2025. Revised April 2025.
3. NVIDIA. [Multi-token prediction implementation](https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/core/transformer/multi_token_prediction.py). Megatron-LM.
4. NVIDIA. [Speculative decoding examples](https://github.com/NVIDIA/Model-Optimizer/tree/main/examples/speculative_decoding). NVIDIA Model Optimizer.
5. NVIDIA Research. [SPEED-Bench: A Unified and Diverse Benchmark for Speculative Decoding](https://research.nvidia.com/publication/2026-02_speed-bench-unified-and-diverse-benchmark-speculative-decoding). 2026.
6. Yaniv Galron et al., Figure 1. [Original image source](https://arxiv.org/html/2611.34092v1#S0.F1). [CC BY 4.0](https://arxiv.org/html/2611.34092v1). [License text](https://creativecommons.org/licenses/by/4.0/). Original SVG rasterized on white.

