Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dashboard.html

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ Coverage: 49 optimal cell(s) not measured.

#### Extra Information

[Comparing CPU-parallel and GPU-batched setups](https://github.com/PyAutoLabs/PyAutoPulse/blob/main/knowledge/cpu_parallel_vs_gpu_batched.md)
- [Comparing CPU-parallel and GPU-batched setups](https://github.com/PyAutoLabs/PyAutoPulse/blob/main/knowledge/cpu_parallel_vs_gpu_batched.md)
- [XLA:CPU deadlock on repeated calls (jaxlib 0.11.2)](https://github.com/PyAutoLabs/PyAutoPulse/blob/main/knowledge/xla_cpu_deadlock_jaxlib_0_11_2.md)

</details>

Expand Down Expand Up @@ -565,9 +566,10 @@ Project `autolens_inference`, scope `None`, read from [PyAutoLabs/autolens_infer
</details>


<!-- decision-history:4d88bb773a36f774562f9e06d52a024b839cc44d2aa91282311891f6064c43c3 -->
<!-- decision-history:ad27a8de3dc279fc950485bff4ddf33985732256d23062b150ac9ca97304de61 -->
## Decision History

- <a href="https://github.com/PyAutoLabs/PyAutoPulse/blob/main/decisions/xla-cpu-deadlock-eigen-workaround.md">Keep --xla_cpu_multi_thread_eigen=false for the 2d JAX CPU legs (jaxlib 0.11.2 deadlock)</a>
- <a href="https://github.com/PyAutoLabs/PyAutoPulse/blob/main/decisions/cluster-pointsolver-starting-grid.md">Keep the 1.0″ PointSolver starting grid for cluster fits, with a validation check</a>
- <a href="https://github.com/PyAutoLabs/PyAutoPulse/blob/main/decisions/direct-conv-symmetric-gate.md">Gate the symmetric direct_conv kernel at work fraction 0.7, with ymin column ordering</a>
- <a href="https://github.com/PyAutoLabs/PyAutoPulse/blob/main/decisions/interferometer-route-gate-cost-model.md">Route interferometer curvature by a calibrated two-constant cost model</a>
Expand Down
4 changes: 4 additions & 0 deletions decisions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ decisions:
title: Keep the 1.0″ PointSolver starting grid for cluster fits, with a validation check
date: '2026-10-23'
url: https://github.com/PyAutoLabs/PyAutoPulse/blob/main/decisions/cluster-pointsolver-starting-grid.md
- id: xla-cpu-deadlock-eigen-workaround
title: Keep --xla_cpu_multi_thread_eigen=false for the 2d JAX CPU legs (jaxlib 0.11.2 deadlock)
date: '2026-10-29'
url: https://github.com/PyAutoLabs/PyAutoPulse/blob/main/decisions/xla-cpu-deadlock-eigen-workaround.md
84 changes: 84 additions & 0 deletions decisions/xla-cpu-deadlock-eigen-workaround.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Keep --xla_cpu_multi_thread_eigen=false for the 2d JAX CPU legs (jaxlib 0.11.2 deadlock)

Date: 2026-10-29
Decision maker: James Nightingale
Decision source: Human decision in chat on 2026-10-29, verbatim: "keep the workaround which ensures we retain the fastest run times and make sure this knowledge is retained in Pulse for going forward". Recorded as decision D12 on the 2d campaign page in [autolens_profiling#484](https://github.com/PyAutoLabs/autolens_profiling/pull/484).

## Campaign

Likelihood-lifecycle phase 2d
([autolens_profiling#473](https://github.com/PyAutoLabs/autolens_profiling/issues/473)): the
`multi_galaxy/{mge, rectangular, delaunay}` (hst) and `group/{mge, rectangular, delaunay}`
(euclid) cells at the standard size on pin 2026.10.25.1. Its laptop smokes found that every JAX
CPU executable deadlocked on a repeated call under jaxlib 0.11.2. The question was which XLA flag
the JAX CPU legs should compile with.

## Evidence

The full account is the knowledge page
[XLA:CPU deadlock on repeated calls (jaxlib 0.11.2)](../knowledge/xla_cpu_deadlock_jaxlib_0_11_2.md)
and the 2d campaign page's "XLA:CPU deadlock" section at
[`caa46fad`](https://github.com/PyAutoLabs/autolens_profiling/blob/caa46fad/wiki/campaigns/multi_galaxy/likelihood_lifecycle_p2d.md#xlacpu-deadlock-found-in-the-laptop-smokes-avoided-by-d12).
In summary (laptop, 8 cores, local library mains, dense JAX CPU, fp64, steady median per call
after compile):

- With default flags every 2d JAX CPU cell hung after 1 to ~35 calls at 0 % CPU, in
`CpuPjRtRawLoadedExecutable::Execute` -> `tsl::BlockUntilReady` -> `absl::Mutex` futex wait.
- An exported group MGE prefix-3 function, run in a `python -I` process importing only jax,
deadlocks at ~call 14 by default and runs 300 calls with either flag below.
- Per call:

| Cell | default | `multi_thread_eigen=false` | `concurrency_optimized_scheduler=false` |
|---|---|---|---|
| group/mge | 0.064 s, then hung | 0.080 s | 0.154 s |
| multi_galaxy/mge | hung | 0.053 s | 0.104 s |
| group/delaunay | hung | 4.57 s | 4.42 s |
| multi_galaxy/rectangular | hung | 2.19 s | 1.90 s |

Untested: RAL (same jaxlib 0.11.2 on the pin), the GPU runtime, and whether the 2a/2b JAX CPU
executables (measured without a flag, and completed) are susceptible.

## Options considered

- **`--xla_cpu_multi_thread_eigen=false`.** About 2x faster than the scheduler flag on the MGE
cells; within ~15 % on the pixelized cells, where it is the slightly slower one. About +25 %
against the deadlocking default on group/mge.
- **`--xla_cpu_enable_concurrency_optimized_scheduler=false`.** Also avoids the hang; about 2x
slower per call on the MGE cells.
- **No flag** with a jaxlib that fixes the fault (none known), or **drop the JAX CPU setups**
from 2d.

## Decision

Keep `--xla_cpu_multi_thread_eigen=false`, the workaround the 2d driver already applies, for the
2d JAX CPU legs (RAL CPU legs and the A100 node's `jax_cpu_sparse_fp64` leg; inert for GPU
executables). The human chose it as the one that keeps the fastest run times, and asked that the
knowledge be kept in Pulse.

One flag for every cell: the human also ruled (2026-10-29, "keep one option for every cell, as
now") against a per-variant choice, such as the scheduler flag on the pixelized cells where it
measured slightly faster. Every 2d JAX CPU leg, MGE and pixelized, compiles with the eigen flag.

## Implications

- No code changes: the 2d driver
(`scripts/misc/likelihood_breakdown/galaxy_group_standard.py`, `XLA_CPU_WORKAROUND_FLAG`)
already appends the flag and records it in each row's `device.xla_flags` and
`configuration.xla_cpu_workaround`.
- A 2d JAX CPU row is not like-for-like with a 2a/2b JAX CPU row, which ran without the flag.
- This record sets no library or workspace default. PyAutoNerves is unchanged; the per-backend
question of which XLA flags to set by default stays with task
[pair_jax_xla_env_vars_with_measured](../tasks/pair_jax_xla_env_vars_with_measured.md).
- Recording the decision submits no compute and gives no batch go.

## Revisit conditions

- A jax / jaxlib version other than 0.11.2: re-run the minimal repro with `XLA_FLAGS` empty; if
it no longer hangs, dropping the flag is a new decision.
- Evidence from RAL that the default does not hang there, or that the flag costs more than on
the laptop.
- Evidence that the 2a/2b JAX CPU executables also hang, which would widen the question to them.

## History

First record for this choice (2d decision D12, drafted 2026-10-29, decided the same day).
147 changes: 147 additions & 0 deletions knowledge/xla_cpu_deadlock_jaxlib_0_11_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# XLA:CPU deadlock on repeated calls (jaxlib 0.11.2)

Status: knowledge. Written 2026-10-29 for likelihood-lifecycle phase 2d
([autolens_profiling#473](https://github.com/PyAutoLabs/autolens_profiling/issues/473), draft PR
[#484](https://github.com/PyAutoLabs/autolens_profiling/pull/484)). The human's choice of
workaround is recorded separately, in
[decisions/xla-cpu-deadlock-eigen-workaround.md](../decisions/xla-cpu-deadlock-eigen-workaround.md).
Evidence is on the 2d campaign pages at
[`caa46fad`](https://github.com/PyAutoLabs/autolens_profiling/blob/caa46fad/wiki/campaigns/multi_galaxy/likelihood_lifecycle_p2d.md#xlacpu-deadlock-found-in-the-laptop-smokes-avoided-by-d12)
(shared page) and
[`caa46fad`](https://github.com/PyAutoLabs/autolens_profiling/blob/caa46fad/wiki/campaigns/group/likelihood_lifecycle_p2d.md)
(group page). All timings below are from one laptop (8 cores) on the local library mains, not
the pinned release. Pulse records this; it does not apply, detect or enforce a flag.

## Symptom and how to recognise it

- Lowering, compiling and the first call of a jitted likelihood return normally. A later call of
the **same compiled executable** never returns. Which call hangs varies run to run (seen from
call 1 to about call 35), so a short smoke (2 steady calls) can pass by luck.
- The process sits at **0 % CPU**. No thread is doing work.
- `faulthandler` puts the Python thread in JAX's `stages.py` `__call__`.
- Native stacks (`py-spy record --native --idle`, started as the parent of the run) show
`CpuPjRtRawLoadedExecutable::Execute` -> `tsl::BlockUntilReady` -> `absl::Mutex` futex wait.
- CPU backend only. GPU executables were not seen to hang; a GPU analogue was not tested.

A run that sits at 0 % CPU inside a compiled call is this hang, not a slow compile and not a slow
likelihood. Do not raise a wall time for it.

## Where it was seen

jax / jaxlib **0.11.2**, XLA:CPU. It hit every 2d (`multi_galaxy` + `group`) JAX CPU cell run on
the laptop: MGE, rectangular and Delaunay, dense and sparse. Prefix bisection over the breakdown
stages: group MGE hangs from prefix 3 (data vector) on, group Delaunay from prefix 4 (curvature
matrix); prefixes 1-2 ran 300 calls.

Ruled out: the persistent compilation cache (hangs with `JAX_ENABLE_COMPILATION_CACHE=false`),
BLAS threads (`OPENBLAS/OMP/MKL_NUM_THREADS=1`), the Delaunay `pure_callback` (the MGE cells have
no host callback and hang too), the flat-pytree-leaves driver change, the `dPIEMassSph` mass
(multi_galaxy has none and hangs), and `--xla_disable_hlo_passes=constant_folding` (hangs without
it). A plain jitted `A.T @ A` at the cell's size (17,692 x 1,300), with or without a scipy
`pure_callback`, ran 30 calls fine.

## Minimal reproduction (no PyAuto code in the process)

1. In the cell's own process, build the group MGE cell, take iid draw 0, flatten the instance to
its pytree leaves, and `jax.jit` the breakdown's prefix-3 function (params -> data vector).
Export it: `jax.export.export(jf)(params)`, then pickle `exp.serialize()` together with the
leaves as NumPy arrays. (The 2d driver's helpers are `_jax_cell`, `_flat_params` and
`_stage_value` in `scripts/misc/likelihood_breakdown/galaxy_group_standard.py`.)
2. In a fresh `python -I` process that imports **only jax**:

```python
import pickle
import sys

import jax

jax.config.update("jax_enable_x64", True)
d = pickle.load(open(sys.argv[1], "rb"))
exp = jax.export.deserialize(d["exp"])
params = [jax.numpy.asarray(p) for p in d["params"]]
c = jax.jit(exp.call).lower(params).compile()
for i in range(300):
c(params).block_until_ready() # with a faulthandler timeout around each call
```

With `XLA_FLAGS` empty it deadlocks at about call 14. With either flag below it runs all 300
calls. The exported module (about 3 MB) is evidence for an upstream JAX issue; it is not
committed to any repo.

## The two flags that avoid it

Either flag appended to `XLA_FLAGS` before the JAX backend starts avoids the hang:

- `--xla_cpu_multi_thread_eigen=false`: Eigen ops inside an XLA:CPU thunk run single-threaded.
- `--xla_cpu_enable_concurrency_optimized_scheduler=false`: XLA:CPU uses its default thunk
schedule instead of the concurrency-optimized one.

So the fault sits in the interplay of multi-threaded Eigen ops and the concurrency-optimized
schedule in XLA:CPU. Neither flag changes what the likelihood computes (every 2d smoke kept
parity `match`); both change how fast it runs.

Steady median per call, full pipelines, laptop, dense JAX CPU:

| Cell | default flags | `multi_thread_eigen=false` | `concurrency_optimized_scheduler=false` |
|---|---|---|---|
| group/mge | 0.064 s, then hung after 35 calls | 0.080 s (150/150) | 0.154 s (150/150) |
| multi_galaxy/mge | hung after 1 call | 0.053 s (40/40) | 0.104 s (40/40) |
| group/delaunay | hung after 1 call | 4.57 s (15/15) | 4.42 s (15/15) |
| multi_galaxy/rectangular | hung after 1 call | 2.19 s (15/15) | 1.90 s (15/15) |

On the MGE cells `multi_thread_eigen=false` is about 2x faster than the scheduler flag. On the
pixelized cells the two are within about 15 %, and the scheduler flag is the slightly faster one
there. Against the deadlocking default (measured only on group/mge, before it hung),
`multi_thread_eigen=false` costs about 25 % per call.

## The decision

The human chose `--xla_cpu_multi_thread_eigen=false` on 2026-10-29: "keep the workaround which
ensures we retain the fastest run times and make sure this knowledge is retained in Pulse for
going forward". The record, its scope and its revisit conditions are in
[decisions/xla-cpu-deadlock-eigen-workaround.md](../decisions/xla-cpu-deadlock-eigen-workaround.md)
(2d decision D12).

## Reading rows measured with the flag

- A row whose JAX leg ran with the flag records it in `device.xla_flags` and in
`configuration.xla_cpu_workaround` (the 2d driver writes both).
- Such a row is **not like-for-like** with a row measured without the flag: the flag is a compile
option that changes per-call cost. The 2a (imaging) and 2b (interferometer) JAX CPU rows were
measured without it. Comparing a 2d JAX CPU row with a 2a/2b JAX CPU row mixes the setup cost
with the flag's cost (about +25 % on group/mge, the one cell where a no-flag time exists).
- Read the two fields before pairing JAX CPU rows. Pulse displays them; it does not refuse or
adjust a pairing because of them, and it does not infer the flag from timings.

## Open questions

- **RAL.** The pin 2026.10.25.1 runs the same jaxlib 0.11.2 on RAL (its 2026.10.17.1
`hpc_ral_cpu` rows record jaxlib 0.11.2). Whether the deadlock fires on a 236-core RAL node is
untested. The 2d legs apply the flag there regardless.
- **The 2a / 2b JAX CPU cells.** They were measured without the flag and completed. Nobody has
tested whether those executables are susceptible on repeated calls, or whether a longer run
(a fit) would hang.
- **GPU.** The flag is inert for a GPU executable; whether the GPU runtime has an analogue was
not tested.
- **When to re-test and drop the flag.** Any jax / jaxlib upgrade away from 0.11.2 (a new
release pin or a change to the PyAutoNerves jax bounds) should trigger the minimal repro
above with `XLA_FLAGS` empty. If it runs 300 calls, the next campaign may propose dropping the
flag; that is a new human decision, recorded with a "Supersedes" link.
- **Relation to the August Eigen-pool deadlock.** PyAutoMind
`complete/2026/08/xla-cpu-eigen-pool-deadlock.md` (an `FftThunk` handing ducc0 the Eigen pool)
was avoided by the same `--xla_cpu_multi_thread_eigen=false` flag, which the test workspaces
set in CI only. Whether the 2d hang is the same fault is not established; its stack shows no
thread working. The broader per-backend measurement of XLA flags is task
[pair_jax_xla_env_vars_with_measured](../tasks/pair_jax_xla_env_vars_with_measured.md).

## Links

- autolens_profiling draft PR [#484](https://github.com/PyAutoLabs/autolens_profiling/pull/484)
(branch `feature/likelihood-lifecycle-p2d-galaxy-group`), issue
[#473](https://github.com/PyAutoLabs/autolens_profiling/issues/473).
- 2d shared campaign page (D12 and the "XLA:CPU deadlock" section):
[`wiki/campaigns/multi_galaxy/likelihood_lifecycle_p2d.md`](https://github.com/PyAutoLabs/autolens_profiling/blob/feature/likelihood-lifecycle-p2d-galaxy-group/wiki/campaigns/multi_galaxy/likelihood_lifecycle_p2d.md).
- 2d group page:
[`wiki/campaigns/group/likelihood_lifecycle_p2d.md`](https://github.com/PyAutoLabs/autolens_profiling/blob/feature/likelihood-lifecycle-p2d-galaxy-group/wiki/campaigns/group/likelihood_lifecycle_p2d.md).
- The driver that applies the flag (`XLA_CPU_WORKAROUND_FLAG`, `_avoid_xla_cpu_deadlock`):
[`scripts/misc/likelihood_breakdown/galaxy_group_standard.py` at `caa46fad`](https://github.com/PyAutoLabs/autolens_profiling/blob/caa46fad/scripts/misc/likelihood_breakdown/galaxy_group_standard.py).
37 changes: 29 additions & 8 deletions pulse/setup_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,34 @@ def assets():
)
PRECISIONS = ("fp64", "fp32", "fp16", "bf16", "mixed")
PNT = "projected_node_throughput"
KNOWLEDGE_URL = (
"https://github.com/PyAutoLabs/PyAutoPulse/blob/main/knowledge/cpu_parallel_vs_gpu_batched.md"
)
KNOWLEDGE_TITLE = "Comparing CPU-parallel and GPU-batched setups"
KNOWLEDGE_BASE_URL = "https://github.com/PyAutoLabs/PyAutoPulse/blob/main/knowledge/"
DP = 5 # display rounding of every per-call time (presentation only)


def knowledge_pages(root: Path = ORGAN_ROOT) -> list[tuple[str, str]]:
"""``(title, url)`` for every ``knowledge/*.md`` page, ordered by file name.

The title is the page's first ``# `` heading (the file stem if it has none).
"""
pages = []
for path in sorted((Path(root) / "knowledge").glob("*.md")):
title = next(
(ln[2:].strip() for ln in path.read_text().splitlines() if ln.startswith("# ")),
path.stem,
)
pages.append((title, KNOWLEDGE_BASE_URL + path.name))
return pages


def _knowledge_html() -> str:
links = "".join(
f'<p data-id="knowledge-link"><a href="{html.escape(url)}" target="_blank" '
f'rel="noopener" title="Opens in a new tab">{html.escape(title)}</a></p>'
for title, url in knowledge_pages()
)
return f'<div data-id="knowledge-links">{links}</div>'


def lifecycle(doc) -> bool:
return isinstance(doc, dict) and doc.get("version") == 3

Expand Down Expand Up @@ -451,9 +472,8 @@ def _render_lifecycle(snapshot):
"No record matches this selection.</p>"
+ coverage
+ '<h4 class="extra-info">Extra Information</h4>'
f'<p data-id="knowledge-link"><a href="{KNOWLEDGE_URL}" target="_blank" rel="noopener" '
f'title="Opens in a new tab">{KNOWLEDGE_TITLE}</a></p>'
"</section>"
+ _knowledge_html()
+ "</section>"
)


Expand Down Expand Up @@ -935,7 +955,8 @@ def _markdown_lifecycle(snapshot):
missing = not_measured(doc)
lines += ["", f"Coverage: {len(missing)} optimal cell(s) not measured.", ""]
lines += [f"- {esc(_cell_label(c))}" for c in missing]
lines += ["", "#### Extra Information", "", f"[{KNOWLEDGE_TITLE}]({KNOWLEDGE_URL})"]
lines += ["", "#### Extra Information", ""]
lines += [f"- [{title}]({url})" for title, url in knowledge_pages()]
lines += ["", "</details>", ""]
return lines

Expand Down
11 changes: 11 additions & 0 deletions tasks/pair_jax_xla_env_vars_with_measured.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ GitHub sources and limits. Current RAL queue was empty; the transfer preview tim
out, so historical jobs and unpulled results remain unverified. Review time does
not refresh measurements or authorize compute. Historical task text is retained.


## Note — 2026-10-29

- Related finding, not a step of this task: likelihood-lifecycle 2d hit a jaxlib 0.11.2 XLA:CPU
deadlock on repeated calls, avoided by either `--xla_cpu_multi_thread_eigen=false` or
`--xla_cpu_enable_concurrency_optimized_scheduler=false`, with per-call costs for both.
Knowledge: [xla_cpu_deadlock_jaxlib_0_11_2](../knowledge/xla_cpu_deadlock_jaxlib_0_11_2.md).
The human kept the eigen flag for the 2d JAX CPU legs on 2026-10-29
([decision record](../decisions/xla-cpu-deadlock-eigen-workaround.md)); that sets no library
default, so this task's question is unchanged.

---

# Pair JAX/XLA env vars with measured compile and run times, per backend
Expand Down
9 changes: 6 additions & 3 deletions tests/browser_setup.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,12 @@ const { execFileSync } = require("node:child_process");
"1 optimal cell not measured",
),
);
const knowledge = life.locator('[data-id="knowledge-link"] a');
assert(await knowledge.isVisible());
assert.equal(await knowledge.getAttribute("target"), "_blank");
const knowledge = life.locator('[data-id="knowledge-links"] [data-id="knowledge-link"] a');
assert((await knowledge.count()) >= 1);
for (const link of await knowledge.all()) {
assert(await link.isVisible());
assert.equal(await link.getAttribute("target"), "_blank");
}
// Bold 5-DP runtime; headers on one line (no "Likeliho- od").
const runtime = row("imaging-delaunay-hst-ral-runtime").locator("td.num b").first();
assert.equal(await runtime.textContent(), "0.21000");
Expand Down
Loading
Loading