Skip to content

Commit

Permalink
Fix for BFGS + diffeqsolve
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-kidger committed Jul 7, 2024
1 parent 70d664c commit 23b3042
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion equinox/internal/_loop/checkpointed.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,11 @@ def _checkpointed_while_loop_bwd(
)
del cond_fun, perturbed
num_steps, init_residual_steps, init_residuals, filled_buffers = remainders
num_steps, init_residual_steps = nonbatchable((num_steps, init_residual_steps))
# `allow_constant_across_batch` to handle
# https://github.com/patrick-kidger/optimistix/issues/67
num_steps, init_residual_steps = nonbatchable(
(num_steps, init_residual_steps), allow_constant_across_batch=True
)

def _cond_fun(carry):
_, step_grad_val, *_ = carry
Expand Down
2 changes: 1 addition & 1 deletion equinox/internal/_nontraceable.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _cannot_batch(x, b, *, msg, allow_constant_across_batch):
return x, b
else:
if allow_constant_across_batch:
x = error_if(x, jnp.min(x) != jnp.max(x), msg)
x = error_if(x, jnp.min(x, axis=b) != jnp.max(x, axis=b), msg)
return jnp.take(x, 0, axis=b), batching.not_mapped
else:
raise ValueError(msg)
Expand Down

0 comments on commit 23b3042

Please sign in to comment.