docs: correct false simulator-JAX claims (registration, eager-on-JAX, TransformerNUFFT) - #380
Merged
Merged
Conversation
… NUFFT) Four claims in this workspace's JAX docs were false. All measured against the installed stack. 1. "The simulator handles pytree registration internally" — no simulator anywhere registers pytrees (autolens, autogalaxy and autoarray bases: zero `register` hits), so the documented @jax.jit wrap fails with `TypeError ... value is of type Tracer`. It is also unimplementable as worded: JAX flattens a jitted function's arguments at trace time, before entering the callee, so registration must precede the first jitted call. PointSolver.solve_triangles already documents exactly this. 2. "eager via_tracer_from(...) already runs on JAX" — eager with use_jax=True returns dataset.data.array of type numpy.ndarray, not jax.Array. 3. The @jax.jit simulator recipe does not work even WITH correct registration: it dies inside autoarray (preprocess.py:153, then array_2d_util.py) on sites that do not thread xp. Separate library bug, filed separately. The docs now say so and point at the eager call. 4. `TransformerNUFFT is not JAX-traceable` — shipped backwards in #375 this morning, inherited from the old __JAX__ blocks. Per autoarray's own error text TransformerNUFFT IS the default JAX-native (nufftax-backed) transformer; TransformerNUFFTPyNUFFT is the legacy pynufft one. Defaults differ by class: SimulatorInterferometer -> TransformerDFT, Interferometer -> TransformerNUFFT. scripts/interferometer/simulator.py already had this right, so #375 contradicted a sibling script. Wording is mirrored from the two scripts that already get this right — point_source/simulator.py and cluster/simulator.py — which are left untouched. In imaging/ and interferometer/simulator.py the dead `@jax.jit def simulate(...)` cells are removed rather than corrected: they defined a function that was never called (the call was commented out), which is why the claim survived unnoticed. The use_jax=True constructor stays a live cell, since that part works. Closes #379 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CWqjHGXUut25TEB8octU8H
2 tasks
…ator-jax-claims # Conflicts: # workspace_index.json
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
Corrects four false JAX claims in this workspace's docs. All measured against the
installed stack — nothing here is a style change.
Closes #379 (in part; the autogalaxy half is PyAutoLabs/autogalaxy_workspace).
1. "The simulator handles pytree registration internally" — false
No simulator anywhere registers pytrees:
grep -rn registerover both autolenssimulators, both autogalaxy simulators and both autoarray bases returns zero
hits. The documented
@jax.jitwrap fails immediately withTypeError ... value is of type Tracer.It is also unimplementable as worded, and
PointSolver.solve_trianglesalready says why at its own call site:
2. "eager
via_tracer_from(...)already runs on JAX" — falseEager with
use_jax=Truesucceeds but returnsdataset.data.arrayof typenumpy.ndarray, notjax.Array.3. The
@jax.jitsimulator recipe does not work at allEven with correct registration it dies inside autoarray
(
preprocess.py:153, thenarray_2d_util.py) on sites that do not threadxp.That is a separate library bug, filed separately. The docs now say so and point
readers at the eager call, instead of presenting a recipe that cannot run.
4.
TransformerNUFFTis not the un-traceable one — this repo shipped it backwards today#375 (merged this morning) put "
TransformerDFT(the default).TransformerNUFFTis not JAX-traceable." intoguides/using_jax.py. Inheritedfrom the old
__JAX__blocks and wrong. Per autoarray's own error textTransformerNUFFTis "the default JAX-native" transformer (nufftax-backed;nufftax 0.3.1 installed) and
TransformerNUFFTPyNUFFTis "the legacy pynufftbackend". Defaults also differ by class:
SimulatorInterferometer→TransformerDFT;Interferometer, which a fit uses →TransformerNUFFT.scripts/interferometer/simulator.pyalready had this right, so #375 contradicteda sibling script.
Approach
The wording is mirrored from the two scripts that already get this right —
scripts/point_source/simulator.py__JAX Variant (Advanced)__andscripts/cluster/simulator.py__JAX JIT__— both of which state the one-timesetup, call
register_tracer_classes(tracer), and give the trace-time reason.Those two files are deliberately untouched.
In
imaging/andinterferometer/simulator.pythe dead@jax.jit def simulate(...)cells are removed rather than corrected: they defined a function that was never
called (
# dataset_jax = simulate(tracer)was commented out), which is exactlywhy the claim survived so long. The
use_jax=Trueconstructor stays as a livecell, since that part works.
Scripts Changed
scripts/guides/using_jax.py— rewrote__Writing @jax.jit Yourself__item 1 (claims 1-3); fixed the NUFFT sentence in__Custom Likelihood Functions__(claim 4)scripts/guides/tracer.py— split the "implicit path" section: registration-as-side-effect is true forAnalysis.fit_from, false forSimulator.via_tracer_fromscripts/imaging/simulator.py— claims 1-3; removed the never-called jitted cellscripts/interferometer/simulator.py— claims 1-3; removed the never-called jitted cell; its already-correct nufftax paragraph keptscripts/group/simulator.py— claim 1 (stub pointing at imaging)scripts/multi_galaxy/simulator.py— claim 1 (stub pointing at imaging)Notebooks,
llms-full.txtandworkspace_index.jsonregenerated viaPyAutoHands/autohands/generate.py.Not touched:
point_source/simulator.py,cluster/simulator.py— already correct.Upstream PR
PyAutoLabs/PyAutoLens#665 — the same stale auto-call claim
in
autolens/jax/registration.py's module docstring. Docstring-only with zero APIsurface, so nothing here imports new API; merge order does not actually matter,
but the library PR is trivial and can go first.
Test Plan
py_compileon every touched filescripts/check_sizes.shcleanpytree registration internally,already runs on JAX, and the reversed NUFFT claimGenerated by the PyAutoLabs agent workflow.