NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hypformer: Exploring Efficient Transformer Fully in Hyperbolic Space

Menglin Yang, Harshit Verma, Delvin Ce Zhang, Jiahong Liu, Irwin King, Rex Ying

Introduction

Standard Transformer architectures have revolutionized deep learning across various domains, from natural language processing to computer vision. However, these models predominantly operate in Euclidean space, which is characterized by a "flat" geometry. While effective for many tasks, Euclidean space struggles to represent data with inherent hierarchical or tree-like structures, such as social networks, biological pathways, and language taxonomies. In Euclidean space, the volume grows polynomially with the radius, whereas in a tree, the number of nodes grows exponentially. This fundamental mismatch leads to significant "distortion" when attempting to embed complex hierarchies.

Hyperbolic geometry offers a natural solution to this problem. Its volume grows exponentially with the radius, mirroring the growth of hierarchical structures and making it an ideal candidate for representing such data. Despite this potential, building a fully functional and efficient "Hyperbolic Transformer" has remained a significant challenge in the field.

The Challenge of Hyperbolic Transformers

Previous attempts to develop hyperbolic versions of the Transformer architecture have faced three major hurdles:

  1. Incompleteness: Many existing models lacked essential building blocks found in standard Transformers, such as Hyperbolic LayerNorm, Dropout, or effective positional encodings.
  2. Efficiency Leaks: These models often relied on frequent and computationally expensive mappings between the hyperbolic manifold and "flat" Euclidean tangent spaces to perform mathematical operations, leading to numerical instability and overhead.
  3. Quadratic Complexity: Like their Euclidean counterparts, existing hyperbolic Transformers suffered from $O(N^2)$ self-attention complexity, rendering them impractical for long sequences or massive graphs.

To address these gaps, we introduce Hypformer, the first comprehensive and efficient Transformer architecture designed to operate entirely within hyperbolic space.

Proposed Method: The Hypformer Architecture

Hypformer is built upon the Lorentz (hyperboloid) model of hyperbolic geometry. The architecture is defined by three novel foundational components that allow it to remain on the manifold while maintaining high efficiency.

Hyperbolic Transformation with Curvatures (HTC)

The HTC block replaces the standard linear layers found in Euclidean Transformers. Unlike previous methods that "flatten" data to apply a matrix transformation, HTC operates directly on the hyperbolic manifold. A key innovation of HTC is its ability to allow the "curvature" of the space to change between layers. By treating curvature as a trainable parameter, the model can learn the optimal geometric representation for each stage of data processing while preserving the relative distances and hierarchical relationships within the data.

Hyperbolic Readjustment and Refinement (HRC)

To handle "non-geometric" operations like LayerNorm, Activation (e.g., ReLU), and Dropout, we propose the HRC block. HRC treats these operations as refinements within a single reference frame. By operating on the "space-like" dimensions of the Lorentz model, HRC ensures that the causal structure of the hyperbolic representation remains intact without requiring constant transitions to tangent spaces.

Hyperbolic Linear Attention

The "secret sauce" for Hypformer's scalability is its first-of-its-kind hyperbolic linear self-attention mechanism. By mathematically refactoring the attention mechanism to operate on space-like dimensions and then "re-calibrating" the time-like dimension to satisfy hyperbolic constraints, the computational complexity is reduced from $O(N^2)$ to $O(N)$. This allows Hypformer to scale to datasets previously unreachable by hyperbolic models.

The Hypformer architecture, featuring Hyperbolic Transformation with Curvatures (HTC), Hyperbolic Readjustment and Refinement (HRC), and Hyperbolic Linear Attention.

Experimental Evaluation

We evaluated Hypformer across a wide range of scales and domains to demonstrate its versatility and power.

  • Billion-Scale Graphs: We tested Hypformer on massive datasets, including ogbn-proteins, Amazon2m, ogbn-arxiv, and the gargantuan Papers100M, which contains over 111 million nodes and 1.6 billion edges.
  • Hierarchical Benchmarks: We utilized datasets with high hyperbolicity, such as Disease and Airport, alongside standard citation networks like Cora, Citeseer, and PubMed.
  • Cross-Domain Tasks: To test latent hierarchy capture, we applied Hypformer to vision (Mini-ImageNet) and text (20News-Groups) data by constructing graphs from these non-graph sources.

Key Results and Insights

Hypformer achieves state-of-the-art performance across several metrics, particularly on hierarchical data.

  • Unprecedented Scalability: Hypformer is the first hyperbolic model capable of running on the Papers100M dataset. While most previous hyperbolic models and many Euclidean Graph Transformers encountered "Out of Memory" (OOM) errors at this scale, Hypformer's linear attention enabled successful training and inference.
  • Efficiency Gains: Head-to-head comparisons reveal that the linear attention mechanism provides a 10x reduction in GPU memory usage and halves the training time compared to standard hyperbolic softmax attention.
  • Superior Accuracy: On datasets with clear hierarchies, Hypformer significantly outperformed standard GNNs and Euclidean Transformers. For instance, it achieved a 93.0 F1 score on the Disease dataset, compared to 70.4 for the Graph Attention Network (GAT).
  • Robustness: Unlike earlier hyperbolic models that struggled on "flat" datasets like Cora, Hypformer remained competitive, proving its broad applicability beyond strictly tree-like data.
GPU memory cost comparison between Hyperbolic Linear Attention and Hyperbolic Softmax Attention, demonstrating the scalability of Hypformer to large-scale graphs.

Conclusion and Future Work

Hypformer represents a significant leap forward in hyperbolic deep learning. By breaking the reliance on tangent space mappings and introducing linear-time hyperbolic attention, it opens the door for applying hyperbolic geometry to massive, real-world hierarchical datasets.

While Hypformer is highly effective, future work involves refining curvature initialization and exploring more sophisticated hyperbolic-native decoders. Nonetheless, Hypformer establishes a new baseline for efficient, manifold-native Transformer architectures.

Authors: Jiahong Liu, Irwin King, Rex Ying

Summary updated

BibTeX
@inproceedings{yang2024hypformer,
  author = {Menglin Yang and Harshit Verma and Delvin Ce Zhang and Jiahong Liu and Irwin King and Rex Ying},
  title = {{Hypformer: Exploring Efficient Transformer Fully in Hyperbolic Space}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
  doi = {10.1145/3637528.3672039},
}
Figure