NVIDIA/torch-harmonics

Differentiable signal processing on the sphere for PyTorch

What it solves

Torch-harmonics gives machine-learning models the ability to work with data that lives on a sphere, like the Earth's surface. It provides differentiable versions of spherical harmonic transforms (the spherical analogue of Fourier transforms), vector spherical harmonic transforms, and convolutions on the sphere. This makes it possible to build neural networks that directly process spherical data (e.g., climate fields) and to implement differentiable solvers for partial differential equations (PDEs) on the sphere. The library was originally created to enable Spherical Fourier Neural Operators (SFNO), a type of neural network for weather and climate modeling.

How it works

The core operation is the spherical harmonic transform (SHT), which projects a signal defined on the sphere onto a basis of spherical harmonics. The implementation uses quadrature rules (numerical integration) for the Legendre transform part and fast Fourier transforms (FFTs) for the longitudinal part. Because everything is built on PyTorch primitives, the operations are fully differentiable, meaning gradients can flow through them for training neural networks. The library also supports multiple grid types (equiangular, HEALPix, Legendre-Gauss, etc.) that define where sample points are placed on the sphere, and it can distribute the computation across multiple GPUs or ranks for large-scale problems.

Who it’s for

This is aimed at researchers and engineers working with spherical data in scientific computing, especially in climate science, weather forecasting, and physics simulations. It is particularly useful for those who want to apply deep learning to such data, for example by building neural operators that learn to solve PDEs on the sphere. The library is also relevant for anyone developing differentiable numerical methods on the sphere.

Highlights

  • Differentiable spherical harmonic transforms (SHT) and vector spherical harmonic transforms
  • Discrete-continuous (DISCO) convolutions on the sphere for local neural operators
  • Spherical attention mechanisms that respect the geometry of the sphere
  • Support for multiple grid types: equiangular, Fejér-1, Legendre-Gauss, Lobatto, trapezoidal, and HEALPix
  • Distributed computation across multiple ranks for large-scale problems
  • Built on PyTorch, making it composable with existing deep learning workflows
  • Used to implement differentiable PDE solvers and Spherical Fourier Neural Operators (SFNO)

Related

  • Project
  • Project
  • Project
  • Project
  • Project