fix: restore jax.tree_util.Partial in omega() for PowerLaw+JAX#352
Merged
fix: restore jax.tree_util.Partial in omega() for PowerLaw+JAX#352
Conversation
Commit 632ae82 replaced jax.tree_util.Partial with functools.partial in omega(), breaking PowerLaw deflection calculations under JAX. scan is wrapped in jax.jit, so its first argument (the body function) is traced as a pytree — functools.partial is not a registered pytree and fails with: TypeError: Error interpreting argument to <function scan> as an abstract array. The problematic value is of type <class 'functools.partial'> jax.tree_util.Partial is still present in JAX 0.9.2, so the "0.5+ compat" rationale in 632ae82 was incorrect. Reverting just that one line. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace#61 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a regression in
omega()introduced by commit 632ae82, which replacedjax.tree_util.Partialwithfunctools.partial, breakingPowerLawdeflection calculations under JAX.scaninsideomega()is wrapped injax.jit, so its first argument (the body function) is traced as a pytree.functools.partialis not a registered pytree and fails with:```
TypeError: Error interpreting argument to as an abstract
array. The problematic value is of type <class 'functools.partial'>
```
jax.tree_util.Partialis still present in JAX 0.9.2, so the "0.5+ compat" rationale in 632ae82 was incorrect. This PR reverts that single-line change.Reproducer
autolens_workspace_test/scripts/jax_likelihood_functions/imaging/lp.py(which usesal.mp.PowerLaw+ a JAX-vmap'dFitness) is a direct reproducer. It fails onmainand passes after this fix.The bug also blocks all
mass_totalstages of the group SLaM pipelines inautolens_workspace/scripts/group/features/that usePowerLaw.Test Plan
🤖 Generated with Claude Code