Skip to content

fix: exclude __exclude_identifier_fields__ attrs from model.info - #1261

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/info-exclude-identifier-fields
May 14, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/info-exclude-identifier-fields

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

model.info was including internal attributes that classes have explicitly declared as not part of the model's identity. The most visible example: every LightProfileLinear (e.g. linear Sersic) instance has a pytree_token int attribute used purely to give a stable __hash__ / __eq__ for JAX pytree flatten/unflatten round-trips. After SLaM chaining (e.g. slam_start_here.py) model.info files of later fits contained 40+ pytree_token N lines per basis profile — meaningless to a user.

LightProfileLinear (and GridSearch in PyAutoFit) already declare __exclude_identifier_fields__; the Identifier hash honors it (autofit/mapper/identifier.py) so internal attrs don't perturb the unique_id. AbstractPriorModel.info did not honor the same contract — until now.

API Changes

__exclude_identifier_fields__ now suppresses an attribute from both the unique_id hash and AbstractPriorModel.info. Previously it only affected the hash. No public symbols added, removed, or renamed; no signatures changed. Downstream libraries that already declare __exclude_identifier_fields__ (PyAutoGalaxy LightProfileLinear) get the cleaner model.info automatically without a code change.

See full details below.

Test Plan

  • New regression test test_info_honors_exclude_identifier_fields in test_autofit/mapper/test_constant.py — verified to fail without the fix and pass with it.
  • Full pytest test_autofit/ passes.
  • End-to-end SLaM run (PYAUTO_TEST_MODE=3 python autolens_workspace/scripts/guides/modeling/slam_start_here.py) before/after:
    • All 5 fits' model.info: 120 pytree_token lines (40 + 40 + 40) → 0.
    • All 5 fits' unique_id hashes (output dir names) unchanged byte-for-byte.
    • All 5 fits' model.results unchanged byte-for-byte.
    • All 5 fits' model.json semantically identical (pre-existing key-reordering noise from set-based get_arguments in PyAutoConf, unrelated to this PR).
Full API Changes (for automation & release notes)

Removed

None.

Added

None.

Changed Behaviour

  • AbstractPriorModel.info (autofit/mapper/prior_model/abstract.py) — now suppresses any leaf whose name appears in the parent object's class-level __exclude_identifier_fields__ tuple. Previously such fields rendered into the info text. The unique_id hash already honored this contract; the two are now consistent.

Migration

None — change is internal. Downstream libraries that declare __exclude_identifier_fields__ automatically benefit; those that don't are unaffected.

🤖 Generated with Claude Code

Internal attributes declared in a class's __exclude_identifier_fields__
(e.g. LightProfileLinear.pytree_token in PyAutoGalaxy, GridSearch
.number_of_cores in PyAutoFit) were leaking into model.info because
they are int-typed and live on objects walked by
path_instance_tuples_for_class. The Identifier hash already honors this
contract — model.info now does too, by walking back to each leaf's
parent and consulting its class's __exclude_identifier_fields__.

No public-API change. No downstream library changes needed:
declaring __exclude_identifier_fields__ now suppresses an attribute
from both the model identity hash and the human-readable info.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 14, 2026
@Jammy2211
Jammy2211 merged commit 4652ed8 into main May 14, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/info-exclude-identifier-fields branch May 14, 2026 18:48
@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