Repository navigation
Description
Overview
ClipperPriorBoxJoint is refused outright whenever a scaler or bijector is set — at construction in multi_start_gradient/search.py:365-384 and again at projection time in clipper.py:522-535. The refusal is stronger than the geometry requires: a coordinate whose bijector kind is identity with linear scale s maps a disk of radius R to a disk of radius R / s, which is still a disk and still exactly projectable. Only a genuinely non-linear pair (log, logit, or two identity coordinates with different scales, which gives an ellipse) has no closed form.
The cost is concrete: any gradient arm that wants a log/logit reparameterisation anywhere in the model must drop the joint clipper entirely, so its ell_comps lanes settle at the box corner |e| = 1.414 — outside the disk, where the axis-ratio conversion saturates and the gradient is flat. Phase 8B's log_reg arms do exactly this.
Plan
- Teach the bijector to report, per coordinate, the linear scale it applies when (and only when) that coordinate is
identity-kind. - Replace the clipper's blanket refusal with a per-pair resolution: a ball pair whose two members are both identity-kind under a common linear scale
sis projected onto radiusR / s; anything else raises, now naming the offending index pair and its kinds. - Delete the construction-time refusal in
MultiStartGradientand move the check to model-resolution time inside_fit, so a genuinely bad combination still dies before any likelihood evaluation but a good one is simply allowed. - Do not round-trip through the bijector inside the clipper — the
logitepsilon clamps would break bit-identity on unrelated coordinates, saturate gradients, and add traced ops. - No new constructor arguments, so
__identifier_fields__and every stored result key are untouched.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main (f466dce) | clean |
Suggested branch: feature/joint-clipper-compose-with-bijector
Implementation Steps
-
autofit/non_linear/bijector.py— addAbstractBijector.identity_scalesbesidekinds(~:236-240): a list whose entryiisfloat(self._scale[i])whenself._kind_code[i] == _IDENTITYandNoneotherwise, guarded by_check_resolved(). ~12 lines. -
autofit/non_linear/clipper.py— replace the blanket raise at ~:522-535 with a_pairs_in_stepped_coordinates(pairs, scale, bijector)helper returning(i, j, radius / s)when both members of a pair share a common linear scales(read frombijector.identity_scales, or from the rawscalearray on the scaler path), and raising the existingValueError— now naming the index pair and its kinds — otherwise. Add a "Composition with a scaler/bijector" docstring section carrying theR -> R/sargument. -
autofit/non_linear/search/mle/multi_start_gradient/search.py— delete the construction-time refusal (:365-384); call the clipper helper on:884-885) and beforemodel.ball_constraint_index_pairs()inside_fit, immediately afterself.bijector.from_model(model=model)(_vmappedis built/compiled. Update theclipper/bijectordocstring paragraphs (~:148-201).bfgs/search.pyis untouched — LBFGS still refuses the joint clipper wholesale, since scipy has no ball.
Tests (NumPy only — JAX stays out of the unit suite)
test_autofit/non_linear/test_clipper.py— rewritetest__a_scaler_or_bijector_is_refused_rather_than_applied(:700) into the composition cases::774-784) from "refused at construction" to "refused at model resolution, before the first step", keeping the identifier assertions verbatim and adding one that a bijector leavesBijectorNonebit-identical to no bijector; a per-pathlogon a non-ell_compspath still projects the corner onto0.999with the angle preserved;BijectorLogiton the ball model still raises and names the pair;scale=[2,2,1]projects onto0.999/2;scale=[2,3,1]raises;BijectorDiagonal(ScalerPriorWidth())with equal widths is accepted. Restate the search-wiring tests (Identifier(...)unchanged.test_autofit/non_linear/test_bijector.py— F5 pintest__round_tripping_a_per_path_map_is_bit_exact_where_it_is_identity, right after the objective-composition test (~:388-409).test_autofit/non_linear/search/mle/test_multi_start_gradient.py— the joint clipper plus a per-path bijector constructs and is accepted at model resolution; alogit-on-ell_compscombination raises before the first step.
Key Files
autofit/non_linear/bijector.py— the per-coordinate kind/scale cache and its accessors.autofit/non_linear/clipper.py—ClipperPriorBoxJoint.project, the ball projection.autofit/non_linear/search/mle/multi_start_gradient/search.py— where the two strategies meet.
Campaign implication (not done here)
To actually use the disk, the Phase 8B logit arm must be restated as a BijectorPerPath with logit on every path except ell_comps.*. That is a config change in autolens_profiling, not a library change, and is out of scope for this issue.
Original Prompt
Click to expand starting prompt
ClipperPriorBoxJoint is refused whenever a bijector/scaler is set (multi_start_gradient/search.py:365-384, clipper.py:522-535); Phase 8B log_reg arms therefore settle at the ell_comps box corner |e|=1.414. Compose them: resolve each ball pair against the map and refuse only genuinely non-linear pairs. Also add the in-process F5 pin test.
Activity
Jammy2211 commentedon Aug 28, 2026
Library PR created
PR: #1540 (
pending-release)Commit:
11fdd4671onfeature/joint-clipper-compose-with-bijectorOption B implemented as planned, with one naming deviation: the clipper helper is
pairs_in_stepped_coordinates(public), not_pairs_in_stepped_coordinates. It is called frommulti_start_gradient/search.py, so it belongs besideproject/bounds_from_modelin the clipper's cross-module consumer API rather than behind an underscore another module has to reach through.Files
autofit/non_linear/bijector.py+30 / -1— newidentity_scalespropertyautofit/non_linear/clipper.py+139 / -13—pairs_in_stepped_coordinates,projectcomposes, "Composition with a scaler/bijector" docstringautofit/non_linear/search/mle/multi_start_gradient/search.py+49 / -20— construction refusal deleted, check moved into_fit, docstrings updatedtest_autofit/non_linear/test_clipper.py+206 / -20test_autofit/non_linear/test_bijector.py+44 / -0(F5 pin)test_autofit/non_linear/search/mle/test_multi_start_gradient.py+75 / -0Validation
test_autofit/full: 2301 passed, 3 skipped (basef466dce1a: 2288/3 → +13 tests), 80s.test_autogalaxy/profiles716 passed;test_autolens/analysis62 passed.|e| = 0.999underjit/vmap, 874 clipped lane-steps (so the assertion is not vacuous), 0 NaN value/grad lane-steps. Thelogit-on-ell_compscounterfactual raises before the first step and names the pair.Note on formatting
The base files were not black-25.1.0-clean, so a plain
blackrun produced unrelated re-wrap churn in all five touched files. That churn was reverse-patched out — the diff is change-only.Follow-up (not here)
The Phase 8B
logitarm must be restated as aBijectorPerPathwithlogiton every path exceptell_comps.*to actually use the disk — anautolens_profilingconfig change.Shipped under the human-authorised Heart RED override; the sole red reason is
"release validation FAILED (stage integrate)", unrelated to this change. Not merged — awaiting CI and review.Jammy2211 commentedon Aug 28, 2026
Shipped
Merged in PR #1540 (merge commit
54aa087→main).ClipperPriorBoxJointwas refused outright whenever ascalerorbijectorwas set — at construction inMultiStartGradient.__init__and again at projection time inClipperPriorBoxJoint.project. That refusal was stronger than the geometry requires: a ball survives a common linear rescale of both its members, sincetheta_i**2 + theta_j**2 <= R**2is exactlyphi_i**2 + phi_j**2 <= (R/s)**2. Only a genuinely non-linear pair has no closed form — alog/logitkind, or two identity coordinates with different scales (an ellipse, whose nearest-point projection is the root of a quartic).What changed
autofit/non_linear/bijector.py— newAbstractBijector.identity_scales: the per-coordinate linear scale where the kind isidentity,Nonewhere it is not.Nonerather than1.0forlog/logitdeliberately, so a caller cannot compose with it silently and wrongly.autofit/non_linear/clipper.py— newClipperPriorBoxJoint.pairs_in_stepped_coordinates(pairs, scale, bijector)resolves each declared ball pair against the map, returning(i, j, radius/s)for a pair sharing one common positive linear scale and raising the existingValueError— now naming the offending index pair and its kinds — otherwise.projectcalls it in place of the blanket raise..../multi_start_gradient/search.py— the construction-time refusal is deleted; the check runs once in_fit, right afterbijector.from_model(model=model)and before_vmappedis built. Whether the two compose is a question about the model, and no model exists at construction — but this is still before any likelihood evaluation, so a bad combination does not die a minute into a multi-hour fit.bfgs/search.pyis untouched (scipy has no ball).The projection is deliberately not round-tripped through the bijector: that would drag the
logitepsilon clamps across coordinates the ball has nothing to do with, breaking the interior-point path's bit-identity, saturating gradients, and adding traced ops per step. Dividing the radius costs nothing and is exact.API changes — additive only. New
identity_scalesandpairs_in_stepped_coordinates; theMultiStartAdam(clipper=ClipperPriorBoxJoint(), bijector=...)combination no longer raises at construction — it either works or raises the sameValueErrorclass at model resolution.__identifier_fields__is unchanged, so no stored result is re-keyed (pinned by a test). Nothing in PyAutoGalaxy or PyAutoLens calls the changed methods.Validation:
test_autofit/2301 passed, 3 skipped (basef466dce1a: 2288 — +13 new tests) ·test_autogalaxy/profiles716 passed ·test_autolens/analysis62 passed. New NumPy-only tests cover composition, refusal-with-named-pair, common vs mixed scales,BijectorDiagonal(ScalerPriorWidth()), the search wiring restated to "refused at model resolution", and the F5 pin (test_bijector.py— identity coordinates round-trip with==, bit-exact; thelogone to rel 1e-12), which is what the radius-division shortcut rests on. This is also the sound, in-process F5 owed by autolens_profiling#185.A traced JAX/CPU integration run outside the unit suite confirmed the behaviour end-to-end: a
BijectorPerPath({"einstein_radius": "log"})fit whose optimum sits at|e| = 2.0held every lane at|e| = 0.999over 874 clipped lane-steps, 0 NaN; theBijectorLogitcounterfactual raised before the first step, naming the pair.Campaign implication (not in this PR): to actually use the disk, the Phase 8B
logitarm must be restated as aBijectorPerPathcarryinglogiton every path exceptell_comps.*— a config change inautolens_profiling, not a library change.Shipped under the human-authorised Heart RED override (sole red reason:
release validation FAILED (stage integrate)).Closed via PyAutoMind close-out:
complete/2026/08/joint-clipper-compose-with-bijector.md.