patrick-kidger / patrick-kidger/diffrax

Type Error in Neural ODE Example

Open
#622 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
2.1k
Forks
189
Avg merge
3d 18h
Merged PRs (30d)
1

Description

Hi,

I've been using jax 0.4.35 and cuda 11.2 with diffrax 0.6.0 and equinox 0.11.8 to train various types of neural ODEs. This worked very well so far. Thanks for the great packages.

However, after upgrading to jax 0.6.0 and cuda 12.8 with diffrax 0.7.0 and equinox 0.12.1, I can no longer compute gradients through ODE solvers. The forward pass works but the gradient computation with eqx.filter_value_and_grad results in a TypeError. To be precise, I receive: TypeError: Argument 'Zero(ShapedArray(float0[32]))' of type '<class 'jax._src.ad_util.Zero'>' is not a valid JAX type . I have tried both the Tsit5() and Dopri5() solvers. The shape of the array in the TypeError is the same as the batch size.

This occurs not only in my own models, but also when I try to run the neural ODE tutorial from https://github.com/patrick-kidger/diffrax/blob/main/examples/neural_ode.ipynb.

Any advice/ideas on how to resolve this would be great! Many thanks in advance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/neural_ode.ipynb and reproduce the gradient failure using the reported JAX, CUDA, Diffrax, and Equinox versions. Compare the forward and gradient paths for both Tsit5() and Dopri5(), then verify that the tutorial computes gradients successfully without the reported Zero(float0) TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.