Skip to content

Commit 4b2decd

Browse files
Jammy2211claude
authored andcommitted
docs: registration is the caller's job — correct stale auto-call claims
The autolens/jax/registration.py module docstring claimed register_tracer_classes "is called automatically by PointSolver(use_jax=True).solve(tracer, ...) on the first invocation and by Simulator(use_jax=True).via_tracer_from(tracer, ...) ... once Phase 2 ships the Simulator changes". Neither is true. grep finds no caller anywhere in autolens. And it cannot be done automatically: PointSolver.solve_triangles already carries the reason at its own call site (point_solver.py:102-109) — JAX flattens a jitted function's arguments at trace time, before entering the callee, so registration must run before the first jitted call. Corrected to state that calling it is the user's responsibility, with the trace-time reason, and to cross-reference the new autogalaxy counterpart autogalaxy.jax.register_galaxies_classes (PyAutoGalaxy#537). Docstring only — no behaviour change, no API surface. Refs PyAutoLabs/autolens_workspace#379 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CWqjHGXUut25TEB8octU8H
1 parent 82afda6 commit 4b2decd

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

autolens/jax/registration.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
88
This module is the counterpart of ``AnalysisImaging._register_fit_imaging_pytrees``
99
for code paths that do not go through ``Analysis`` (point-source solving,
10-
custom forward models, hand-built simulators). It is called automatically
11-
by ``PointSolver(use_jax=True).solve(tracer, ...)`` on the first invocation
12-
and by ``Simulator(use_jax=True).via_tracer_from(tracer, ...)`` in PyAutoLens
13-
once Phase 2 ships the Simulator changes.
10+
custom forward models, hand-built simulators).
11+
12+
**Calling it is the user's responsibility.** Nothing in the library calls it
13+
for you, and nothing can: JAX flattens a jitted function's arguments at trace
14+
time, i.e. *before* entering the callee, so a ``solve()`` or
15+
``via_tracer_from()`` that registered internally would already be too late.
16+
``PointSolver.solve_triangles`` carries the same note at its own call site.
17+
Register once, before the first ``@jax.jit`` invocation.
18+
19+
The autogalaxy counterpart is ``autogalaxy.jax.register_galaxies_classes``.
1420
1521
Mirrors PyAutoFit's ``autofit/jax/pytrees.py`` layout. Idempotent: re-registration
1622
of a class is a silent no-op.

0 commit comments

Comments
 (0)