Skip to main content

Taylor Mode Autodiff in PyTorch

This library provides a PyTorch implementation of Taylor mode automatic differentiation, a generalization of forward mode to higher-order derivatives. It is similar to JAX's Taylor mode (jax.experimental.jet).

The repository also hosts the Python functionality+experiments and LaTeX source for our NeurIPS 2025 paper "Collapsing Taylor Mode Automatic Differentiation", which allows to further accelerate Taylor mode for many practical differential operators. The paper's numbers come from the benchmark in jet/exp/exp01_benchmark_laplacian run at commit 9eabf4e. Check out that commit to reproduce the published figures exactly.

Operator coverage is still growing, so please help us improve the package by providing feedback, filing issues, and opening pull requests.

Taylor mode propagates the jet of an input curve through a function to obtain the jet of the output curve

Getting Started

Installation

pip install jet-for-pytorch

Quickstart

Compute the third-order derivative of a scalar function with jet:

from torch import tensor, ones_like, zeros_like
from jet import jet

f = lambda x: x**4  # f'''(x) = 24 * x

x = tensor(2.0)
f_jet = jet(f, (x,))  # (x₀, x₁, x₂, x₃) ↦ (f₀, f₁, f₂, f₃)

# x₀ = x, x₁ = 1, x₂ = x₃ = 0 ⇒ f₃ = f'''(x)
f0, f1, f2, f3 = f_jet((x, ones_like(x), zeros_like(x), zeros_like(x)))

assert f3.allclose(24 * x)  # third derivative matches by hand

For the full list of supported operators, see the supported operations section of the introductory tutorial.

Examples

See the documentation.

Works with vmap, grad, vjp, jvp, and torch.compile

  • Transforms over a jet. A jet function returned by jet(...) is an ordinary PyTorch function, so torch.func.vmap, grad, vjp, and jvp apply to it.

  • torch.compile needs one more step. The jet function interprets the captured graph at call time, so the order and the number of directions can change between calls; dynamo cannot trace that interpreter. jet.freeze traces the jet computation once for fixed arguments and returns a callable that torch.compile handles, at the price that order, direction count, shapes, dtypes, and devices are then fixed:

    jet_fn = jet(f, mock_args)
    compiled = torch.compile(jet.freeze(jet_fn, jet_args))
    
  • A jet of a transform, such as jet(torch.func.grad(f), ...) or a jet of a vjp, works: autograd's backward pass adds its own ATen ops to the trace, and the backward ops of the supported primitives have jet rules too. If the trace contains an op without a rule, calling the jet raises NotImplementedError naming that op.

Citing

If you find the jet package useful for your research, consider citing

@inproceedings{dangel2025collapsing,
  title =        {Collapsing Taylor Mode Automatic Differentiation},
  author =       {Felix Dangel and Tim Siebert and Marius Zeinhofer and Andrea
                  Walther},
  year =         2025,
  booktitle =    {Advances in Neural Information Processing Systems (NeurIPS)},
}

Metadata

Release files for jet-for-pytorch 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jet-for-pytorch 1.1.0
File Size Uploaded Provenance Actions
jet_for_pytorch-1.1.0.tar.gz 6.4 MB With provenance Details for jet_for_pytorch-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jet-for-pytorch 1.1.0
File Interpreter ABI Platform Actions
jet_for_pytorch-1.1.0-py3-none-any.whl Python 3 none any Details for jet_for_pytorch-1.1.0-py3-none-any.whl

Total release size: 9.1 MB

Release files / jet_for_pytorch-1.1.0.tar.gz

Download URL jet_for_pytorch-1.1.0.tar.gz
Size 6.4 MB
Tags Source
SHA-256 checksum
How to use checksums
56f5d144f96737802a3dcfed980fb42f26437175442ac067a0602e98d3fb5554
BLAKE2b-256 checksum
How to use checksums
f6a1bcaebca3e10623d1122ab2f53ac193e6c689321e0d1db66358df0f8018a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / jet_for_pytorch-1.1.0-py3-none-any.whl

Download URL jet_for_pytorch-1.1.0-py3-none-any.whl
Size 2.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c79dc1d2588a5dcd2a9287c376c5cae56ba58ba3e58b2a6c8b376bedc36f3411
BLAKE2b-256 checksum
How to use checksums
57ac441f27f857c6eb6266bfbf44a1345b9a0676883d5b7378577eafec9c8bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for jet-for-pytorch 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jet_for_pytorch-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page