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
92 changes: 92 additions & 0 deletions decisions/jax-cpu-policy-2026-11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# JAX CPU policy: XLA:CPU deadlocks — November 2026

Status: RECOMMENDATION (research, PyAutoNerves#213). Evidence complete; awaiting a Heart
validation of the proposed range before any requirement changes.
Supersedes: [jax-2026-10-04](jax-2026-10-04.md) (review date 2026-11-04 passed).
Owner: PyAutoBrain; validation authority: PyAutoHeart; evidence: PyAutoDNA research records.

## The problem

On the CPU backend, a compiled JAX likelihood sometimes stops for good: a later call of the same
compiled executable never returns and the process sits at 0 % CPU. Since August 2026 this was
patched five times in five places (test-workspace CI flags, Heart release legs, a profiling
driver, a private RAL job script, and a version exclusion for a different LAPACK path). None of
these reached users' installs, and the then "recommended validation baseline", jax 0.11.2,
still hangs.

## Evidence (DNA hang matrix)

Each reproducer runs many times in a process that imports only jax (or, for Delaunay, through
the library with PyAutoNerves' default XLA flags). A stall with no CPU work is a hang.
Laptop pilot, 8 cores, 2026-11-10, one repeat per cell:

| 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) | hang, call 4 | pass, 0.064 s | pass, 0.062 s | pass, 0.064 s |
| multi_galaxy MGE (full) | hang, call 94 | pass, 0.048 s | pass, 0.045 s | pass, 0.040 s |
| group Delaunay (full, library) | hang, call 1 | pass, 4.54 s | pass, 4.30 s | pass, 4.31 s |
| FFT pool (scatter-fed FFTs) | hang, call 1 | pass | pass | pass |

- The scheduler flag (`--xla_cpu_enable_concurrency_optimized_scheduler=false`) also avoids the
hang on 0.11.2 but costs 1.4-2x per call on MGE; on 0.12.0.1 it is still 1.6-2x slower.
- 0.9.2 and 0.10.2 ran the 0.11.2-exported group MGE module without a hang (20 calls).
- The batched-Cholesky case did not reproduce the October LAPACK hang even on 0.10.2, so it is
not evidence either way; the 0.10.* / 0.11.0 exclusion rests on its original reproduction.
- Upstream: the FFT-pool deadlock is jax-ml/jax#41265 (regression in 0.11.1), fixed by
openxla/xla#50091 (merged 2026-10-06), released in jax 0.12.0 (2026-10-19). No upstream issue
was found for the MGE / Delaunay hang (no thread working, unlike the FFT latch).

RAL repeat matrix (job 415009, 2026-11-11, AMD EPYC 7763 nodes): jax 0.9.2 / 0.11.2 / 0.12.0 /
0.12.0.1 x {no flag, eigen flag, scheduler flag} x {4, 16} cores x 5 repeats, 300 calls per cell,
600 cells, 180,000 calls in all.

| jax | no flag, 4 cores | no flag, 16 cores | eigen flag | scheduler flag |
|---|---|---|---|---|
| 0.11.2 | **hang in 25 / 25 cells, all 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 |
| 0.9.2 | pass (fft, group MGE data vector) | pass | pass | pass |

0.9.2 cannot read the three full-likelihood modules exported from 0.11.2 (StableHLO is newer
than it), so it is only partly tested.

What this adds to the pilot:

- On 0.11.2 the hang depends on the cores the process has: always at 4 cores, intermittent at 8
(laptop), not seen at 16. Small containers, CI runners and laptops are the most exposed; a
large node can hide the bug.
- Per-call cost of the flags on 0.12.0.1 (steady median):

| Likelihood | cores | no flag | eigen flag | scheduler flag |
|---|---|---|---|---|
| group MGE (full) | 4 / 16 | 0.056 / 0.040 s | 0.055 / 0.040 s | 0.086 / 0.084 s |
| multi_galaxy MGE (full) | 4 / 16 | 0.037 / 0.025 s | 0.038 / 0.026 s | 0.062 / 0.056 s |
| multi_galaxy rectangular (full) | 4 / 16 | 1.44 / 0.91 s | 1.71 / 1.35 s | 1.27 / 0.91 s |
| fft | 4 / 16 | 0.159 / 0.071 s | 0.146 / 0.120 s | 0.139 / 0.113 s |

The eigen flag is free for MGE but costs 18 % (4 cores) to about 50 % (16 cores) on the
pixelized likelihood; the scheduler flag costs 1.5-2x on MGE. Neither is free everywhere.

## Recommended policy (pending Heart validation)

1. Require `jax>=0.12.0,<0.13` and `jaxlib>=0.12.0,<0.13` in PyAutoNerves. Both bounds move
together: jax 0.12.0 itself accepts jaxlib 0.11.2. This replaces the 0.7 floor and the
0.10.* / 0.11.0 exclusions. Python (>=3.12) is unchanged; numpy's floor becomes 2.2; x86-64
needs a Haswell (2013) or newer CPU. 0.12.0 and 0.12.0.1 behave the same on Linux.
2. Do not add a default XLA:CPU flag. On 0.12 no reproducer needs one, and the eigen flag slows
pixelized likelihoods by up to about 50 %. Remove the per-place eigen-flag workarounds once the
floor is released (CI test workspaces, Heart release legs, the autolens_profiling 2d driver,
job scripts), each re-checked on 0.12 first.
3. Guard: a scheduled Heart check runs the exported reproducers for 300 calls at 4 cores on
every jax version the requirement allows (4 cores is where the 0.11.2 hang is certain) and
writes the result into DNA. The DNA board marks any observed environment whose jax version
and XLA flags match a hanging setup.

## Open before deciding

- Heart validation of the full library and workspace suites on 0.12 (CPU and GPU, including
blackjax, optax, nufftax, jaxnnls and the CUDA plugins).
- The CI hang of `multi_dataset/jax_likelihood/delaunay_mge.py`, which hung twice on 0.11.2
even with the eigen flag set: rerun on 0.12.

Review date: 2026-12-10.
96 changes: 90 additions & 6 deletions dna/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import yaml
from packaging.requirements import Requirement
from .campaigns import Store
from .inventory import public_inventory, PUBLIC_PACKAGES, PUBLIC_REPOSITORIES
from .inventory import public_inventory, public_runtime, PUBLIC_PACKAGES, PUBLIC_REPOSITORIES
from .matrix import CHECK_FIELDS, MATRIX_SOURCE
from .schema import identifier, now, read, timestamp

URL = 'https://pyautolabs.github.io/PyAutoDNA/'
Expand Down Expand Up @@ -38,6 +39,55 @@ def registry(root):
return obj['environments']


SIMPLE = __import__('re').compile(r'[A-Za-z0-9_.:/-]{1,100}')


def public_check(check):
"""A validation check reduced to allowlisted fields with simple values."""
if isinstance(check, str):
return check if SIMPLE.fullmatch(check) else None
if not isinstance(check, dict):
return None
out = {}
for key in CHECK_FIELDS:
value = check.get(key)
if value is None or isinstance(value, (int, float)) and not isinstance(value, bool):
out[key] = value
elif isinstance(value, str) and SIMPLE.fullmatch(value):
out[key] = value
return out if out.get('case') else None


#: XLA options that decide whether the XLA:CPU deadlock can fire (PyAutoNerves#213). Other
#: options (e.g. --xla_disable_hlo_passes=constant_folding) were tested and do not.
HANG_OPTIONS = ('xla_cpu_multi_thread_eigen', 'xla_cpu_enable_concurrency_optimized_scheduler')


def stack_key(packages, xla_options):
relevant = [o for o in (xla_options or []) if o.lstrip('-').split('=')[0] in HANG_OPTIONS]
return (packages.get('jax'), tuple(sorted(relevant)))


def jax_cpu_policy(records):
"""Latest DNA research verdict per (stack, environment), with the stack's jax and XLA options."""
stacks = {r['digest']: r for r in records if r['kind'] == 'stack'}
research = latest([r for r in records if r['kind'] == 'validation' and r.get('authority') == 'PyAutoDNA'],
'validation', lambda r: (r['stack'], r['environment']))
rows = []
for r in research.values():
stack = stacks.get(r['stack'], {})
options = stack.get('runtime_flags', {}).get('xla_options', [])
checks = [c for c in r.get('checks', []) if isinstance(c, dict)]
hangs = [c for c in checks if c.get('outcome') == 'hang']
rows.append({'jax': stack.get('packages', {}).get('jax', 'Unknown'), 'xla_options': options,
'environment': r['environment'], 'result': r['result'], 'created': r['created'],
'cells': len(checks), 'passed': sum(c.get('outcome') == 'pass' for c in checks),
'hung': len(hangs),
'hung_cases': sorted({c['case'] for c in hangs}),
'first_hang': min((c['hung_at_call'] for c in hangs if c.get('hung_at_call') is not None), default=None)})
return sorted(rows, key=lambda x: (x['jax'], x['environment'], ' '.join(x['xla_options'])))


def public_records(records):
result = []
for obj in records:
Expand All @@ -50,6 +100,13 @@ def public_records(records):
'inventory', 'result', 'authority', 'review_date', 'validations', 'latest',
'compatible_stable')
clean = {k: obj[k] for k in allowed if k in obj}
if obj['kind'] == 'validation' and isinstance(obj.get('checks'), list):
clean['checks'] = [c for c in (public_check(c) for c in obj['checks']) if c is not None]
if obj['kind'] == 'stack' and isinstance(obj.get('runtime_flags'), dict):
flags = obj['runtime_flags']
# private stacks carry raw flags; already-public ones carry the filtered fields
runtime = public_runtime({'flags': flags, **{k: flags[k] for k in ('xla_options', 'platforms') if k in flags}})
clean['runtime_flags'] = {k: runtime[k] for k in ('xla_options', 'platforms') if k in runtime}
if 'packages' in clean:
clean['packages'] = {k: v for k, v in clean['packages'].items() if k in PUBLIC_PACKAGES}
if obj['kind'] == 'audit':
Expand Down Expand Up @@ -86,7 +143,8 @@ def snapshot(root, max_age_days=7):
raise ValueError('unsupported public projection schema')
current = {}
for obj in records:
if obj['kind'] == 'inventory':
if obj['kind'] == 'inventory' and obj['runtime'].get('source') != MATRIX_SOURCE:
# a hang-matrix inventory describes a throwaway test interpreter, not the environment
inv = public_inventory(obj)
if inv['environment'] not in current or timestamp(inv['created']) > timestamp(current[inv['environment']]['created']):
current[inv['environment']] = inv
Expand Down Expand Up @@ -167,11 +225,26 @@ def render(root, brain, output, max_age_days=7):
items.append({'id': 'dependency-' + str(index), 'severity': 'yellow', 'state': 'action_required',
'text': f"{env['label']}: {row.get('package')} {row.get('observed')} is outside {row['repository']} declarations",
'url': URL + '#compatibility'})
policy = jax_cpu_policy(records)
failing = {stack_key({'jax': r['jax']}, r['xla_options']) for r in policy if r['result'] == 'fail'}
exposed = []
for e in envs:
inv = e['observed']
if inv and inv['runtime'].get('backend') == 'cpu' and 'jax' in inv['packages']:
key = stack_key({'jax': inv['packages']['jax']['version']}, inv['runtime'].get('xla_options'))
if key in failing:
exposed.append(e)
items.append({'id': 'jax-cpu-' + e['id'], 'severity': 'yellow', 'state': 'action_required',
'text': f"{e['label']}: jax {key[0]} with {', '.join(key[1]) or 'no XLA:CPU hang flag'} hangs in the DNA hang matrix",
'url': URL + '#jax-cpu-policy'})
mismatches = mismatches + [(e, None) for e in exposed]
status = 'yellow' if mismatches else 'stale' if any(e['status'] == 'stale' for e in envs) else 'grey'
count = sum(e['status'] == 'observed' for e in envs)
headline = f'{count} / {len(envs)} environments observed'
if mismatches:
headline += f'; {len(mismatches)} declaration mismatches'
if len(mismatches) > len(exposed):
headline += f'; {len(mismatches) - len(exposed)} declaration mismatches'
if exposed:
headline += f'; {len(exposed)} on a hanging JAX CPU setup'
state = dict(schema_version=1, organ='dna', repo='PyAutoLabs/PyAutoDNA', status=status,
headline=headline, updated=board['updated'], pages_url=URL, items=items)
errors = state_contract.validate_state(state)
Expand All @@ -187,9 +260,10 @@ def render(root, brain, output, max_age_days=7):
organ='dna', refreshed_at=board['refreshed_at'], refresh_url=REPO + '/actions/workflows/pages.yml',
work_links=[{'label': 'DNA', 'href': REPO}, {'label': 'Brain', 'href': 'https://github.com/PyAutoLabs/PyAutoBrain'}])
body += '<section><h2 id="environments">Environments</h2>'
body += table(['Environment', 'Profile', 'Observed Python / backend', 'Last observation'], [
body += table(['Environment', 'Profile', 'Observed Python / backend', 'XLA options', 'Last observation'], [
[e['label'], e['declared_python'] + ' / ' + e['declared_backend'],
e['observed']['python'] + ' / ' + e['observed']['runtime']['backend'] if e['observed'] else 'Unknown',
(', '.join(e['observed']['runtime'].get('xla_options') or []) or 'Default') if e['observed'] else 'Unknown',
e['status'] + ' · ' + e['observed']['created'] if e['observed'] else 'Not collected'] for e in envs], 'Environment observations; scroll for more columns')
observed = [e for e in envs if e['observed']]
if observed:
Expand Down Expand Up @@ -235,10 +309,20 @@ def render(root, brain, output, max_age_days=7):
body += '</details>'
else:
body += '<p>No dependency audit recorded. Package requirements remain authoritative in each repository.</p>'
body += '<h3 id="jax-cpu-policy">JAX CPU policy: hang matrix</h3>'
if policy:
body += table(['jax', 'XLA options', 'Environment', 'Result', 'Reproducers passed', 'Hung (first call)', 'Recorded'], [
[r['jax'], ', '.join(r['xla_options']) or 'Default', r['environment'], r['result'],
f"{r['passed']} / {r['cells']}",
(', '.join(r['hung_cases']) + (f" (call {r['first_hang']})" if r['first_hang'] is not None else '')) if r['hung'] else 'None',
r['created']] for r in policy], 'JAX version and XLA flag hang matrix')
body += '<p class="muted">DNA research evidence: each reproducer runs many times in a process that imports only jax. A pass is not a Heart validation and never promotes a stack; a hang blocks one.</p>'
else:
body += '<p>No hang-matrix evidence recorded.</p>'
body += '<h3>Validation and promotion history</h3>'
validations = latest(records, 'validation', lambda r: (r['stack'], r['environment']))
if validations:
body += table(['Stack', 'Environment', 'Latest supplied Heart result', 'Evidence date', 'Freshness'], [[r['stack'][:12], r['environment'], r['result'], r['created'], evidence_age(r, max_age_days)] for r in validations.values()], 'Supplied validation receipts')
body += table(['Stack', 'Environment', 'Authority', 'Latest supplied result', 'Evidence date', 'Freshness'], [[r['stack'][:12], r['environment'], r.get('authority', 'PyAutoHeart'), r['result'], r['created'], evidence_age(r, max_age_days)] for r in validations.values()], 'Supplied validation receipts')
else:
body += '<p>No matching Heart validation receipt recorded. No supported stack is inferred from an observed installation.</p>'
body += '<p class="muted">Supplied validation receipts are records, not a live Heart readiness verdict. Stale evidence must be refreshed before adoption.</p>'
Expand Down
9 changes: 8 additions & 1 deletion dna/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ def _gate(self, obj, validations):
raise ValueError("promotion requires an explicit backend")
checks = [self.require(d, "validation") for d in validations]
all_checks = self.records("validation")
if any(c["authority"] != "PyAutoHeart" for c in checks):
raise ValueError("only PyAutoHeart validation can support promotion")
for env in obj["environments"]:
matching = [c for c in all_checks if c["stack"] == obj["target"] and c["environment"] == env]
latest = max(matching, key=lambda c: timestamp(c["created"])) if matching else None
heart = [c for c in matching if c["authority"] == "PyAutoHeart"]
latest = max(heart, key=lambda c: timestamp(c["created"])) if heart else None
if latest is None or latest["digest"] not in validations or latest["result"] != "pass":
raise ValueError(f"latest matching Heart evidence must pass: {env}")
research_fail = [c for c in matching if c["authority"] != "PyAutoHeart" and c["result"] == "fail"
and timestamp(c["created"]) > timestamp(latest["created"])]
if research_fail:
raise ValueError(f"newer DNA research evidence fails: {env}")
if (datetime.now(timezone.utc) - timestamp(latest["created"])).total_seconds() > 7 * 86400:
raise ValueError("stale Heart validation")
inv = self.require(latest["inventory"], "inventory")
Expand Down
9 changes: 9 additions & 0 deletions dna/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def main(argv=None):
p = sub.add_parser("export-public"); p.add_argument("--output", default="inventories/public.json")
p = sub.add_parser("collect"); p.add_argument("environment"); p.add_argument("--repo", action="append", default=[]); p.add_argument("--probe-backend", action="store_true")
p = sub.add_parser("import"); p.add_argument("file")
p = sub.add_parser("import-matrix", help="record a JAX hang-matrix run as DNA research evidence"); p.add_argument("rows"); p.add_argument("--evidence")
p = sub.add_parser("stack"); p.add_argument("name"); p.add_argument("--python", required=True); p.add_argument("--backend", choices=["cpu", "cuda", "unknown"], required=True); p.add_argument("--package", action="append", default=[])
p = sub.add_parser("diff"); p.add_argument("left"); p.add_argument("right")
p = sub.add_parser("compare"); p.add_argument("inventory"); p.add_argument("stack")
Expand Down Expand Up @@ -45,6 +46,14 @@ def main(argv=None):
raise ValueError("environment not in registry")
result = store.add(collect(args.environment, args.repo, args.probe_backend))
elif cmd == "import": result = store.add(schema.read(args.file))
elif cmd == "import-matrix":
from .board import registry
from .matrix import import_matrix
known = {e["id"] for e in registry(Path(args.root))}
rows = [json.loads(l) for l in Path(args.rows).read_text().splitlines() if l.strip()]
if any(r.get("environment") not in known for r in rows):
raise ValueError("matrix row environment not in registry")
result = import_matrix(store, args.rows, args.evidence)
elif cmd == "stack":
packages = {}
for text in args.package:
Expand Down
Loading
Loading