Residual connections (the ubiquitous $x + f(x)$) are the bedrock of modern deep learning, but they come with a fundamental trade-off. Researchers often find themselves stuck on a "seesaw": use Pre-Norm to ensure stable gradients in deep networks at the cost of "representation collapse" (where layers become redundant), or use Post-Norm to keep representations distinct at the risk of vanishing gradients.
A new paper from the ByteDance Seed-Foundation-Model Team, titled "Hyper-Connections," proposes a way to step off the seesaw entirely. Instead of hard-coding how layers connect, they introduce a learnable, dynamic framework that allows the network to decide its own wiring.
TL;DR
Hyper-connections (HC) are a learnable alternative to residual connections that expand the hidden state into multiple paths and use dynamic weights to control information flow. This approach allows networks to autonomously balance gradient stability and representation diversity, leading to 1.8x faster convergence in MoE models and significant accuracy gains across LLM and vision tasks with negligible computational overhead.
What Problem Does This Paper Address?
The "seesaw effect" in residual connections is a well-known headache. In very deep Transformers:
- Pre-Norm (normalizing before the layer) makes training stable but causes hidden states in deep layers to become highly similar, effectively "wasting" the capacity of deeper layers.
- Post-Norm (normalizing after the layer) keeps features diverse but makes the gradient signal fragile, often leading to training instability or "explosions."
Furthermore, standard architectures fix the layer arrangement (sequential vs. parallel) at design time. The authors argue that a fixed residual path is a "non-trainable" constraint that limits a model's ability to optimize its internal information routing.
Methods
The core of the proposal is the Hyper-Connection (HC). Instead of a single hidden vector, the model maintains $n$ hidden vectors (the expansion rate).
- Static Hyper-Connections: The connections between these $n$ vectors and the layer outputs are governed by learnable scalar matrices. This allows the model to learn, for example, that Layer 5 should act as a residual for Layer 10.
- Dynamic Hyper-Connections (DHC): This takes it a step further. The connection weights are predicted on-the-fly based on the input token itself. A small linear layer followed by a
tanhfunction generates the weights for each connection. - Sequential-Parallel Duality: Mathematically, the authors prove that HC can represent traditional sequential layers, parallel blocks (like those in GPT-J), or any "soft mixture" of the two.
- Efficiency: While it sounds like the model becomes $n$ times wider, the "expansion" only applies to the residual paths, not the heavy Attention or FFN weights. The actual increase in FLOPs is typically less than 0.2%.
Datasets
The authors conducted an extensive evaluation across different modalities:
- Language Modeling: Pre-training on the Dolma and C4 datasets using the OLMo (1B, 7B) and OLMoE (sparse 7B) architectures.
- LLM Benchmarks: Evaluation on HellaSwag, ARC-Challenge, PIQA, SciQ, and MMLU.
- Vision Tasks: Image generation using Diffusion Transformers (DiT) and classification using Vision Transformers (ViT) on ImageNet-1k.
Key Insights and Ideas
- Residuals are just a special case: The authors show that Pre-Norm and Post-Norm are simply specific, fixed configurations of a Hyper-Connection matrix. By making the matrix trainable, the model can find a middle ground that avoids both vanishing gradients and representation collapse.
- The $\Lambda$-shaped Connection Pattern: Through visualization, the authors found that HC models naturally develop a "$\Lambda$" pattern. They rely on a few adjacent layers (Post-Norm style) while frequently accessing early "anchor" layers (Pre-Norm style).
- Automatic Layer Rearrangement: The model often learns to treat consecutive layers as parallel blocks. For instance, in a 1B model, layers 11 and 12 were observed to operate in parallel without any explicit architectural instruction to do so.
- Input Embedding Shedding: The visualization revealed that the model learns to "drop" the original word embedding from the hidden state just before the final output, likely because raw embeddings are "noisy" for next-token prediction.
Key Results
- Faster Convergence: The OLMoE-1B-7B model with DHC converged 1.8 times faster than the baseline.
- Better Reasoning: On the ARC-Challenge, the HC-equipped MoE model saw a massive 6-point improvement over the baseline.
- Vision Gains: A DiT-XL/2 model with HC outperformed a standard DiT-1B/2, effectively matching the performance of a model with 50% more parameters.
- Stability: The HC models showed significantly smoother training curves with fewer loss spikes compared to standard residual baselines.
Limitations and Future Work
- Memory Footprint: While FLOPs and parameters are nearly identical, training memory increases. Because the model tracks $n$ hidden states, it must store more activations for backpropagation. For a 7B model, this resulted in a ~28% increase in memory usage.
- Expansion Rate Diminishing Returns: Performance gains were significant moving from $n=1$ to $n=4$, but plateaued at $n=8$. Finding the "sweet spot" for different model scales remains an open question.
- Inference Overhead: While negligible, there is a tiny amount of extra computation for the dynamic weight prediction that could impact ultra-low-latency deployment.
Overall, Hyper-Connections offer a compelling "set it and forget it" alternative to manual residual tuning, allowing the data to dictate the optimal depth-wise architecture of the model.
Summary updated