TL;DR
HexFormer is a new Vision Transformer (ViT) architecture that operates in hyperbolic space rather than standard Euclidean space. By introducing a novel "Exponential Map Aggregation" (ExpAgg) for its attention mechanism, it achieves better accuracy and significantly more stable training dynamics, effectively eliminating the need for the delicate "warmup" schedules typically required by Euclidean transformers.
What Problem Does This Paper Address?
Most deep learning models, including standard Vision Transformers, operate in Euclidean space. While intuitive, Euclidean geometry isn't always the best fit for data with hierarchical or relational structures—think of a "tree" where the number of nodes grows exponentially with depth.
Hyperbolic geometry is a non-Euclidean framework where space "expands" much faster, making it mathematically ideal for embedding hierarchies. While researchers have tried building hyperbolic ViTs before, they often ran into two walls:
- Numerical Instability: Standard hyperbolic operations are prone to floating-point errors (NaNs/Infs), especially during the "aggregation" step of attention.
- Training Sensitivity: These models often required massive pre-training or very specific hyperparameter tuning to outperform their Euclidean counterparts.
HexFormer aims to solve these stability issues while proving that hyperbolic geometry can provide a "principled and scalable" boost to representational capacity.
Methods
The authors build HexFormer using the Lorentz (hyperboloid) model of hyperbolic space. The core innovations are:
- Exponential Map Aggregation (ExpAgg): In standard attention, "values" are averaged together. In curved space, finding a true average (the Fréchet mean) is computationally expensive and numerically unstable. HexFormer instead projects value vectors into a flat tangent space (using a logarithmic map), performs a weighted sum there, and then projects the result back onto the hyperbolic manifold (using an exponential map). This "ExpAgg" approach is simpler, faster, and much more stable than previous centroid-based methods.
- HexFormer-Hybrid: The authors found that while hyperbolic encoders are great at extracting features, a fully hyperbolic classification head can sometimes overfit. They introduced a hybrid variant that uses a hyperbolic encoder but switches to a standard Euclidean linear head for the final classification.
- Lorentzian Attention Scores: Instead of the usual dot-product attention, HexFormer calculates scores based on the squared Lorentzian distance, which naturally respects the geometry of the manifold.
Datasets
The models were evaluated on datasets with known hierarchical structures:
- CIFAR-10 & CIFAR-100: Small-scale image datasets with latent semantic groupings (e.g., animals vs. vehicles).
- Tiny-ImageNet: A subset of ImageNet that inherits the deep WordNet taxonomy.
To test the limits of the architecture, they also ran experiments on "flat" datasets (MNIST, Fashion-MNIST, and SVHN). As expected, the hyperbolic advantage disappeared on these non-hierarchical datasets, confirming that the model's strength lies specifically in capturing complex relational structures.
Key Insights and Ideas
- The "Warmup" Cure: One of the most surprising findings is that HexFormer is largely indifferent to learning rate warmup. Euclidean ViTs often "break" if you don't start with a very low learning rate; HexFormer’s gradients remain stable and smooth from the very first iteration.
- Geometry as a Regularizer: The negative curvature of hyperbolic space tends to "spread out" representations. This prevents the extreme activation values that often lead to vanishing or exploding gradients in deep Euclidean networks.
- Stability over Complexity: The paper shows that the relatively simple ExpAgg mechanism outperforms more complex centroid-based averaging. It avoids the "numerical collapse" that happens when floating-point precision can't handle the massive values generated in Lorentz space.
Key Results
- Superior Accuracy: On CIFAR-100, the HexFormer-Hybrid (Tiny) achieved 75.85% accuracy, outperforming the Euclidean baseline (74.64%) and significantly beating prior hyperbolic state-of-the-art models like LViT (69.11%).
- Faster Convergence: HexFormer reached higher accuracy in fewer epochs. For instance, a HexFormer trained for only 60 epochs outperformed a Euclidean ViT trained for the full 100 epochs.
- Robustness: In head-to-head stability tests using the AdamW optimizer, the standard "centroid" method failed (produced NaNs) in 4 out of 5 seeds. The proposed ExpAgg method succeeded in 5 out of 5 seeds, demonstrating its reliability for practical training.
Limitations and Future Work
Despite the performance gains, there are clear trade-offs:
- Computational Overhead: Hyperbolic operations are more complex. HexFormer is roughly 4x slower per training iteration and uses about 2.5x more GPU memory than a standard Euclidean ViT.
- FLOPs Measurement: The authors note that standard tools for counting FLOPs (like THOP) don't fully capture the cost of manifold-specific operations (like
coshorsqrt), meaning the reported computational cost might be an underestimate. - Fixed Curvature: Most experiments used a fixed curvature ($K = -1$). While the authors briefly experimented with learnable curvature, fully exploring how curvature interacts with different model scales remains a task for future research.
Summary updated