Skip to content

research: JAX version policy for recurring XLA:CPU deadlocks #213

Closed

Description

@Jammy2211

Overview

XLA:CPU keeps deadlocking inside compiled JAX likelihoods (a later call never returns, 0 % CPU, futex wait in CpuPjRtRawLoadedExecutable::Execute), and each occurrence has been patched locally (container flags, a Heart release-only flag, a profiling-script flag, a private RAL job script). Users' installs get none of these fixes, and the recommended baseline jax 0.11.2 still hangs. This research task finds one general policy covering the allowed JAX version range plus any default XLA CPU flags, backs it with a repeated-call hang matrix, and records it as a PyAutoDNA campaign so the policy and the environments' actual JAX versions and XLA flags are visible on the DNA board.

Heart RED development override invoked by the human on 2026-11-10 (Heart RED: PyAutoGalaxy/PyAutoLens Tests failing, workspace validation 14f). This is a research task; no library change ships from it.

Plan

  • Build one set of hang reproducers: the PyAutoPulse reproducer that needs no PyAuto code (exported group MGE prefix-3 module), group Delaunay prefix 4, the delaunay_mge multi-dataset vmap (hung even with the eigen flag in release-integrate), the PyAutoHeart#274 batched-Cholesky path, and one real HowToLens ch2 tutorial-4 MGE fit.
  • Run a hang matrix: jax 0.9.2 / 0.11.2 / 0.12.0 / 0.12.0.1 × {no flag, --xla_cpu_multi_thread_eigen=false, --xla_cpu_enable_concurrency_optimized_scheduler=false} × N=300 repeated calls, in throwaway per-version venvs (never PyAuto313 or the shared RAL install). Short laptop pilot, then a RAL CPU array (not the gpu partition).
  • Record every cell in PyAutoDNA: one stack per jax version × flag pair, one receipt per environment (dna collect --probe-backend), one validation record per stack × environment under a new DNA-written research authority (which can never trigger a promotion by itself).
  • Measure the per-call cost of each surviving flag across likelihood families (MGE, rectangular, Delaunay, interferometer, point source) at 4 cores, 8 cores and on a RAL node, in fp64, and store it as DNA evidence.
  • Check JAX/XLA upstream for an existing issue or a fix in 0.12. If there isn't one, draft an upstream issue from the reproducer for the human to approve before filing.
  • Write a DNA decision page that replaces the overdue decisions/jax-2026-10-04.md. It covers the allowed range, any CPU-only default flag, the baseline and the guard design. Add a small DNA board change so environments' JAX versions and XLA flags, plus a JAX CPU policy panel, show publicly.
  • File follow-up prompts: the Nerves pin/flag change, a Heart guard that writes reproducer results into DNA on every allowed version, HowToLens/docs updates, and pointing PyAutoPulse's XLA notes at DNA.

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

Detailed implementation plan

Affected Repositories

  • PyAutoNerves (issue home; read-only in this task)
  • autolens_profiling (reproducer and matrix scripts, campaign wiki)
  • PyAutoDNA (campaign records, research authority, decision page, board panel)
  • Read-only: HowToLens, PyAutoHeart, PyAutoPulse

Branch Survey

