Repository navigation
Description
Overview
Likelihood-lifecycle epic, phase 5A (PyAutoNerves only). Phase 5 bakes the Pulse-designated optimal compute setup into the source as setup="auto"; 5A lays the environment layer underneath it: a hardware probe, PYAUTO_SETUP honoured at import, and the JAX_ENABLE_X64=False opt-out bug fixed (ruling R4 depends on it). 5A detects and honours overrides only; it chooses nothing (choice is 5B Setup.auto in PyAutoArray).
Plan
- Add
autonerves.environment.Environment.detect(): GPU (present, name, memory), usable cores, RAM, numba / nufftax availability, site hint. Reports only. jax_wrapperhonoursPYAUTO_SETUP=auto|cpu|gpu|<setup_id>at import: an explicit CPU intent pins JAX to CPU and sets thread variables before JAX initialises;auto/unset/gpuset nothing; invalid values raise a clear error.- Fix x64:
JAX_ENABLE_X64=False|0is respected; unset still forces x64 on. - Docstrings only (workspace prose is 5F). Ship to an open pending-release PR.
- Tier + merge mode: effective level: supervised; merge mode: human /prm
Detailed implementation plan
Affected Repositories
- PyAutoNerves (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoNerves | main | clean |
Suggested branch: feature/likelihood-lifecycle-p5a-nerves
Implementation Steps
autonerves/environment.py(new): frozenEnvironmentdataclass (gpu,gpu_name,gpu_memory_gb,cores,ram_gb,numba,nufftax,site) +Environment.detect(). cores =SLURM_CPUS_PER_TASK→os.sched_getaffinity(0)→os.cpu_count(); RAM from/proc/meminfo(fallbackos.sysconf); numba/nufftax viaimportlib.util.find_spec(no import); GPU viajax.devices()only whenjaxis already insys.modules, else onenvidia-smiquery with a timeout (documented); site =SLURM_CLUSTER_NAMEor hostname class, reusingsite_configdetection.autonerves/jax_wrapper.py: parsePYAUTO_SETUPbefore anything can import JAX via a reusableparse_setup_intent()(5B reuses it).cpu, or a<setup_id>(<backend>_<device>_<operator>_<precision>[_<transformer>], report §3.1) whose device token iscpu, setsJAX_PLATFORMS=cpuandOMP/MKL/OPENBLAS/NUMBA_NUM_THREADSto the detected cores, only where unset (never overwriting a user value).auto/unset/gpuare no-ops. Invalid → error naming the allowed forms.- x64 block: explicit
False/0stays False (one log line noting fp32 was requested); unset → forced True as today; explicitTrue/1untouched. - Tests:
test_autonerves/test_environment.py(monkeypatched env vars, affinity, missing /proc, absent optional packages; one test per branch); subprocess import tests forPYAUTO_SETUP(JAX_PLATFORMS, thread vars, no overwrite, no-op cases, invalid error); subprocess x64 tests (False,0, unset,True→jax.config.read("jax_enable_x64")). Full suite green. - ship_library → open PR (pending-release); merge is the human's
/prm.
Key Files
autonerves/environment.py— new probeautonerves/jax_wrapper.py— PYAUTO_SETUP + x64 fixautonerves/site_config.py— existing site detection to reusetest_autonerves/test_environment.py,test_autonerves/test_jax_wrapper.py
Note: CPU-intent thread defaults are the detected cores (right for a single process); Nautilus numba workers pin their own threads, so this never overrides that.
Original Prompt
Click to expand starting prompt
Likelihood lifecycle phase 5A: PyAutoNerves environment probe, PYAUTO_SETUP honoured at import, and the x64 opt-out bug
Type: feature
Target: PyAutoNerves
Repos:
- PyAutoNerves
Themes: - hpc-gpu
- profiling
Difficulty: medium
Autonomy: supervised
Priority: high
Status: draft
Consequence: judge
Witness: PyAutoNerves main carriesautonerves.environment.Environment.detect()returning gpu, gpu_name, gpu_memory_gb, cores (SLURM_CPUS_PER_TASK, then sched_getaffinity, then cpu_count), ram_gb, numba, nufftax and a site hint, each branch covered by a unit test with the environment monkeypatched;jax_wrapperhonoursPYAUTO_SETUP=auto|cpu|gpu|<setup_id>at import (explicit cpu/numba intents set JAX_PLATFORMS=cpu and the *_NUM_THREADS variables before JAX initialises;autoand unset set nothing), checked by subprocess import tests; underJAX_ENABLE_X64=False(and0) importing autonerves leavesjax.config.read("jax_enable_x64")False while unset still forces x64 on, checked by a subprocess test; full test suite green
Review-minutes: 20
Unattended: ready
Lane: any
Gate: MET 2026-11-16 — human ruled phase 4 closed (gaps listed), approved report §3.4 and R6 = opt-in first (ledger line 2026-11-16). Ran after the wall-estimate bug, per the human — that bug is fixed (complete/2026/11/validation-wall-estimates-miss-eval-count-and-sampler-floor.md, autolens_inference#70, merged 2026-11-16).
Epic: likelihood-lifecycle
Phase: 5
Parent: draft/research/autolens_profiling/likelihood_lifecycle_epic.md
Filed: 2026-11-16
Context
- Phase 5 (epic ledger): optimal setup baked into the source, library first: 5A PyAutoNerves → 5B PyAutoArray → 5C PyAutoGalaxy + PyAutoLens → 5D PyAutoFit → 5E estimator → 5F workspace/HowToLens → 5G assistant → 5H science projects. This prompt is 5A only. One issue in PyAutoNerves.
- Design: report §3.5 (
draft/research/autolens_profiling/likelihood_lifecycle_epic_report.md), the PyAutoNerves row:autonerves.environment.Environment.detect()→ gpu (bool), gpu_name, gpu_memory_gb, cores (SLURM_CPUS_PER_TASK → sched_getaffinity → cpu_count), ram_gb, numba, nufftax, site hint (SLURM_CLUSTER_NAME, hostname class).jax_wrapperhonoursPYAUTO_SETUP=auto|cpu|gpu|<setup_id>at import: only explicit cpu/numba intents setJAX_PLATFORMS=cpuand the*_NUM_THREADSvariables before JAX initialises;autosets nothing at import (JAX picks the GPU when present).
- Boundary (report §3.4): auto decides backend, device, operator, precision, route, threads and default cores; it never touches the model, the sampler or the HPC request, and an explicit override (
PYAUTO_SETUP=<setup_id>) always wins. 5A only detects and honours the override; it chooses nothing (choice is 5BSetup.auto). - The x64 bug is adopted into 5A (ledger "Adopted":
draft/bug/autonerves/jax_enable_x64_env_ignored_and_fp32_leg_runs_fp64.md→ 5A). Root cause in@PyAutoNerves/autonerves/jax_wrapper.py(theJAX_ENABLE_X64block: an explicitFalseis overwritten withTrue). 5A fixes the Nerves root cause only; that draft's PyAutoFitpreflight.pyX64_WARNINGtext and the autofit_inference fp32 row check stay in that draft (narrow it when 5A merges). Ruling R4 (mixed precisionexperimentaluntil the x64 bug is fixed) depends on this fix. - Existing neighbours, read before designing:
@PyAutoNerves/autonerves/site_config.pyandautonerves/site/ral.yaml(site layer); the thread-pinning lessons in Brain memory (numba under Nautilus is one process per core; never prange inside multiprocessing workers; OMP does not cap numba).
Plan
autonerves/environment.py: frozen dataclassEnvironment+detect(); no JAX import insidedetect()beyond what is already initialised (GPU facts read lazily or viajax.devices()only when JAX is already imported; document which). Unit tests with monkeypatched env vars, affinity and missing optional packages.jax_wrapper.py: readPYAUTO_SETUPbefore JAX initialises; implement the cpu/numba intents (JAX_PLATFORMS=cpu, thread variables set only when absent, never overwriting a user value);auto/unset is a no-op. Invalid values raise a clear error naming the allowed forms.- x64: respect an explicit
JAX_ENABLE_X64=False|0; keep forcing x64 on when unset; update the log message to match. - Docs: docstrings only (workspace prose is 5F). Changelog/pending-release note per ship_library.
- Ship via ship_library to an open PR (pending-release). Stop at PR-open; merge is the human's
/prm.
Out of scope
aa.Setup, Setup.auto, the rule table and apply_setup (5B); setup="auto", banner and setup.json (5C); number_of_cores="auto" (5D); the estimator (5E). No compute; no RAL.
Activity
Jammy2211 commentedon Nov 23, 2026
Library PR created — awaiting human /prm
PR: #223 (pending-release), commit 32ee087.
Gate:
test_autonerves375 passed (80 in test_environment.py / test_jax_wrapper.py, including subprocess import tests for PYAUTO_SETUP and for x64 under False, 0, unset and True).pyauto-heart smoke --affected-by PyAutoNerves, run against the task worktree: 8/8 workspaces PASS (autofit, autogalaxy, autolens, autolens_test, euclid, howtolens, autocti, autocti_test).Workspace impact: none needed.
PYAUTO_SETUPis new and opt-in. The three callers that setJAX_ENABLE_X64=False|0(autofit_inference CLI fp32 legs, the autolens_profiling point-source fp32 what-if, and the PyAutoFit preflight warning text) do it because they want fp32, which they now actually get.Tier: judge, so the merge is the human's
/prm. After the merge, narrowdraft/bug/autonerves/jax_enable_x64_env_ignored_and_fp32_leg_runs_fp64.mdto its PyAutoFit/autofit_inference remainder, and file 5B (PyAutoArrayaa.Setup,Setup.auto).Jammy2211 commentedon Nov 23, 2026
Shipped
Merged PyAutoNerves#223 → main (db589c2), via human /prm. Pending release.
autonerves.environment:Environment.detect()andparse_setup_intent()(which 5B reuses)PYAUTO_SETUPread at import: a CPU intent sets JAX_PLATFORMS and the thread variables only where unsetJAX_ENABLE_X64=False|0is now respected; unset still turns x64 onNext in the epic: 5B, PyAutoArray
aa.Setup/Setup.auto.