What padaquad is for#

What this is for#

  • ✅ Compute \(\int_{a}^{b} f(t)\,dt\) where \(f\) is given as a callable.

  • ✅ Compute \(\int f(t, \phi_\theta(t))\,dt\) for a learnable \(\phi_\theta\), and back-propagate through it.

  • ✅ Compute integrals of gradients, expectations, residuals — anything the user constructs as a \(t\mapsto \mathbb{R}^D\) callable.

  • ✅ Run on GPU or CPU; the parallel evaluation pays off most when evaluating \(f\) is itself non-trivial (a neural net, a PDE solver, etc.).

What this is not for#

  • ❌ True ODE integration \(\dot y = f(t, y)\) with state coupling — the parallel trick relies on independence between subintervals. For state- coupled problems use torchdiffeq, torchode, or diffrax.

  • ❌ Multi-dimensional adaptive integration (cubature). Use a sparse-grid or Monte-Carlo library.

  • ❌ Long-time symplectic / Hamiltonian integration. Use a dedicated geometric integrator.

Comparisons with other libraries#

Library

Adaptive subdivision

Differentiable

Parallel

Best for

scipy.integrate.quad

✓

✗

✗

classical one-shot smooth quadrature

torchquad

✗

✓

✓

fixed-grid methods and Monte Carlo (including VEGAS), also in several dimensions

torchdiffeq

adaptive step size

✓

✗

true state-coupled ODEs \(\dot y = f(t, y)\)

padaquad

✓

✓

✓

path integrals, learned-integrand integration, physics-informed residual losses

torchquad’s README (commit fc6f9cd, 2026-10-28) states that it does not implement adaptive subdivision. For one-shot scalar quadrature with no autograd, scipy.integrate.quad is fine. The library’s value is when the integrand is a learnable PyTorch function and many evaluations are needed.