Skip to content

fix: JAX vmap likelihood hangs in block_until_ready, not compile #1528

Closed

Description

@Jammy2211

Overview

Phase 3 of the jax-compile-stall epic: root-cause the hang that has now
quarantined seven entries across the two test workspaces, and restore the
coverage those quarantines removed. Phase 1 (PyAutoFit#1516/#1517/#1518) made a
stalled run report itself; phase 2 (autolens_workspace_test#271) measured it
across 60 script executions and captured the stacks. This phase is the fix.

The epic's name is wrong, and this issue starts from the correction. Every
prior marker, prompt and issue calls this an "intermittent XLA compile stall".
Phase 2's faulthandler stacks — captured from two different repos running two
different scripts, and identical — put the process in
jax.block_until_ready / try_to_block. Compilation completes (~16s, per
autolens_workspace_test's own 2026-08-24 marker); what never returns is the wait
for the result to materialize. The phase-2 record closes on the instruction:
"Do not restart from 'why is XLA slow to compile'. Start from 'why does
block_until_ready never return'."

There is now a deterministic reproducer. autolens_workspace_test
imaging/jax_likelihood/mge_group has 16/16 lifetime executions with zero
completions — 5/5 at the 300s cap on both Python legs (run 32664682689) and 3/3
at the 1800s cap on both legs (run 32758924176). Every A/B below therefore has a
binary readout rather than needing the underpowered n=10/arm probability
estimates phase 2 was forced into.

Plan

  • Fix two instrumentation defects in autofit/non_linear/jax_compile.py first —
    ~30 lines, and every experiment below is unreadable without them. Ships
    regardless of what the investigation finds.
  • Establish the deterministic reproducer under the fixed instrumentation with a
    single retime.yml dispatch, capturing a phase-labelled log and a stack.
  • Walk a hypothesis ladder re-ordered for an execution hang, each rung an A/B
    on that reproducer, driven through the existing retime.yml +
    PyAutoHeart reusable-workflow harness.
  • Fork on the outcome: a root cause is fixed in PyAutoFit library-first; no root
    cause after the ladder is recorded as an explicit infrastructure-limit
    decision. Not a fourth quarantine, either way.
  • Restore the seven quarantined entries, or re-mark each with the real reason
    and the measurement behind it.
  • Repair the epic bookkeeping: the "compile stall" misnomer across ledger,
    markers and issue titles, and a ledger that routes resumers to a file that
    does not exist.
Detailed implementation plan

Work Classification

Both (library + workspace) — library-first: the PyAutoFit PR merges before
the workspace PRs consume it.

Affected Repositories

  • PyAutoFit (primary) — autofit/non_linear/jax_compile.py, autofit/non_linear/fitness.py
  • autogalaxy_workspace_test — config/build/no_run.yaml, smoke_tests.txt, config/build/profile_smoke.yaml
  • autolens_workspace_test — config/build/no_run.yaml, smoke_tests.txt, config/build/profile_smoke.yaml

Branch Survey

Repository Current Branch Dirty?
./PyAutoFit main @ 34d6dff clean
./autogalaxy_workspace_test main @ e187c0e clean
./autolens_workspace_test main @ 8be3d59 clean

worktree_check_conflict → exit 0; nothing claimed in active.md.

PyAutoFit still carries experiment/jax-vmap-jit-ordering @ 0a40c31 from
phase 2, unmerged. Its autogalaxy_workspace_test twin has been deleted —
which matters, because PyAutoHeart's reusable workflow clones the dependency
chain at the matching branch name, so driving a library-side A/B through
workspace CI requires identically-named branches in both.

Suggested branch: feature/jax-stall-block-until-ready

Worktree root: ~/Code/PyAutoLabs-wt/jax-stall-block-until-ready/

Scope — verified against the live marker files, not the phase records

Repo File Entry Marker
ag_test config/build/no_run.yaml multi_dataset/jax_likelihood/rectangular.py NEEDS_FIX 2026-08-01
ag_test config/build/no_run.yaml imaging/jax_likelihood/mge_group.py NEEDS_FIX 2026-08-23
ag_test config/build/no_run.yaml imaging/jax_likelihood/rectangular_mge.py NEEDS_FIX 2026-08-23
al_test config/build/no_run.yaml imaging/jax_likelihood/mge_group NEEDS_FIX 2026-08-24 (16/16, deterministic)
al_test config/build/no_run.yaml multi_dataset/jax_likelihood/delaunay.py NEEDS_FIX 2026-08-01 (#245)
al_test smoke_tests.txt multi_dataset/jax_likelihood/mge.py disabled 2026-08-22
al_test smoke_tests.txt multi_dataset/jax_likelihood/shared_preloads.py disabled 2026-07-22

Two exclusion-list disagreements also in scope, both of which let a script
disabled on one channel burn a cap on another:

  • al_test: multi_dataset/jax_likelihood/shared_preloads.py is admitted by
    no_run.yaml (the 2026-08-24 retime removed its SLOW marker) but excluded
    by smoke_tests.txt. It then stalled at 300s on the very next weekly run
    (PyAutoHeart Workspace Smoke 32902243623).
  • ag_test: multi_dataset/jax_likelihood/rectangular.py is NEEDS_FIX in
    no_run.yaml but still enabled in smoke_tests.txt.

Implementation Steps

Step 0 — PyAutoFit instrumentation, two defects. Both in
autofit/non_linear/jax_compile.py:

  1. _Heartbeat is constructed as _Heartbeat(description, start) and its
    _beat prints JAX jit still compiling {description}, {n}s elapsed... for
    the entire first call. That is why a stalled run logged
    still compiling ... 1770s elapsed while parked in block_until_ready.
    Give it a mutable phase and have wrapper flip it the instant
    func(*args, **kwargs) returns, so the heartbeat names the half it is
    actually in. The phase-2 record flags this explicitly: "Fix the message to
    name the phase before anyone reads another one of these logs."
  2. The traced, lowered and compiled in Xs, result materialized in Ys line is
    emitted only after both halves finish, so a stalled run prints neither
    number and characterises the healthy case only. Emit the compile-half
    duration as soon as func() returns, before jax.block_until_ready. A
    stalled run then self-classifies from its log alone, with no stack required.

Tests in test_autofit/non_linear/test_jax_compile.py: assert the heartbeat
text changes across the phase boundary, and that the compile-half line is
emitted when the execute half never returns (blocking sentinel). Assert the
relationship, not literal wordings — the trap phase 1 recorded when #1517's
tests could not catch a 300s dump default colliding with a 300s cap.

Step 1 — baseline the reproducer. Dispatch retime.yml on
autolens_workspace_test with scripts=imaging/jax_likelihood/mge_group.py,
repeats=2, script-timeout=1800, from a branch named identically to the
PyAutoFit branch carrying step 0. Expected readout: compiled in ~16s,
heartbeats naming the materialize phase, and a block_until_ready stack at
1440s (DUMP_FRACTION_OF_CAP = 0.8). That confirms the reproducer and validates
step 0 in one run.

Step 2 — the ladder, re-ordered for an execution hang. Each rung is an A/B
on the deterministic reproducer; a completion in the experiment arm is a
positive result, because the control arm is 16/16 hangs.

  1. Persistent compilation cache. JAX_COMPILATION_CACHE_DIR, default-on
    since PyAutoConf#128 (2026-07-17). Never tested, and phase 2 sharpened the
    hypothesis: a cache hit satisfies compile instantly and leaves execution to
    hang — exactly the ~16s-then-nothing shape observed. A/B by overriding the
    var to empty in config/build/profile_smoke.yaml. Cheapest rung, strongest
    timeline correlation (both NEEDS_FIX stalls post-date the default; the SLOW
    batch predates it).
  2. vmap(jit) ordering, re-run on the deterministic case. Fitness._vmap
    (autofit/non_linear/fitness.py) builds jax.vmap(jax.jit(self.call));
    analysis/latent.py builds the conventional jax.jit(jax.vmap(...)). Phase 2
    measured 80% → 30% at Fisher exact p = 0.070 on a probabilistic script with
    n=10/arm — underpowered and inconclusive. On a 16/16 script the same swap is
    a clean binary. Phase 2 also reframes why it matters now: the ordering changes
    the shape of the executed computation, a more plausible route to an
    execution hang than to a compile one. Reuse
    experiment/jax-vmap-jit-ordering; recreate the matching workspace branch.
  3. Async dispatch / device transfer. Whether one buffer hangs or the whole
    batch: block on individual pytree leaves rather than the aggregate; vary the
    vmap batch size; JAX_DISABLE_JIT=1;
    XLA_FLAGS=--xla_force_host_platform_device_count.
  4. Runner resource exhaustion. The affected set is uniformly the heavy
    multi_dataset/composite paths on 2-core hosted runners, and an execution
    hang there is as consistent with memory thrashing as with a deadlock. Read
    the stalled job's runner memory; check whether the reusable workflow can be
    pointed at a larger machine.
  5. JAX/jaxlib version bisect. Last — expensive. The repo has form
    (delaunay_mge.py is disabled outright because jax 0.7 removed
    jax.interpreters.xla.pytype_aval_mappings), so it is plausible but not
    cheap. Re-decide before starting this rung rather than rolling into it.

Step 3 — outcome fork. A root cause is fixed in PyAutoFit and shipped first,
its API-change summary consumed by the workspace PRs. No root cause after rungs
1–4 is recorded as an explicit infrastructure-limit decision naming what was
tested and excluded — which this task's acceptance permits as an alternative to
a fix. Not a fourth quarantine either way.

Step 4 — restore coverage. Clear the five NEEDS_FIX markers; re-enable
multi_dataset/jax_likelihood/mge.py and shared_preloads.py in al_test
smoke_tests.txt; resolve both exclusion-list disagreements deliberately rather
than by whichever file is edited next. Anything that stays out stays out with a
recorded reason and the measurement behind it — never as an accumulated one-off.

Step 5 — epic bookkeeping. Rename the "XLA compile stall" misnomer across
the ledger, the markers and the issue titles. PyAutoMind/epics.md routes
resumers to draft/research/ci/smoke_timing_and_profiling.md, which does not
exist
— repoint it at this task. Flip the epic from CLOSED AS PARTIAL back
to in flight.

Key Files

  • autofit/non_linear/jax_compile.py — _Heartbeat (phase-blind message), log_on_first_compile.wrapper (split line emitted too late); jax.block_until_ready at the hang site
  • autofit/non_linear/fitness.py — Fitness._vmap, the jax.vmap(jax.jit(...)) ordering under test in rung 2
  • test_autofit/non_linear/test_jax_compile.py — phase-boundary and stalled-execute-half tests
  • <workspace>/config/build/no_run.yaml — the five NEEDS_FIX stall markers
  • <workspace>/smoke_tests.txt — the two disabled al_test entries and the ag_test disagreement
  • <workspace>/config/build/profile_smoke.yaml — env-profile overrides for the rung-1 cache A/B
  • <workspace>/.github/workflows/retime.yml + .github/scripts/retime.py — phase 2's dispatchable A/B harness

Testing

PyAutoFit unit suite for step 0. Every ladder rung is a CI dispatch returning a
retime.py JSON verdict (STALL / SLOW / NEITHER / AMBIGUOUS with the
ratio that drove it). Final validation is the un-quarantined scripts passing
their own smoke gates on both Python legs.

Scope floor

The Bug Agent sizes this too-large (heuristic score 13) and an open-ended
root-cause hunt has no natural end. Steps 0, 4 and 5 ship regardless of whether
the ladder lands a cause, which gives the task a floor.

Known environment constraint

pyauto-heart was unreachable from the web-github environment in both prior
phases, and this is the same environment. Expect the ship gate's Heart leg to be
un-consulted again, as recorded on phases 1 and 2.

Original Prompt

Click to expand starting prompt

Phase 3: root-cause the XLA vmap compile stall and clear every NEEDS_FIX it caused

Type: bug
Target: ci
Repos:

  • @PyAutoFit
  • @autogalaxy_workspace_test
  • @autolens_workspace_test
    Difficulty: large
    Autonomy: supervised
    Priority: high
    Status: formalised
    Epic: jax-compile-stall
    Phase: 3
    Campaign: bug/ci/jax_vmap_jit_compile_stall.md (Phase 3 — the fix; blocked on phases 1 and 2)
    Filed: 2026-08-23

Blocked on phase 1

Do not start this before phase 1's watchdog has shipped and a CI stall has
actually dumped a traceback. Diagnosing a hang that leaves no evidence is what
produced three quarantines and no root cause; repeating it without the
instrumentation would be a fourth.

Reproduce deliberately

Loop imaging/jax_likelihood/mge_group.py under its declared CI env profile
until it hangs, rather than waiting for CI to hit it. Attach py-spy dump to
the hung process as well as reading phase 1's own faulthandler output — the
two see different things, and py-spy can read native frames the in-process
dump cannot.

Hypotheses, in the order they are cheapest to test

  1. vmap of jit, the inverted ordering. Fitness._vmap
    (autofit/non_linear/fitness.py) builds jax.vmap(jax.jit(self.call));
    autofit/non_linear/analysis/latent.py builds
    jax.jit(jax.vmap(compute_latent_for_model)), the conventional order. The
    stalling path is exactly the vmap path, and the _jit-only scripts in the
    same directories do not stall. One-line A/B — try it first.
  2. Persistent compilation cache contention. JAX_COMPILATION_CACHE_DIR has
    defaulted on since PyAutoConf#128 (merged 2026-07-17). Both NEEDS_FIX stalls
    post-date it; the eight SLOW entries predate it. A/B with the cache dir set
    to empty (which disables it) and see whether the stall probability moves.
  3. JAX/XLA version interaction. This repo has form: delaunay_mge.py is
    disabled outright because jax 0.7 removed
    jax.interpreters.xla.pytype_aval_mappings, and the smoke installer once
    clobbered a working tfp-nightly. Pin-bisect jax/jaxlib across a run set.
  4. Runner CPU contention. complete/2026/07/jax-compile-time-research.md
    records that XLA compiles on host CPUs and that compile timing is
    load-sensitive by up to 7×, which is why a hosted runner is the place this
    reproduces and a workstation is not.
  5. Graph size in the vmap trace. The affected set has a shape: plain mge.py
    passes in 9.4s, while the composite variants — group, rectangular-MGE,
    delaunay-MGE — stall or are already out. Complexity-driven compile blowup was
    argued against by the autolens_profiling#71 research ("compile cost is
    op-pattern-driven, not complexity-driven"), so treat this as the hypothesis
    of last resort, not the first.

Then restore the coverage

The point of the campaign. Quarantining removes exactly the heaviest JAX paths,
which are the ones most worth testing.

  1. Clear the NEEDS_FIX markers this campaign inherits — including the
    2026-08-01 multi_dataset/jax_likelihood/rectangular.py one and the
    autolens_workspace_test delaunay.py entry citing Zeus gives error due to pickling #245.
  2. Re-enable multi_dataset/jax_likelihood/mge.py and shared_preloads.py in
    autolens_workspace_test's smoke_tests.txt (folded in from the superseded
    2026-08-22 filing).
  3. Anything that stays out after the fix stays out with a recorded deliberate
    reason
    , not as an accumulated one-off.

Acceptance

  • A stated root cause, or an explicit recorded decision that it is an
    infrastructure limit to be worked around rather than fixed. Not another
    quarantine.
  • Every entry marked NEEDS_FIX for this signature restored to its suite, or
    re-marked with the real reason phase 2 established.
  • The multi_dataset/jax_likelihood/ family back under CI coverage in both test
    workspaces, or its absence recorded as a deliberate choice.

Activity

  1. Jammy2211 commented on Aug 27, 2026

    @Jammy2211
    CollaboratorAuthor

    Step 1 baseline: the hang is not in the compile or the block_until_ready, and every stalled run has been throwing away the evidence

    autolens_workspace_test run 33032703787 — imaging/jax_likelihood/mge_group.py, 2 repeats, 1800s cap, on feature/jax-stall-block-until-ready in both PyAutoFit and the workspace (chain checkout confirmed against smoke-tests.yml:142, which resolves github.head_ref || github.ref_name).

    The legs disagreed, and the instrumentation says why

    3.13 — NEITHER, completed 2/2 in 44.6s and 36.6s. Against a 16/16 lifetime zero-completion record.

    3.12 — AMBIGUOUS, capped 2/2. Both repeats identical:

    02:47:20  JAX jit compiling vectorized (vmap) likelihood function, could take seconds or minutes...
    02:47:36  ... traced, lowered and compiled in 16.1 seconds; waiting for the result to materialize...
    02:47:37  ... result materialized in 1.3 seconds.
    02:47:37  ... complete in 17.5 seconds.
              [nothing at all for the next 1782 seconds]
              TIMEOUT after 1800s — killed the process group.
    

    The JAX first call completed. Both halves. In 17.5 seconds. Compilation finished, jax.block_until_ready returned, log_on_first_compile returned — and then the script hung for another half hour.

    Note the two legs materialized in 1.3 seconds each. The half phase 2 identified as the hang site is, in this run, the fastest and most consistent part of the whole thing.

    What this overturns

    The epic ledger, epics.md, and autolens_workspace_test's own 2026-08-24 no_run.yaml marker all now record as established fact that "the stack sits in jax.block_until_ready". On this evidence that is wrong, in the same way "XLA compile stall" was wrong before it — a real stack, read correctly, generalised to a failure mode it did not cover.

    Phase 2's stack was genuine; there is no reason to doubt it. But it was one stack from one run, and this run's own instrumentation contradicts it directly. Either there is more than one failure mode here, or the failure point moves. Both readings are live and I am not picking one.

    There is a second-order consequence worth stating plainly: the watchdog is armed and cancelled around the first compile only (watchdog.cancel() in the finally). Because the first call completed at 17.5s, the faulthandler timer was disarmed 1782 seconds before the process was killed. This run produced no stack at all, and could not have. The instrumentation is watching the wrong window.

    The finding that probably explains the whole campaign

    The script is spawned by retime.py / run_smoke.py as [sys.executable, script_path] with stdout=subprocess.PIPE, and nothing anywhere sets PYTHONUNBUFFERED. A pipe is not a tty, so the child's print() output is block-buffered and only flushed at process exit. logger writes to stderr, which is not.

    So on a run that gets SIGKILLed at the cap, 100% of the script's own print() output is destroyed, and the "captured tail" that this whole campaign has been reading is stderr-only.

    This is not inference from the hanging leg. The passing leg proves it: in the 3.13 log every logger line appears in real time, interleaved correctly by timestamp, and then all eight print() lines arrive afterwards in a single block at exit. That is the block-buffered-then-flushed-at-exit signature, unmistakably.

    It matters here because everything mge_group.py does after the wrapper returns is print() — lines 313, 314, 318-321, 362, 374, 380, 387. The script could have got most of the way to the end and we would see exactly what we see: silence. We cannot currently localise this hang at all, and never could have.

    Every "then silence for the full 300s" observation in this epic — the 2026-08-01, 2026-08-23, 2026-08-24 and 2026-08-25 markers — was recorded under this blindfold.

    The fix is one line, in a fourth repo

    autohands/env_config.py:45 already carries the right home:

    DIAGNOSTIC_ENV_DEFAULTS = {"JAX_TRACEBACK_FILTERING": "off"}

    Adding "PYTHONUNBUFFERED": "1" there applies it to every profiled run, layered before apply_profile so a profile can still override it. That makes a killed script's own output survive, for this stall and for every future one.

    That is PyAutoHands, which is outside this issue's stated affected-repo list, so it is a scope call rather than something to slip in.

    Consequences for the plan

    • The "deterministic reproducer" premise is dead. 3.13 completed 2/2. Every A/B in the ladder was designed around a binary readout and now needs a power argument instead — with phase 2's own warning that a small N measures the fast mode and says nothing about the tail.
    • Version interaction is promoted. 3.12 and 3.13, identical commit, identical chain, same runner image, same minute, ~40s versus >1800s. That is a controlled comparison that fell out for free and it is the strongest signal on the board. It was hypothesis 5 in this issue's ladder; it should be near the front.
    • The JAX_COMPILATION_CACHE_DIR rung is unchanged in principle, but its rationale in the issue body needs correcting: autonerves/jax_wrapper.py:98 sets the default only if "JAX_COMPILATION_CACHE_DIR" not in os.environ and treats an explicitly empty value as disabled, so the A/B adds a quoted JAX_COMPILATION_CACHE_DIR: "" to the workspace profile rather than overriding an existing key. Unquoted, apply_profile's env[key] = str(value) turns YAML's empty value into the literal string "None" — a truthy cache directory named None.

    Nothing has been un-quarantined and no marker has been rewritten. The 3.13 completions are not grounds to readmit anything; that is precisely the mistake the 2026-08-24 retime made with shared_preloads.py, which stalled on the very next weekly run.


    Generated by Claude Code

  2. Jammy2211 commented on Aug 27, 2026

    @Jammy2211
    CollaboratorAuthor

    The hang is caught with a stack: block_until_ready, compile already finished

    Run 33076408637, 300s cap, 2 repeats — both legs hung 2/2, and the PyAutoHands diagnostics (PyAutoHands a108f7f) produced exactly what the campaign has never had:

    13:33:33  JAX jit compiled vectorized (vmap) likelihood function in 15.7s
              and is still waiting for the result to materialize, 270s elapsed...
    
    Fatal Python error: Aborted
    
    Current thread 0x00007f9fc9506b80 (most recent call first):
      File ".../jax/_src/api.py", line 2764 in try_to_block
      File ".../jax/_src/api.py", line 2781 in block_until_ready
      File ".../autofit/non_linear/jax_compile.py", line 249 in _block_until_ready
      File ".../autofit/non_linear/jax_compile.py", line 339 in wrapper
      File ".../scripts/imaging/jax_likelihood/mge_group.py", line 313 in <module>
    

    Phase 2 was right and I was wrong. My previous comment argued the block_until_ready finding had been over-generalised. It had not. The hang is in block_until_ready / try_to_block, with compilation complete — exactly where phase 2's stack put it.

    Both instrumentation fixes earned their place here. The heartbeat says "compiled in 15.7s and is still waiting for the result to materialize"; on the old code this identical run would have logged "still compiling ... 270s elapsed" and produced a sixth marker calling it a compile stall. And the SIGABRT is what produced the stack at all — PyAutoFit's own watchdog cannot, because it is armed only around the first compile.

    The two observations reconcile

    This morning's run 33032703787 showed the wrapper completing (17.5s) and the hang landing later. That is almost certainly the same failure one call site further on. mge_group.py calls fitness._vmap(parameters) twice — line 313 and line 318 — and on the second call log_on_first_compile.wrapper short-circuits at if state["compiled"], returning func(*args) directly: no log line, no heartbeat, no watchdog, and no block_until_ready. JAX dispatches asynchronously, so that call returns a future immediately and the wait moves to print(result) on line 319.

    One failure mode — materializing a vmap result never completes — at whichever call site gets unlucky. Not two bugs.

    That also means the wrapper's one-shot design leaves every call after the first completely uninstrumented, which is worth fixing regardless of root cause.

    Refuted along the way

    • Version interaction — dead. The 2026-08-24 run, where this script hung 3/3 on both legs, installed jax 0.11.1, jaxlib 0.11.1, ml_dtypes 0.6.0, numpy 2.5.2, scipy 1.17.1 — identical to today. No bisect needed.
    • The 3.12/3.13 split — not causal. 3.13 completed 2/2 at 02:18 and hung 2/2 at 13:33 on the same commit and chain. Per-run probability, not a leg property. I over-read a single run earlier and am correcting it here.
    • The "deterministic reproducer" premise stays dead; the hang rate is variable, so every A/B needs a power argument.

    Next: the compilation cache, now sharply motivated

    Dispatched: JAX_COMPILATION_CACHE_DIR: "", 3 repeats × 2 legs (autolens_workspace_test f1c77f8).

    The 15.7s compile time is what promotes this from speculation. autonerves/jax_wrapper.py sets JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS=1 whenever the cache is on, so a 15.7s compile is far past the threshold and is written to disk. A hosted runner starts with an empty ~/.cache/pyauto_jax, so every CI run is a miss followed by a write — putting a large artifact's disk write in the same window as the execution that never returns.

    Control is this run: 4/4 hangs with the cache at its default. Experiment is 6 executions with it off. 6/6 completions would be Fisher exact p≈0.002.

    Two traps handled: the empty value must be quoted, because env_config.apply_profile does env[key] = str(value) and an unquoted empty YAML value becomes the literal string "None" — a truthy cache directory. Verified the resolved value is '', and that the strict profile validator passes.

    Nothing un-quarantined, no marker rewritten.


    Generated by Claude Code

  3. Jammy2211 commented on Aug 27, 2026

    @Jammy2211
    CollaboratorAuthor

    Cache rung refuted — and it handed over the actual locus

    Run 33078033016, JAX_COMPILATION_CACHE_DIR: "", 3 repeats × 2 legs.

    6/6 hangs, against 4/4 with the cache on. AMBIGUOUS — hit the cap in all 3 runs on both legs. The persistent compilation cache is not the cause.

    The experiment did apply — I checked rather than assuming. No "The JAX persistent compilation cache has been enabled at ..." line from autonerves anywhere in the log (it emits that only when it sets the default, which an explicit empty value skips), and compile times dropped to a consistent 11.8 / 12.0 / 12.3s from 15.7s with the cache on.

    What it bought instead: three identical stacks

    Fatal Python error: Aborted
    Current thread (most recent call first):
      File ".../jax/_src/array.py",    line 642 in _value
      File ".../jax/_src/profiler.py", line 420 in wrapper
      File ".../jax/_src/array.py",    line 391 in __str__
      File ".../scripts/imaging/jax_likelihood/mge_group.py", line 319 in <module>
    

    Line 319 is print(result). The hang is in jax.Array._value — the device-to-host transfer.

    And PYTHONUNBUFFERED is what makes that readable: JAX Time To VMAP + JIT Function 12.87 / 13.50 / 13.08 survived the kill in all three repeats. Without it those prints die with the process and the hang is unplaceable, exactly as it has been all month.

    One failure, two doors

    Run Stack Script line
    33076408637 block_until_ready → try_to_block 313 (first _vmap)
    33078033016 __str__ → _value 319 (print of the second _vmap result)

    block_until_ready and _value are two ways of forcing the same thing. Materialising the output of the vmap'd computation never returns — which means the computation itself does not terminate. Compilation finished ~13s earlier and log_on_first_compile returned cleanly all three times.

    This also confirms the reconciliation proposed in my previous comment: the second _vmap call short-circuits the wrapper, so it dispatches asynchronously, logs nothing, and the wait lands on the print.

    Ledger of the ladder

    Rung Status Evidence
    Persistent compilation cache refuted 6/6 hangs disabled vs 4/4 on
    jax / jaxlib version refuted identical 0.11.1 stack on 2026-08-24 when it hung 3/3 on both legs
    3.12 vs 3.13 refuted 3.13 passed 2/2 at 02:18 and hung 2/2 at 13:33, same commit
    vmap(jit) ordering untested here phase 2's p=0.070 stands, underpowered
    XLA CPU thread pool running now see below

    Next: intra-op thread pool

    Dispatched (222f5d8): XLA_FLAGS="--xla_cpu_multi_thread_eigen=false --xla_force_host_platform_device_count=1" with OMP_NUM_THREADS=1, compilation cache restored to default so this is a single variable against the 4/4 control.

    The rationale is the shape of the evidence: a computation that never terminates while nothing appears to be burning CPU is what an intra-op thread pool deadlock looks like, and a hosted runner advertising more CPUs than its container can actually schedule is the classic way to get one.

    Caveat stated up front: three variables move together here. If it passes, that is not the answer yet — it needs narrowing one at a time before anything is proposed as a real profile change.

    Nothing un-quarantined, no marker rewritten.


    Generated by Claude Code

  4. Jammy2211 commented on Aug 27, 2026

    @Jammy2211
    CollaboratorAuthor

    Narrowed to one flag: --xla_cpu_multi_thread_eigen=false

    Time Arm Result Run
    13:21 default 4/4 HANG 33076408637
    13:40 JAX_COMPILATION_CACHE_DIR: "" 6/6 HANG 33078033016
    14:11 eigen + host-device-count + OMP_NUM_THREADS=1 6/6 PASS, slowest 63.2s 33080638510
    14:35 --xla_cpu_multi_thread_eigen=false alone 6/6 PASS, slowest 62.3s 33082896277
    === imaging/jax_likelihood/mge_group.py: NEITHER — completed 3/3 runs, slowest 62.3s = 21% of the 300s cap ===
    

    62.3s alone against 63.2s for all three together is the same number, so the other two variables did nothing. --xla_force_host_platform_device_count=1 was almost certainly a no-op (CPU already exposes one host device) and OMP_NUM_THREADS bounds OpenMP inside numpy/scipy BLAS, not XLA's own pool.

    That is consistent with the mechanism the stacks pointed at: multithreaded Eigen is the XLA CPU intra-op thread pool, and a deadlock there is exactly "the computation never terminates while the compile finished 13s ago and nothing is burning CPU".

    Sufficiency is not necessity — one more run before any of this counts

    Twelve passes with the flag prove nothing if the hang merely went quiet. This script passed 2/2 at 02:18 today and hung 2/2 at 13:33 on the identical commit, so the rate demonstrably wanders, and that is the single most likely way to fool myself here.

    Dispatched (8cb1695): the stock profile again, 3 repeats × 2 legs. That turns the sequence into an ABAB design rather than a before/after.

    • Hangs → necessity confirmed, and the workaround is real.
    • Passes → the flag was never the variable that mattered, this is a coincidence of timing, and nothing gets proposed or un-quarantined.

    What I would propose only if it hangs — not yet done

    1. XLA_FLAGS: "--xla_cpu_multi_thread_eigen=false" into profile_smoke.yaml and profile_release.yaml in both test workspaces.
    2. A cost measurement before committing to placement. The flag is global to the profile, so it disables multithreaded Eigen for every script the mega-run touches, not just the JAX ones. On mge_group it costs ~50s against ~44s unpatched — fine — but that says nothing about the rest of the suite. If the whole-suite cost is material, scope it to a jax_likelihood/ overrides: pattern instead of the global defaults: block.
    3. A family re-time before any marker moves: al_test imaging/jax_likelihood/mge_group, multi_dataset/jax_likelihood/delaunay.py, plus smoke_tests.txt's multi_dataset/jax_likelihood/mge.py and shared_preloads.py; ag_test multi_dataset/jax_likelihood/rectangular.py, imaging/jax_likelihood/mge_group.py, imaging/jax_likelihood/rectangular_mge.py. A flag that fixes one script is not evidence about seven.
    4. Recorded honestly as an infrastructure workaround, not a root-cause fix. We know where it hangs and what avoids it; we do not know why XLA's CPU thread pool wedges on this graph. This issue's acceptance criteria explicitly allow that outcome — but it must be written as what it is, and it should carry an upstream JAX/XLA report.

    Nothing un-quarantined, no marker rewritten.


    Generated by Claude Code

  5. Jammy2211 commented on Aug 27, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Four PRs merged 2026-08-27, library-first:

    PR Merge sha
    PyAutoFit#1529 — phase-aware JAX first-call instrumentation 4130b22
    PyAutoHands#269 — unbuffered child output + SIGABRT stacks ad64e12
    autolens_workspace_test#281 — flag + four entries restored 69ee97c
    autogalaxy_workspace_test#114 — flag + three entries restored adf5ffe

    Both workspace smoke gates went green with the restored scripts back in smoke_tests.txt, which is the validation that matters.

    What this settles

    The epic's name was wrong for a month. It is not an XLA compile stall. Compilation completes in ~12–18s; what never returns is materialising the vmap result — captured at jax.block_until_ready → try_to_block (line 313) and at jax.Array._value → __str__ (line 319), both doors onto the same failure, both caught in the same run.

    Trigger: XLA CPU's multithreaded Eigen thread pool. XLA_FLAGS=--xla_cpu_multi_thread_eigen=false, in the smoke and release profiles of both test workspaces. ABAB:

    Arm Result
    default 4/4 HANG
    compilation cache disabled 6/6 HANG
    flag + 2 other vars 6/6 PASS
    flag alone 6/6 PASS
    default again 4/6 HANG, verdict STALL

    12 passes / 0 hangs with the flag; 2 passes / 14 hangs without. Fisher exact p ≈ 3e-6.

    All seven quarantined entries restored — 42/42 completions, verdict NEITHER on every entry and every leg, slowest 20% of cap. mge_group had 16/16 lifetime cap hits and zero completions before this.

    Refuted along the way

    • the persistent compilation cache (6/6 hangs with it disabled);
    • jax/jaxlib version (identical 0.11.1 stack on 2026-08-24 when it hung 3/3 on both legs — no bisect needed);
    • the 3.12-vs-3.13 split (3.13 passed 2/2 and hung 2/2 on the same commit, hours apart);
    • the "deterministic reproducer" premise the plan was built on.

    Two instrumentation defects fixed, and why they mattered

    The heartbeat said "still compiling" in both halves, so a stalled run produced positive evidence for the wrong cause — five markers were written against it. And the compile/execute split was only emitted once both halves finished, so a stalled run reported neither number.

    Underneath both: nothing set PYTHONUNBUFFERED, and the runners capture through a pipe. Every "and then silence" tail in this campaign was silence of stderr alone, with the scripts' own prints discarded by the SIGKILL. Five scripts were quarantined on evidence truncated before anyone read it.

    Left deliberately undone

    This is a workaround, not a root cause. We know where it hangs and what avoids it; we do not know why XLA's CPU thread pool wedges on these graphs — faulthandler shows Python frames only, so the pool itself is still opaque. Recorded as such in both no_run.yaml files, with the note that removing the flag brings the entries back. A follow-up research prompt and an upstream JAX/XLA report are the next step.

    Heart: not consulted — pyauto-heart is unreachable from the web-github environment, as on phases 1 and 2.


    Generated by Claude Code

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