Skip to content

fix: make Array2D.native jit-traceable for JAX simulator path - #339

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/array2d-native-jit-safety
May 25, 2026
Merged

fix: make Array2D.native jit-traceable for JAX simulator path#339
Jammy2211 merged 1 commit into
mainfrom
feature/array2d-native-jit-safety

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

array_2d_via_indexes_from called tuple(native_index_for_slim_index_2d.T) on the JAX path, which iterates the outermost axis of a traced array and triggers TracerArrayConversionError under @jax.jit. This was the last structural blocker preventing users from wrapping SimulatorImaging(use_jax=True) and SimulatorInterferometer(use_jax=True) in @jax.jit.

Replaced with 2D advanced indexing ([:, 0], [:, 1]), removed the temporary if xp is np workaround in the imaging simulator, and cleaned up the "jit blocked" docstring caveats on both simulators.

API Changes

None — internal changes only. array_2d_via_indexes_from is a private utility; the simulator public interface is unchanged.

Test Plan

  • All 837 PyAutoArray unit tests pass
  • Workspace parity scripts: simulator_use_jax_parity.py (imaging + interferometer) with @jax.jit roundtrip enabled (workspace follow-up)
  • Smoke tests on autolens_workspace_test
Full API Changes (for automation & release notes)

Changed Behaviour (internal)

  • autoarray.structures.arrays.array_2d_util.array_2d_via_indexes_from — JAX path now uses 2D advanced indexing instead of tuple(...T). Semantically identical; now jit-traceable.
  • autoarray.dataset.imaging.simulator.SimulatorImaging.via_image_from — removed the if xp is np: .native else: .array guard; always uses .native (now safe under JIT).

Removed (docstring caveats only)

  • SimulatorImaging.__init__ docstring: removed "@jax.jit wrapping is currently blocked" note
  • SimulatorInterferometer.__init__ docstring: removed "@jax.jit wrapping is currently blocked" note

🤖 Generated with Claude Code

Replace tuple(native_index_for_slim_index_2d.T) with 2D advanced
indexing on the JAX path — the tuple() call iterates the outermost
axis of a traced array, triggering TracerArrayConversionError under
@jax.jit. Remove the temporary if/else workaround in the imaging
simulator and the "jit blocked" docstring caveats.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace_test#123

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace#208

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autogalaxy_workspace#104

@Jammy2211
Jammy2211 merged commit 699d7a6 into main May 25, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/array2d-native-jit-safety branch May 25, 2026 10:13
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant