Skip to content

refactor: NSS onto Fitness, trace preflight and x64 check (search-extensibility A3b) #1678

Closed

Description

@Jammy2211

Overview

Phase A3b: NSS onto Fitness via the factory with traced assertions, the eval_shape trace preflight per declared kind after the test-mode bypass with chained tracebacks, the x64 warning, and Dynesty's single-core RuntimeError control flow replaced by an explicit sentinel that no longer swallows XlaRuntimeError. Depends on A2 and A3. Launched --auto by the human on 2026-10-08; effective level safe (refactor cap); Tier: judge.

Plan

"A3b — NSS onto Fitness, trace preflight, x64 (depends on A2 and A3; surveys/02 P3; D2, D8). Repo: PyAutoFit. Scope: NSS onto Fitness via the factory (traced assertions; the sanity check moves to the start of the run); the eval_shape trace preflight per declared kind, after the test-mode bypass, chained tracebacks, plus the optional numerical probe; the x64 check; Dynesty's RuntimeError single-core control flow becomes an explicit sentinel that no longer catches XlaRuntimeError. Risk: low-medium. Verify: NSS with assertions under jit; the preflight raises on an np.asarray likelihood with the original error chained; an fp32 warning test; the D2 smoke-profile regression test. Witness: NSS fits gaussian_x3_blend with its ordered-centre assertions under JAX."

Tier: judge — merge mode: human /prm, after A2 and A3

Detailed implementation plan

Affected Repositories

  • PyAutoFit (library, pending-release)

Branch Survey

All affected canonical checkouts on main, clean (verified 2026-10-08 before the worktree was created).

Suggested branch: feature/search-ext-a3b-nss-preflight (stacked on A2+A3) (worktree ~/Code/PyAutoLabs-wt/search-ext-a2-objective-bridge (after A2 and A3))

Implementation Steps

See the prompt's Pins, Verification and Shape sections (embedded below); commit in the order the Shape names.

Validation checklist (--auto run — plan was not pre-approved)

  • Effective level: safe (refactor cap)
  • Gate legs recorded in the PR body at ship

Original Prompt

Click to expand starting prompt

NSS onto Fitness, trace preflight and x64 check (epic search-extensibility, phase A3b)

