asdex: Automatic Sparse Differentiation in JAX
summary
The gist
The gist: Automatic sparse differentiation (ASD) exploits input-dependent sparsity in derivative matrices to compute them efficiently with fewer automatic differentiation passes than standard methods.
In short
Automatic Sparse Differentiation (ASD) efficiently computes sparse Jacobian and Hessian matrices in JAX by exploiting input-dependent sparsity. It achieves this through four steps: detecting input patterns, coloring a graph to group related inputs, performing compressed differentiation with fewer passes, and decompressing the result. This provides a memory-efficient alternative to standard dense differentiation methods.
Key concepts
- Sparsity Detection
- This step uses abstract interpretation on JAX's internal representation (jaxpr7) to determine which inputs influence which outputs. It propagates index sets through the function, creating a conservative pattern of input-output dependencies. This process is crucial because it identifies the structure of sparsity before any computation begins.
- Graph Coloring
- The detected sparsity pattern is modeled as a graph coloring problem. For Jacobians, this involves distance-2 coloring to partition inputs into groups that share an AD pass without overlapping nonzeros. This grouping significantly reduces the number of required differentiation passes, which is the core efficiency gain.
- Compressed Differentiation
- Instead of computing the full dense matrix, asdex computes a compressed derivative matrix using parallelized Jacobian-vector products against a seed matrix derived from the coloring. This allows for one AD pass per color group instead of one pass per dimension, drastically lowering computational cost.
- Decompression
- The final step takes the compressed derivative information and scatters it back into the original, desired sparse format. This ensures that the output is a usable sparse Jacobian or Hessian matrix matching the original input structure, completing the process.
Terminology used across episodes
This episode discusses
- asdex: Automatic Sparse Differentiation in JAX · Paper Radio
- The Elements of Differentiable Programming
- Revisiting Sparse Matrix Coloring and Bicoloring
- A versatile FEM framework with native GPU scalability via globally-applied AD
- Lineax: unified linear solves and linear least-squares in JAX and Equinox
The paper
asdex: Automatic Sparse Differentiation in JAX · Read on arXiv
Adrian Hill, Guillaume Dalle
BIFOLD – Berlin Institute for the Foundations of Learning and Data · Machine Learning Group, Technical University of Berlin · LVMT, ENPC, Institut Polytechnique de Paris
Many tasks in scientific computing and machine learning require the Jacobian or Hessian matrix of a function. Automatic differentiation (AD) computes these derivatives to machine precision, but materializing a dense m times n Jacobian requires n forward-mode or m reverse-mode AD passes, one per column or row. For a large class of functions, each output depends on only a few inputs, making the derivative matrix sparse. Automatic sparse differentiation (ASD) exploits this structure in four steps: detection of the input-agnostic sparsity pattern, coloring of a graph to group columns or rows that can share an AD pass, compressed differentiation to compute a compressed derivative matrix with one AD pass per color, and finally decompression into the original sparsity pattern. The number of colors, and hence of AD passes, is often independent of the problem dimension: a banded Jacobian with b contiguous bands, for instance, only ever requires b colors, regardless of its size. asdex offers the first standalone ASD toolkit in the popular JAX ecosystem. With asdex.jacobian and asdex.hessian, it provides sparse drop-in replacements for jax.jacobian and jax.hessian.
Transcript
Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.
Tom: Today's paper: "asdex: Automatic Sparse Differentiation in JAX".
Jane: The gist: Automatic sparse differentiation (ASD) exploits input-dependent sparsity in derivative matrices to compute them efficiently with fewer automatic differentiation passes than standard methods.
Tom: First, who's behind it and why it matters.
Title and authors: Tom: We're starting with the title and the authors of this paper, "asdex: Automatic Sparse Differentiation in JAX." It’s clear from that name what they’re trying to achieve—making differentiation sparse automatically within the JAX framework.
Jane: The authors are Adrian Hill and Guillaume Dalle, and they’ve been working on this idea for a while now since the problem started getting more pressing for machine learning research.
Lu: They are really focusing on high-level languages like JAX because that’s where most of the new machine learning prototyping is happening right now.
Meng: So, what does this title actually mean in plain English? It means they’re building a system to figure out where the derivatives are zero so they don't waste time calculating those zero entries.
Tom: Exactly. They want to bypass the standard method where you just compute everything dense, and instead use input-dependent sparsity—meaning the derivative matrix is sparse for specific inputs—to save both memory and calculation time.
Jane: It’s about exploiting that input-dependent structure so you get more efficient matrix storage and a faster way to fill in those sparse matrices.
Lalam: So, it’s essentially trying to combine smart pattern detection with clever matrix filling techniques to get the best of both worlds for these derivative calculations.
The paper's summary: Tom: Now, let’s look at what the paper actually summarizes in "asdex: Automatic Sparse Differentiation in JAX." They lay out a four-step process for how this automatic sparse differentiation works.
Jane: First, they have sparsity detection—that’s figuring out which inputs actually influence which outputs. They do this by performing abstract interpretation on a jaxpr7, which is JAX’s intermediate representation of functions.
Lu: That abstract interpretation step is key because it propagates index sets through each primitive to determine the pattern, and importantly, it yields a conservative pattern that never misses any non-zero entries.
Meng: So they aren't just guessing sparsity; they are using JAX’s own structure to find where the dependencies lie before doing any heavy matrix math.
Tom: After detection comes graph coloring. They take the detected pattern and turn it into a graph coloring problem, which they solve approximately using standard greedy algorithms.
Jane: For Jacobians, this involves a distance-two coloring of a bipartite row-column graph to partition columns or rows into structurally orthogonal groups that have no overlapping non-zeros <ref:2610.12336#pg1>.
Lalam: And for Hessians, they use something called star coloring to exploit the symmetry of the matrix further to reduce the number of colors needed.
The paper's improvements: Tom: The paper highlights a few major improvements over just using standard JAX functions like `jax.jacobian` or `jax.hessian`. They show that asdex is designed with several distinct, composable components mirroring the actual stages of ASD.
Jane: One big improvement is the separation between preparation and evaluation. Preparation involves that one-time detection and coloring work which depends only on input shapes but not the actual values.
Lu: That means in an iterative solver or a training loop, you only have to do that expensive setup once, and then you just run the cheap compressed differentiation pass repeatedly.
Meng: That amortization of the preparation step is what makes it practical for real-world applications where you're running lots of optimization steps.
Tom: Another improvement is how they handle second-order detection. They don’t need a separate second-order detector; they get Hessian patterns by applying the same first-order detector to `jax.grad(f)`.
Jane: That’s smart because it keeps the workflow simpler and avoids having to maintain a whole separate system just for the Hessian patterns.
Conclusion: Tom: So, wrapping up this discussion on "asdex: Automatic Sparse Differentiation in JAX," we see a tool that lets us leverage JAX’s speed while bypassing the memory bottleneck of dense derivative matrices by computing them with one AD pass per column or row.
Jane: It offers a way to compute sparse Jacobians and Hessians, which is crucial for applications like second-order optimization algorithms and sensitivity analysis where those matrices are often massive.
Lu: The real impact is that it combines more efficient matrix storage with a faster way to fill it, which addresses both the memory bottleneck and the high computational cost of standard methods.
Meng: For practitioners, this means you can keep using JAX’s performance and JIT compilation but get a much better handle on those large systems without running into immediate out-of-memory errors.
Lalam: Culturally, this kind of tooling makes it easier for researchers to focus on the model dynamics rather than worrying about the underlying hardware limitations of the differentiation process itself.
Tom: So, that’s what we have on "asdex: Automatic Sparse Differentiation in JAX." It’s a method designed to make derivative calculations more efficient by exploiting input-dependent sparsity.
Jane: It gives us a pathway to use JAX for bigger problems without immediately hitting those dense matrix limitations.
Lu: We'll be watching how this pattern detection and coloring approach develops, because it sets a strong foundation for other sparse derivative techniques in high-level systems.
Meng: From an engineering standpoint, the ability to amortize the setup cost is really what makes this viable for large-scale scientific computing tasks.
Lalam: It shows how AI tools can help us build infrastructure that handles complex mathematical structures more intelligently than just brute force computation.
More episodes
- 2610.09563-EvoSignal: LLM-Guided Evolutionary Design of Modular Traffic Signal Control Programs
- 2610.10135-Attention via Black-Box Vector Search
- 2610.09471-When Should an In-Context Learner Expand Its Hypothesis Space?
- 2610.12358-Subspace Uncertainty and Sharp Sampling Thresholds on the Boolean Cube
- 2610.12321-Spatial Pattern Formation from Multi-Agent Learning in Public Goods Dilemmas
- 2610.12340-Ambient Discrete Diffusion: Using the Wrong Data at the Right Time for Data Efficient Learning
- 2610.12349-SplitJEPA: Learning Invariant and Variant Latent Worlds without Reconstruction
- 2610.12379-Marformer: A Transformer for Predicting Missing Data Distributions
- 2610.12401-Learning Kilometer-Scale Weather Prediction with Global-Regional Alignment
- 2610.12397-Prospective Prediction of OOD Degradation from Source-Side Training Dynamics