Abstract
Recent advancements in Large Language Models (LLMs) have highlighted the power of "length scaling"—providing models with additional computational steps to "think" through complex problems. While effective in post-training (e.g., Chain-of-Thought), applying this to pre-training has been hindered by the linear growth of the KV cache, which imposes severe memory and latency penalties. This paper presents the Parallel Hidden Decoding (PHD) Transformer, a novel framework that decouples computational depth from memory footprint. By selectively caching only essential tokens, PHD-Transformer enables deeper pre-training computation with nearly zero overhead during inference.
Introduction
The success of models like OpenAI’s o1 and DeepSeek-R1 has sparked intense interest in "thinking" models that utilize long reasoning sequences. However, integrating this capability during the initial pre-training phase is challenging. Standard Transformer architectures suffer from a KV cache bottleneck: as sequence length or "thinking" depth increases, the memory required to store Key and Value states grows linearly. This leads to increased pre-filling times and decoding latencies, making long-sequence pre-training impractical for deployment.
Methodology: The PHD-Transformer Series
To address the KV cache bottleneck, we propose three iterations of the PHD-Transformer:
- Parallel Hidden Decoding (PHD): Input tokens are repeated $K$ times. Only the first instance (the "original token") is stored in the KV cache. Subsequent "hidden decoding tokens" are used for parallel computation and then discarded, preventing cache bloat.
- PHD-SWA (Sliding Window Attention): To maintain local context for hidden tokens, this variant introduces a small, fixed-size sliding window ($W$) for the hidden decoding tokens' KV cache. This provides an $O(1)$ memory overhead while improving performance.
- PHD-CSWA (Chunk-wise Sliding Window Attention): To eliminate sequential dependencies in SWA that slow down pre-filling, PHD-CSWA restricts dependencies to independent chunks ($C$). This allows for high parallelization, keeping pre-fill times comparable to vanilla Transformers.
Experimental Results
We evaluated PHD-Transformer using the OLMo2 codebase, training models from 151M to 1.2B parameters on up to 500 billion tokens.
Performance and Scaling
Our results demonstrate that training loss and downstream accuracy scale robustly with the repetition factor $K$. A 1.2B parameter PHD-CSWA model ($K=3$) achieved a 2.0% average accuracy improvement across benchmarks (including MMLU and HellaSwag) compared to a vanilla baseline.
As shown in the figure above, increasing the token repetition times consistently lowers training loss (a) and improves HellaSwag accuracy (b). Crucially, while a naive token-repeating approach leads to linear increases in pre-filling time (c) and decoding latency (d), PHD-CSWA maintains nearly constant performance, matching the efficiency of a vanilla Transformer.
Inference Efficiency
The PHD-Transformer is particularly effective because LLM inference is often memory-bound rather than compute-bound. By keeping the KV cache size identical to a vanilla model, PHD-Transformer can perform significantly more computation ($K$ times more) with less than a 20% increase in actual decoding latency, even when $K$ is scaled as high as 256.
Conclusion
The PHD-Transformer framework offers a path toward more capable LLMs by enabling efficient computational depth scaling during pre-training. By overcoming the KV cache bottleneck, it allows models to "think harder" without sacrificing inference speed or memory efficiency. Future research will explore dynamic length scaling, allowing models to adaptively determine the necessary computational depth for a given task.
Summary updated