Type: refactor
Target: autofit
Repos:

  • PyAutoFit
    Themes:
  • searches
  • jax
    Difficulty: medium
    Autonomy: safe
    Consequence: judge
    Witness: NSS fits gaussian_x3_blend with its ordered-centre assertions under JAX (the autofit_inference harness's blend model, 10 parameters) and the A0a conformance layers pass for NSS through Fitness.objective; the preflight raises on an np.asarray likelihood with the original tracer error chained; the D2 regression (REQUIRED + PYAUTO_DISABLE_JAX=1 + PYAUTO_TEST_MODE=2 completes) still passes
    Unattended: ready
    Priority: high
    Epic: search-extensibility
    Blocked-by: search-ext-a2-objective-bridge, search-ext-a3-samples-checkpointer (PyAutoFit; both must be on the branch this stacks on)
    Status: draft
    Filed: 2026-10-08

Human launch 2026-10-08: --auto for A2, A3, A3b and B3. Plan draft/research/autofit/search_extensibility_epic_report.md §4 (phase text quoted verbatim below), architecture §3.3–§3.5, decisions in §8. A0, A0c, A1 and B2 are merged (A1: capability attributes, Analysis.is_jax, REQUIRED gate, registry/manifest, docs/design/run_ctx.md frozen). Golden identifiers (A0a(i)) are frozen by human ruling: any identifier change stops the item and is flagged. The nine A0 strict xfails are witnesses: flip only the ones a phase names, never add silent ones. Depends on A2 (objective factory) and A3 (adapter/checkpointer); implemented stacked on a branch that carries both.

Original request (verbatim from the epic plan)

"A3b — NSS onto Fitness, trace preflight, x64 (depends on A2 and A3; surveys/02 P3; D2, D8). Repo: PyAutoFit. Scope: NSS onto Fitness via the factory (traced assertions; the sanity check moves to the start of the run); the eval_shape trace preflight per declared kind, after the test-mode bypass, chained tracebacks, plus the optional numerical probe; the x64 check; Dynesty's RuntimeError single-core control flow becomes an explicit sentinel that no longer catches XlaRuntimeError. Risk: low-medium. Verify: NSS with assertions under jit; the preflight raises on an np.asarray likelihood with the original error chained; an fp32 warning test; the D2 smoke-profile regression test. Witness: NSS fits gaussian_x3_blend with its ordered-centre assertions under JAX."

Pins

Survey 02 §5.3: preflight = jax.eval_shape(objective, prior-median vector) (+ eval_shape(grad) when gradient == uses), one trace, no compile; raise naming the tracer error and the search, raise ... from e; it is a trace preflight, not a validity certificate; the optional numerical probe is separate. x64: warn once when analysis.is_jax and not jax.config.jax_enable_x64 (raise only if a search declares requires_fp64; none do today). Placement: after the test-mode bypass and after A1's REQUIRED gate. Dynesty: survey 01 §8 "Single-core control flow" (dynesty/abstract.py raise RuntimeError inside a try) → explicit sentinel exception class; except RuntimeError must no longer swallow XlaRuntimeError. NSS sanity check: moves to the start of run.

Verification

Full pytest test_autofit; nojax emulation; afT searches/NSS.py, Dynesty_jax.py, Nautilus_jax.py under test mode; the autofit_inference blend NSS fit (run _runner.run_search from the canonical fit/autofit_inference checkout with sampler=NSS, local_jax_cpu_fp64, test-mode budget) completing with assertions.

Shape

One PyAutoFit PR (pending-release) based on the A2+A3 integration branch; merges after both. Tier judge.

Activity

  1. Jammy2211 commented on Oct 8, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged 2026-10-08 via /prm, after A2 (#1679) and A3 (#1680): #1681 (label pending-release: it is on main but not yet on PyPI).

    • NSS now samples through Fitness.objective (via make_fitness) and runs on run(ctx) + raw_samples_from. It resumes from NativeFileCheckpointer("nss_checkpoint.pkl"). Assertions are traced, so NSS no longer raises TracerBoolConversionError under jit.
    • New autofit/non_linear/search/preflight.py:
      • trace_preflight runs a jax.eval_shape of each declared objective kind. It runs after the test-mode bypass and the REQUIRED gate. A likelihood that cannot be traced raises a SearchException chained to the tracer error.
      • check_x64 warns once when x64 is off, and raises when a search sets requires_fp64=True.
    • Dynesty now chooses its single-core path with an explicit _SingleCoreRun sentinel. A RuntimeError or XlaRuntimeError raised mid-run no longer silently restarts the run single-core.

    Witness (run on a983123): PASS

    • Leg 1: NSS fits gaussian_x3_blend under JAX on CPU at fp64.
      • Default settings (n_live 200, 5 MCMC steps) are not good enough. Seed 0 is correct (ln Z 133.98), seed 1 lands in the wrong mode, and seed 2 is about 27 nats low.
      • n_live 200 with 50 MCMC steps gives ln Z 135.35, 137.62 and 135.67 on seeds 0–2, with all centres correct. That is inside the reference spread (Nautilus 137.06/137.07, Dynesty 134–139.7).
      • The harness verdict is not_assessed because the jax_cpu reference is still pending.
      • Pre-A3b main fails the same fit with TracerBoolConversionError.
    • Leg 2: conformance -k NSS, 16 passed.
    • Leg 3: a real NSS fit on an np.asarray JAX likelihood raises a chained SearchException in 0.05 s.
    • Leg 4: the D2 regression passes for all 7 required searches.
    • The x64 check warns once, and raises with requires_fp64=True.
    • Full suite: 3555 passed, 1 skipped, 4 xfailed.

    Follow-ups filed in Mind (not fixed here):

    1. The x64 warning text at preflight.py:65-66 is wrong. autonerves/jax_wrapper.py forces x64 on for any value that is not "true".
    2. The autofit_inference local_jax_cpu_fp32 config actually runs fp64.
    3. When the NSS deferral is lifted, the inference settings need at least 50 MCMC steps.

    Next in the epic: A4 or B4 (human to choose).

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