Skip to content

fix: drop stale enable_pytrees/register_model advice from searches/mcmc.py #184

Closed

Description

@Jammy2211

Overview

scripts/searches/mcmc.py (and its generated notebook) still tells users to call enable_pytrees() / register_model(model) before running BlackJAXNUTS. Neither is exposed on af, Fitness.__init__ already calls both internally, and scripts/searches/mle.py in the same workspace says the opposite ("No JAX pytree registration of the model is needed"). The PyAutoFit half of this bug (stale advice in the NUTS/SMC error strings) is already fixed on main; this issue covers the workspace half only.

Plan

  • Remove requirement 2 (pytree registration) from the BlackJAXNUTS prose in scripts/searches/mcmc.py, leaving use_jax=True as the one requirement and noting that registration happens internally.
  • Delete the from autofit.jax.pytrees import enable_pytrees, register_model import and the two calls.
  • Regenerate the matching cells of notebooks/searches/mcmc.ipynb the same way.
  • Run the NUTS section of the script to confirm the fit still runs without the explicit calls.

Tier: glance — merge mode: auto-merge on green if the Witness passes, post-merge summary

Detailed implementation plan

Affected repositories

  • autofit_workspace (primary, only)

Work classification

Workspace (bug). Library half verified done on PyAutoFit@362ee746: git grep enable_pytrees autofit/ hits only autofit/jax/ and autofit/non_linear/fitness.py:330-333 (the internal call); BlackJAXNUTS with use_jax=False raises SearchException naming use_jax=True only.

Branch survey

Repository Current Branch Dirty?
autofit_workspace main clean

Suggested branch: feature/stale-enable-pytrees-advice
Worktree root: ~/Code/PyAutoLabs-wt/stale-enable-pytrees-advice/

Implementation steps

  1. scripts/searches/mcmc.py ~L238-247: collapse "Two requirements" to the single use_jax=True requirement; say the model is registered as a JAX pytree automatically when the fit starts, so no extra call is needed.
  2. scripts/searches/mcmc.py L283-286: delete the import and both calls.
  3. notebooks/searches/mcmc.ipynb: same edits to the matching markdown and code cells.

Key files

  • scripts/searches/mcmc.py
  • notebooks/searches/mcmc.ipynb

Witness

grep -rn enable_pytrees autofit/ autofit_workspace/scripts/searches/ returns no user-facing advice; BlackJAXNUTS with use_jax=False raises an error naming use_jax=True only.

Original Prompt

Click to expand starting prompt

Stale enable_pytrees register_model advice in NUTS and SMC errors and searches docs

Type: bug
Target: PyAutoFit
Repos:

  • PyAutoFit
  • autofit_workspace
    Difficulty: small
    Autonomy: safe
    Priority: normal
    Status: formalised
    Consequence: glance
    Witness: grep -rn enable_pytrees autofit/ autofit_workspace/scripts/searches/ returns no user-facing advice; BlackJAXNUTS with use_jax=False raises an error that names use_jax=True only.
    Review-minutes: 3
    Unattended: ready
    Lane: any

autofit/non_linear/search/mcmc/blackjax/nuts/search.py:270 and autofit/non_linear/search/mcmc/blackjax/smc/search.py:328 tell users to call enable_pytrees() / register_model(model), and the workspace script scripts/searches/mcmc.py lines 244-247 and 283-286 do the same in prose and code. Neither function is exposed on the af namespace and Fitness.init (autofit/non_linear/fitness.py:261-265) already calls them internally; scripts/searches/mle.py:232-235 in the same workspace says the opposite. NUTS was verified to run without them on 2026-09-10. Fix the two error strings and the mcmc.py prose (the workspace half lands in autofit_workspace).

Re-scoped 2026-11-05 — what is left (draft-queue sweep)

  • Done: Library advice removed: PyAutoFit now has enable_pytrees only in jax/pytrees.py, jax/init.py and fitness.py, not in the blackjax nuts/smc searches (commit not pinned).
  • Remaining: autofit_workspace scripts/searches/mcmc.py (and its notebook) still teaches enable_pytrees() / register_model — fix the workspace leg.

Evidence from the 2026-11-05 read-only sweep (Mind ledger + GitHub search); remaining items are the live scope of this prompt.

Activity

  1. Jammy2211 commented on Nov 14, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped: merged in #185 (5267644). scripts/searches/mcmc.py and its notebook no longer tell users to call enable_pytrees() / register_model(model); Fitness.__init__ registers the model automatically for any JAX analysis. The PyAutoFit half (NUTS/SMC error strings) was already fixed on main.

    Independent close-out witness: no enable_pytrees / register_model hits in scripts/searches/ or notebooks/searches/ at the PR head; BlackJAXNUTS with use_jax=False raises a SearchException that names use_jax=True only. CI 7/7 green, Heart dev-ship green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions