HypLL: The Hyperbolic Learning Library

Max van Spengler, Philipp Wirth, Pascal Mettes · DOI

TL;DR

HypLL (Hyperbolic Learning Library) is a new open-source PyTorch-based library designed to make hyperbolic deep learning as accessible and user-friendly as standard Euclidean deep learning. By introducing "manifold-aware" tensors and a familiar API, it allows researchers to build complex hyperbolic neural networks—complete with convolutions and batch normalization—with minimal changes to their existing PyTorch workflows.

What Problem Does This Paper Address?

Most deep learning happens in Euclidean space, which assumes data exists on a flat, regular grid. However, many real-world datasets are inherently hierarchical (think of biological taxonomies, social networks, or language structures). In a hierarchy, the number of nodes grows exponentially with depth. Trying to embed this exponential growth into Euclidean space leads to significant distortion unless you use a massive number of dimensions.

Hyperbolic geometry offers a solution: its volume also grows exponentially with radius, making it a natural fit for hierarchical data. While the theory for hyperbolic neural networks has advanced rapidly, the software hasn't kept pace. Existing tools often lack standard layers (like convolutions), don't track the underlying geometry (leading to "silent" mathematical errors), or are built for different frameworks like TensorFlow. HypLL aims to bridge this gap for the PyTorch community.

Methods

HypLL is structured around four core modules that mirror the PyTorch ecosystem:

  1. tensors: This is the library's foundation. It introduces the manifold_tensor, which wraps a standard PyTorch tensor but adds metadata about which manifold the data lives on and which dimension represents the manifold coordinates. It also includes tangent_tensor for handling vectors in the tangent space.
  2. manifolds: This module defines the mathematical operations (like exponential maps, logarithmic maps, and Fréchet means) for specific geometries. Currently, it supports the Euclidean manifold and the Poincaré ball (a popular model of hyperbolic space).
  3. nn: This module contains hyperbolic versions of standard layers like Linear, Convolution, BatchNorm, and Pooling. These layers are "manifold-agnostic," meaning they use the manifold object passed during initialization to perform their internal math.
  4. optim: To train these networks, the library implements Riemannian versions of SGD and Adam, which ensure that parameter updates stay within the bounds of the chosen manifold.
Figure 1: The structure of HypLL, centered around the ten- sors, manifolds, nn, and optim modules.

Datasets

The paper uses the CIFAR-10 dataset as a primary example to demonstrate how a standard image classification pipeline can be adapted to hyperbolic space using HypLL. The authors provide a tutorial showing how to map Euclidean image data onto the Poincaré ball and train a small convolutional network.

Key Insights and Ideas

  • Manifold Tracking as a Debugging Tool: By embedding manifold information directly into the tensor object, HypLL can automatically check if an operation is mathematically valid. This prevents the "silent failures" common in non-Euclidean DL, where code runs but produces nonsensical results because data from different geometries was mixed.
  • Minimal API Friction: The design philosophy is "PyTorch-first." If you know how to build a nn.Module in PyTorch, you already know how to use HypLL. The only major difference is passing a manifold object to your layers.
  • Learnable Curvature: In the Poincaré ball model, the curvature is often a fixed hyperparameter. HypLL allows this curvature to be a learnable parameter, letting the model optimize the geometry itself during training.

Key Results

The paper focuses on the library's design and ease of use rather than benchmarking new SOTA results. The primary "result" is the demonstration of how little code needs to change to go from Euclidean to Hyperbolic.

For example, feeding data into a model requires just a few lines to wrap inputs in a TangentTensor and map them to the manifold using an exponential map:

Figure 3: Feeding data to a model written with HypLL.

The authors highlight that across existing literature, hyperbolic learning consistently shows better performance with fewer embedding dimensions and increased robustness to out-of-distribution samples when dealing with hierarchical data.

Limitations and Future Work

Currently, HypLL focuses primarily on the Poincaré ball model of hyperbolic space. The authors acknowledge the need to expand this to other models, such as the hyperboloid and Klein models, in future updates.

Furthermore, while the library handles standard neural network layers well, the authors aim to build a dedicated geometric framework for graph-based data (similar to PyTorch Geometric) on top of HypLL to better serve the graph representation learning community.

Summary updated

BibTeX
@inproceedings{spengler2023hypll,
  author = {Max van Spengler and Philipp Wirth and Pascal Mettes},
  title = {{HypLL: The Hyperbolic Learning Library}},
  booktitle = {ACM Multimedia},
  year = {2023},
  url = {https://openreview.net/forum?id=KooCI23LRa},
}
Figure