Repository Current Branch Dirty? Notes
./lens/autolens_profiling main clean co-claimed with paused gradient-correctness-sweep (#517) by human override 2026-11-10; separate branch and worktree, paths disjoint
./organs/PyAutoDNA main clean leftover worktree feature/pyautodna-stack-management (0 ahead, clean): not a conflict

Suggested branch: feature/jax-version-policy (worktree ~/Code/PyAutoLabs-wt/jax-version-policy/)

Implementation Steps

Phase 1: hang matrix as a DNA campaign (prompt questions 1, 2, 4, 6)

  1. autolens_profiling/scripts/misc/jax_version_policy/export_reproducers.py: serialize jax.export modules plus their inputs for group MGE prefix 3, group Delaunay prefix 4 and the delaunay_mge vmap. Reuse _jax_cell, _flat_params and _stage_value from scripts/misc/likelihood_breakdown/galaxy_group_standard.py.
  2. hang_matrix.py: in a fresh python -I process that imports only jax, load the module and call it N times under a per-call watchdog. Each run writes a JSON row: jax/jaxlib, XLA_FLAGS, cores, environment id, the call index that hung (or null), and seconds per call.
  3. lapack_repro.py: a batched cho_factor reproducer for the #274 path.
  4. make_venvs.sh: one venv per jax version under a scratch path.
  5. Caveat: an exported module fixes the StableHLO, so re-running it under each version tests XLA compile and runtime, but not tracing. Each version also runs one real HowToLens tutorial-4 fit through the library with a repeated-call driver.
  6. RAL: an sbatch array of version × flag × reproducer × 5 repeats, --no-requeue, private checkout, ral partition. The laptop pilot stays under 30 min.
  7. PyAutoDNA: register the stacks (jax pin plus runtime XLA constraint) and the campaign "jax-cpu-policy". Collect receipts per environment. Add the research validation authority to dna/schema.py and the gate code (it can never satisfy promotion), with tests. Import the matrix rows as validation records.

Phase 2: flag cost (question 3)
8. Reuse the likelihood_breakdown drivers (XLA_CPU_WORKAROUND_FLAG already exists) to measure steady-state per-call time with and without each flag, per family, at 4/8 cores locally and at full width on RAL. Store the results as DNA evidence.
9. Confirm from XLA option handling that the flags are inert on GPU. Run on GPU only if the check is ambiguous.

Phase 3: decision, board, follow-ups (question 5)
10. PyAutoDNA/decisions/jax-cpu-policy-2026-11.md replaces jax-2026-10-04.md with a new review date. It holds the matrix, the cost table, the recommended single policy and the Heart guard design.
11. DNA board: a public allowlist of runtime flag names and specific XLA option tokens (no paths or hosts) in dna/inventory.py / dna/board.py, plus a JAX CPU policy panel showing matrix status per allowed version. Tests cover both.
12. Follow-up prompts in PyAutoMind/draft/: Nerves pin and/or jax_wrapper CPU-only default flag; Heart scheduled reproducer guard writing DNA records; HowToLens/README docs; PyAutoPulse knowledge and decision pointers to DNA; the upstream JAX issue (human approval).
13. Witness check against the prompt's Witness: line.

Key Files

  • PyAutoPulse/knowledge/xla_cpu_deadlock_jaxlib_0_11_2.md: reproducer recipe
  • PyAutoPulse/decisions/xla-cpu-deadlock-eigen-workaround.md: D12 decision
  • PyAutoNerves/autonerves/jax_wrapper.py: existing XLA_FLAGS edits
  • PyAutoDNA/dna/inventory.py:16: runtime FLAGS collected (incl. XLA_FLAGS)
  • PyAutoDNA/dna/campaigns.py, dna/schema.py, dna/board.py, environments.yaml, decisions/jax-2026-10-04.md
  • autolens_profiling/scripts/misc/likelihood_breakdown/galaxy_group_standard.py

Original Prompt

Click to expand starting prompt

JAX version policy and the recurring XLA:CPU deadlocks: what is the general…

Type: research
Target: PyAutoNerves
Repos:

  • autolens_profiling
  • PyAutoNerves
  • HowToLens
  • PyAutoHeart
  • PyAutoPulse
    Difficulty: too-large
    Autonomy: supervised
    Priority: high
    Status: formalised
    Consequence: glance
    Witness: a written recommendation (one policy covering JAX version range + any default XLA flags) backed by a repro matrix: each candidate jax/jaxlib version x flag setting, run on the laptop and a RAL CPU node, records hang / no-hang over N repeated calls of the known reproducers, plus per-call cost of the flag on at least one MGE and one pixelized likelihood.
    Review-minutes: 3
    Unattended: needs-slicing
    Lane: ral

Human request (2026-11-10): "make this more general research on what to do with JAX version and what might be the most general sensible solution". Raised while regenerating HowToLens#130 stored results on RAL, where tutorials 4 and 6 deadlocked at 0 % CPU.

The problem: the same bug class keeps being patched locally

XLA:CPU on JAX CPU hangs: a compiled (often vmapped) executable runs, then a later call never returns, process at 0 % CPU (futex wait in CpuPjRtRawLoadedExecutable::Execute → tsl::BlockUntilReady → absl::Mutex). Every fix so far has been scoped to one place; no fix reaches users' installs.

When Where seen Fix Scope
2026-09 4-core containers, vmap ("intra-op thread-pool starvation") — Mind complete/2026/09/mge-jit-regression-rebaseline.md, jax-import-order-x64.md, jit-visualization-outputs.md XLA_FLAGS=--xla_cpu_multi_thread_eigen=false container/CI only
2026-10-04 CPU batched LAPACK (Cholesky) on jax 0.10.x / 0.11.0 — PyAutoHeart#274 PyAutoNerves 249ba9e: jax>=0.7.0,<0.12.0,!=0.10.*,!=0.11.0 (+ README "JAX compatibility") everyone
2026-10-05 CPU FFT pool deadlock in release validation PyAutoHeart ad9bbc4: eigen flag in workspace-validation release mode, release-diagnostic, jax-compatibility; test asserts smoke mode does NOT set it Heart release legs only
2026-10-29 likelihood-lifecycle 2d: every JAX CPU cell on jaxlib 0.11.2 (MGE, rectangular, Delaunay) — decision D12 eigen flag in scripts/misc/likelihood_breakdown/galaxy_group_standard.py (XLA_CPU_WORKAROUND_FLAG) autolens_profiling only
2026-11-10 HowToLens ch2 tutorials 4 (MGE) and 6 (MultiStartProdigy) on RAL, jaxlib 0.11.2 eigen flag in the private RAL job script one task

Key facts:

  • PyAutoNerves names 0.11.2 the "recommended validation baseline" and it is what users resolve today (laptop and RAL venvs are jax/jaxlib 0.11.2), yet 0.11.2 has the 2d/HowToLens deadlock. The 0.10/0.11.0 exclusion fixed a different (LAPACK) path.
  • jax/jaxlib 0.12.0 and 0.12.0.1 are on PyPI and excluded by the <0.12.0 cap. Untested whether they fix either path.
  • PyAutoNerves autonerves/jax_wrapper.py already edits XLA_FLAGS before JAX starts (appends --xla_disable_hlo_passes=constant_folding, --xla_gpu_autotune_level=0, Triton GEMM off), env-respecting — a natural home for a CPU flag if that is the answer.
  • Known reproducer with no PyAuto code: PyAutoPulse knowledge/xla_cpu_deadlock_jaxlib_0_11_2.md (exported group MGE prefix-3 function, hangs ~call 14 by default, 300 calls fine with either flag). Decision record: PyAutoPulse decisions/xla-cpu-deadlock-eigen-workaround.md.
  • Two flags avoid it: --xla_cpu_multi_thread_eigen=false (D12 chose it; ~+25 % per call vs default on group/mge, ~2x faster than the alternative on MGE) and --xla_cpu_enable_concurrency_optimized_scheduler=false.
  • Hang is intermittent (call 1 to ~35): short smokes and test mode pass by luck. Smoke tests run in test mode and never hit it; readers running tutorials live (HowToLens ch2 tutorial 1 runs a real JAX search) are exposed.
  • Prior human constraint (CI timing epic): keep the eigen flag and the Eigen-pool bug-class reproduction (jax-compile-stall epic in epics.md).

Questions to answer

  1. Do jax/jaxlib 0.12.0 / 0.12.0.1 fix the 0.11.2 XLA:CPU deadlock (Pulse reproducer + one real tutorial fit) and the PyAutoHeart#274 LAPACK path? Any upstream JAX issue / fix commit?
  2. Which versions in the allowed range are actually safe on CPU, with and without each flag? Is "recommended baseline 0.11.2" still right?
  3. Is a library default (e.g. PyAutoNerves jax_wrapper appending a CPU-only XLA flag, skipped when the platform is GPU, never overriding a user's explicit setting) the most general fix? Cost across likelihood families (MGE, rectangular, Delaunay, interferometer, point source), CPU core counts (4 vs 8 vs RAL nodes), and fp64.
  4. Alternatives: pin/cap changes (exclude 0.11.2, move to 0.12.x, raise the floor), the scheduler flag instead, per-feature workarounds, or documentation only. Interaction with the GPU path (flag inert? D12 2d fix skipped it for cuda).
  5. How should this be guarded so it stops recurring: a Heart check that runs a known reproducer for N calls on each allowed jax version, rather than test-mode smokes.
  6. Should an upstream JAX issue be filed (the Pulse reproducer's exported module is the evidence)?

Deliverable

A short decision page (PyAutoPulse knowledge/decision or Nerves README section) with the repro matrix, a recommended single policy, and follow-up implementation prompts (library change, pin change, Heart guard, docs). Research only: no library change in this task.

Constraints

  • Laptop for short pilots only; repeated-call matrices longer than ~30 min go to a RAL array per the no-long-laptop-runs rule (private checkout, never the shared install).
  • Measure through pyauto-brain profiling conventions where timing rows are recorded.

Activity

  1. Jammy2211 commented on Nov 10, 2026

    @Jammy2211
    CollaboratorAuthor

    Progress: phase 1 laptop pilot

    The hang test grid ran on the laptop (8 cores, one repeat per cell; 100 calls for the exported likelihoods, 30 for Delaunay, 20 for FFT):

    Reproducer 0.11.2 no flag 0.11.2 eigen flag 0.12.0.1 no flag 0.12.0.1 eigen flag
    group MGE (data vector, exported) hang, call 4 pass, 0.064 s pass, 0.062 s pass, 0.064 s
    multi_galaxy MGE (full, exported) hang, call 94 pass, 0.048 s pass, 0.045 s pass, 0.040 s
    group Delaunay (full, library, PyAutoNerves default flags) hang, call 1 pass, 4.54 s pass, 4.30 s pass, 4.31 s
    FFT pool hang, call 1 pass pass pass

    DNA: PyAutoDNA feature/jax-version-policy adds:

    • a PyAutoDNA research validation authority that can block a promotion but never satisfy one;
    • dna import-matrix;
    • an allowlist of XLA options that are safe to show publicly;
    • a JAX CPU policy panel on the board, plus a yellow item when an observed environment runs a jax + flag combination that hung.

    The laptop's own PyAuto313 environment (jax 0.11.2) now shows as yellow. The draft decision is in decisions/jax-cpu-policy-2026-11.md.

    Next: the RAL grid (4 jax versions × 2 core counts × 5 repeats, 300 calls) is approved but not yet submitted, because the RAL jump host stopped responding during venv setup. After that: a Heart validation of 0.12, then the proposed floor jax>=0.12.0, jaxlib>=0.12.0 (both packages need it, because jax 0.12.0 still accepts jaxlib 0.11.2).

  2. Jammy2211 commented on Nov 11, 2026

    @Jammy2211
    CollaboratorAuthor

    RAL results (job 415009) and recommendation

    The run had 600 cells: jax 0.9.2 / 0.11.2 / 0.12.0 / 0.12.0.1 × {no flag, eigen, scheduler} × {4, 16} cores × 5 repeats, at 300 calls per cell (180,000 calls in total).

    jax no flag, 4 cores no flag, 16 cores eigen flag scheduler flag
    0.11.2 hang in 25/25 cells, every one on the first call pass 25/25 pass 50/50 pass 50/50
    0.12.0 pass 25/25 pass 25/25 pass 50/50 pass 50/50
    0.12.0.1 pass 25/25 pass 25/25 pass 50/50 pass 50/50
    • On 0.11.2 the hang depends on core count: certain at 4 cores, intermittent at 8 (the laptop), and not seen at 16. A large node can hide the bug.
    • The eigen flag is free for MGE, but on 0.12 it costs +18 % (4 cores) to about +50 % (16 cores) on the pixelized (rectangular) likelihood. So it should not become a default.
    • 0.9.2 cannot read modules exported from 0.11.2, so it was only partly tested. Those cells are recorded as unloadable, not as failures.

    Recommendation (PyAutoDNA decisions/jax-cpu-policy-2026-11.md):

    • Raise the floor to jax>=0.12.0,<0.13 and jaxlib>=0.12.0,<0.13, after a Heart validation on 0.12.
    • Add no default XLA flag.
    • Remove the per-place eigen workarounds once the floor is released.
    • Add a Heart guard that runs the reproducers at 4 cores on every allowed version and writes the results into DNA.

    The FFT part is already fixed upstream (jax-ml/jax#41265 / openxla/xla#50091). 0.12 no longer reproduces the MGE hang either, so no upstream issue is needed.

    All 600 rows are recorded in DNA as research evidence. Four follow-up drafts are filed in Mind: the Nerves floor (with the Heart validation), the Heart guard, removing the workarounds, and pointing the Pulse notes at DNA.

  3. Jammy2211 commented on Nov 11, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped for review: PyAutoLabs/autolens_profiling#527 (hang-grid scripts) and PyAutoLabs/PyAutoDNA#5 (research authority, import-matrix, JAX CPU policy panel, decision, public records). The human acknowledged Heart YELLOW at ship on 2026-11-11. Merge via /prm. The jax floor change itself is follow-up draft/feature/autonerves/raise_jax_floor_to_0_12.md and is coupled to the next release.

  4. Jammy2211 commented on Nov 11, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged:

    Witness: met. One policy (jax>=0.12.0,<0.13 + jaxlib>=0.12.0,<0.13, no default XLA flag), backed by a hang grid on the laptop and on RAL CPU nodes (600 cells, 180,000 calls). It also gives per-call flag cost on MGE and pixelized likelihoods (eigen flag +18–50 % on rectangular at 0.12).

    Approved by the human on 2026-11-11. The floor change itself rides the next release: draft/feature/autonerves/raise_jax_floor_to_0_12.md (needs a Heart validation on 0.12 first). Other follow-ups: the Heart hang guard writing DNA records, removing the eigen-flag workarounds after release, and pointing Pulse's XLA notes at the DNA decision.

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