Repository navigation
refactor: NSS onto Fitness, trace preflight and x64 check (search-extensibility A3b, stacked on A3) - #1681
Merged
Conversation
NSS samples through its fit's scalar objective (Fitness.objective via
make_fitness, from its declared objective_target and invalid_value) instead
of the inline nss_log_likelihood_from closure, so it shares the one guard
path: NaN/inf, the configured magnitude ceiling and the traced xp.where
assertion penalty (an assertion no longer raises TracerBoolConversionError
under jit). NSS moves onto run(ctx) + raw_samples_from, resuming from
ctx.resume (its NativeFileCheckpointer("nss_checkpoint.pkl")); the bridge
builds the Fitness before sampling, so the resume likelihood sanity check
now runs at the start of the run. make_fitness is the only Fitness
construction site left under autofit/non_linear/search. The bridge repeats
the REQUIRED gate before building the Fitness for direct _fit callers.
Removed: nss_log_likelihood_from (no external users).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
NonLinearSearch.start_resume_fit, after the test-mode bypass and the REQUIRED gate, now runs (autofit/non_linear/search/preflight.py, only for a JAX analysis): - check_x64: warn once per process when jax_enable_x64 is off; raise for a search declaring the new capability requires_fp64 (default False, none set; added to the manifest, schema-compatible); - trace_preflight: one jax.eval_shape of the declared objective kind (batched for a batched search, else scalar) at the prior medians, plus its gradient kind when gradient == uses; no compile or execution. A non-traceable likelihood raises SearchException naming the search and the kind, chained (raise ... from e) to the tracer error. PYAUTO_JAX_PREFLIGHT=0 skips it; PYAUTO_JAX_PREFLIGHT_PROBE=1 adds an eager numerical probe at the prior medians (off by default) that warns on the invalid value. run_ctx.md gains Revision 2 (NSS on the bridge, the bridge's REQUIRED gate, the preflight placement); signature and members unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
AbstractDynesty._fit selected its single-core path with `raise RuntimeError` inside a try, so `except RuntimeError` also caught any RuntimeError raised while a pooled run executed (genuine dynesty errors, JAX's XlaRuntimeError) and silently restarted the run single-core. The control flow is now the private _SingleCoreRun sentinel (not a RuntimeError subclass); only a RuntimeError from creating the pool still falls back, chained as its cause. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ness) into A3b Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from
feature/search-ext-a3-samples-checkpointer
to
main
October 8, 2026 19:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1678
Search-extensibility phase A3b. Stacked on A3 (#1680, itself stacked on A2 #1679): review and merge those first. The diff against
feature/search-ext-a3-samples-checkpointeris the three commits below plus a merge of the updated A3 branch.Summary
Fitnessandrun(ctx)(aeadaae48)Fitness.objectiveviamake_fitness, from its declaredobjective_targetandinvalid_value). It no longer uses the inlinenss_log_likelihood_fromclosure, so NSS shares the one guard path: NaN/inf handling, the configured magnitude ceiling and the tracedxp.whereassertion penalty. An assertion no longer raisesTracerBoolConversionErrorunderjit.run(ctx)+raw_samples_fromand resumes fromctx.resume(NativeFileCheckpointer("nss_checkpoint.pkl")).Fitnessbefore sampling. The resume likelihood sanity check therefore runs at the start of the run.make_fitnessis now the only place underautofit/non_linear/searchthat builds aFitness.nss_log_likelihood_from, which had no external users.8bc269743, newautofit/non_linear/search/preflight.py). For a JAX analysis only, these run instart_resume_fitafter the test-mode bypass and the REQUIRED gate.check_x64warns once per process whenjax_enable_x64is off. It raises for a search declaring the newrequires_fp64capability (defaultFalse; no search sets it).trace_preflightruns onejax.eval_shapeof the declared objective kind (batched or scalar) at the prior medians, plus the gradient kind whengradient == uses. Nothing is compiled or executed.SearchException, which names the search and the kind and is chained to the tracer error.PYAUTO_JAX_PREFLIGHT=0skips the preflight.PYAUTO_JAX_PREFLIGHT_PROBE=1adds an eager numerical probe, off by default.docs/design/run_ctx.mdgains Revision 2. The signature and members are unchanged.c89cbc430)AbstractDynesty._fitchose the single-core path by raising aRuntimeErrorinside atry. That meant anyRuntimeErrorraised during a pooled run (including JAX'sXlaRuntimeError) silently restarted the run single-core._SingleCoreRunsentinel. Only aRuntimeErrorfrom creating the pool still falls back, chained as the cause.Tests run
pytest test_autofit -q -xon the merged branch (local, numpy 2.2.6, JAX present): 3555 passed, 1 skipped, 4 xfailed.nss/test_nss_fitness.py: assertions underjit, plus an NSS fit with assertions underjit.test_preflight.py:np.asarraylikelihood raises with the error chained;requires_fp64is set.nest/test_dynesty_single_core_sentinel.py.nss/test_checkpoint.py,nss/test_log_likelihood_ceiling.pyandtest_make_fitness.py.gaussian_x3_blendwith its ordered-centre assertions through theautofit_inferenceharness). The unit-scale analogue (test_nss_fit_with_assertions_runs_under_jit) passes.Decisions taken
requires_fp64(defaultFalse, no search sets it): added to the manifest in a schema-compatible way. fp32 only warns until a search opts in.PYAUTO_JAX_PREFLIGHT_PROBE=1turns it on). The default preflight stayseval_shapeonly, with no likelihood evaluation, so it costs no compile.REQUIRED+PYAUTO_DISABLE_JAX=1+PYAUTO_TEST_MODE=2completes) is untouched.Fitness, for callers that invoke_fitdirectly.nss_log_likelihood_fromremoved outright rather than deprecated, because it had no external users.RuntimeErrorraised while creating the pool. A failure during the run now surfaces instead of silently restarting single-core.🤖 Generated with Claude Code