Skip to content

Phase 0 and Phase 1 results, and two diagnoses - #6

Merged
mmcky merged 2 commits into
mainfrom
phase0-phase1-results
Oct 25, 2026
Merged

mmcky merged 2 commits into
mainfrom
phase0-phase1-results

Conversation

@mmcky

@mmcky mmcky commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

The first full runs of #1's precision matrix, from main at 9bd776a, and two diagnoses that came out of them. precision/runs/2026-10-25/README.md has the conditions.

What's here

Run Machine Rows
Phase 0 qe-mini1's M6 CPU, agents paused for the 2 minutes 46
Phase 1 qe-wharton1-gpu: the Threadripper, one TITAN RTX (0b:00.0), both cards 120
Phase 1, interleave the CPU under numactl --interleave=all 46
Phase 1, cuda12 the whole matrix under jax[cuda12] 120

python precision/summarise.py results/ gives the tables. The dashboard (QuantEcon/project-benchmarks-jax) picks these up on its next build once this merges.

The float64 cost at a glance

float64 time over float32 time, warm, at the largest sizes:

Kernel TITAN RTX Threadripper M6
matmul (compute), n = 8,192 24.5× 2.3× 2.7×
Bellman step over stored rewards (memory), 40k 3.8× 1.2× 3.2×
Bellman step recomputing rewards (transcendental), 60k 26.8× 1.5× 2.0×
Kalman filter (latency), T = 100k 1.3× 0.9× 0.3×, see below

Two diagnoses

  • The M6's Kalman filter runs ~3.5× slower in float32 than in float64. Its 10 × 10 products go through XLA's YNNPACK fusion, which costs about 1.1 µs per call in float32 on the M6, against 0.16 µs in float64. XLA_FLAGS=--xla_cpu_experimental_ynn_fusion_type= removes the gap, but large float32 matmuls then lose up to 2.4×. The rows use the default.
    • Evidence: precision/runs/2026-10-25/checks/.
    • The precision README's caveats now say this, and also give a more accurate picture of JAX's use of Apple's matrix unit: about 2 TFLOPS in float32 at n = 1,024, but about 900 GFLOPS from n = 4,096.
  • aiyagari_jax's float32 NaN on the card at a 5,000-point grid (from Lectures run as used: aiyagari_jax and ifp_egm_jax in float32 and float64 #3). JAX's bicgstab stalls in float32, then at step 46 ⟨r̂, q⟩ rounds to exactly zero. That makes alpha infinite and omega NaN, which the solver's exact-zero breakdown test misses, so it returns NaN. The lecture's while error > tol then stops, because NaN > tol is false.
    • Evidence: lectures/aiyagari_jax/nan_check.py, bicgstab_jit_trace.py and checks/bicgstab_nan_trace.txt.
    • It's repeatable, and it doesn't happen on the CPU.

🤖 Generated with Claude Code

- results/qe-mini1/2026-10-25.jsonl: Phase 0, the precision matrix on
  qe-mini1's M6 CPU, with the agents paused (46 rows).
- results/qe-wharton1-gpu/2026-10-25.jsonl: Phase 1 on the Threadripper,
  one TITAN RTX and both cards (120 rows); the CPU under numactl
  --interleave=all (label interleave, 46 rows); and the whole matrix
  under jax[cuda12] (label cuda12, 120 rows).
- precision/runs/2026-10-25/: the drivers, logs and machine state, and
  checks/ on why the Kalman filter is ~3.5x slower in float32 than in
  float64 on the M6. XLA's YNNPACK fusion costs ~1.1 us per small float32
  matrix product there, against ~0.16 us in float64. The precision README's
  caveats now say so, with the flag that turns the fusion off, and give the
  M6's matrix-unit picture.
- lectures/aiyagari_jax/: where float32 goes NaN on the card. JAX's
  bicgstab breaks down with an infinite alpha that its exact-zero checks
  miss, and the lecture's loop takes the NaN as convergence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 25, 2026 05:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It consists mostly of large empirical result/log artifacts and hardware-specific diagnoses that cannot be independently verified in review, so final human sign-off is prudent beyond the minor docstring-filename fixes flagged.

3 open issues
What changed in this PR

This PR adds the first full results of the precision benchmark matrix (from #1/#2) run on 2026-10-25, plus two diagnostic write-ups that came out of those runs. It is purely additive: committed result data, run logs/scripts, and short one-off diagnostic scripts, with documentation tying them together. It feeds the external dashboard once merged.

Changes:

  • Commits Phase 0 (M6 CPU, qe-mini1) results as results/qe-mini1/2026-10-25.jsonl, with the run driver, log, and machine-state capture under precision/runs/2026-10-25/.
  • Diagnoses the M6 Kalman float32 slowdown (XLA ynn_fusion on small matmuls) with checks/ scripts/output and expanded precision/README.md caveats.
  • Diagnoses aiyagari_jax's float32 NaN at a 5,000-point grid (bicgstab breakdown test misses inf/NaN) via nan_check.py, bicgstab_jit_trace.py, and a committed trace.
File Description
results/​qe-mini1/​2026-10-25.jsonl Phase 0 result rows (46); internally consistent with phase0.log
precision/​runs/​2026-10-25/​README.md Run conditions, machine/row summary, skip notes
precision/​runs/​2026-10-25/​phase1.sh /​ phase1.log GPU-box driver and its full console output
precision/​runs/​2026-10-25/​phase0.sh /​ phase0.log /​ phase0-state.txt Mac driver (SIGSTOP/CONT), log, and before/paused/after state
precision/​runs/​2026-10-25/​checks/​ynn.txt YNN/XNN fusion timing evidence for the Kalman diagnosis
precision/​runs/​2026-10-25/​checks/​ynn_dot_check.py Small-matmul-by-precision probe; usage line names wrong file
precision/​runs/​2026-10-25/​checks/​kalman_ops_check.py Per-op Kalman timing probe; usage line names wrong file
precision/​README.md Expanded Apple matrix-unit / small-matmul caveats
lectures/​results/​.../​checks/​bicgstab_nan_trace.txt Committed step-by-step bicgstab NaN trace
lectures/​aiyagari_jax/​README.md Documents the two new NaN-diagnosis scripts
lectures/​aiyagari_jax/​nan_check.py Steps the policy iteration to the first non-finite value
lectures/​aiyagari_jax/​bicgstab_jit_trace.py Reproduces JAX's bicgstab body; usage line names wrong file

Review effort: Balanced

The usage lines kept the names the scripts had before they were copied
in: bicgstab_trace.py, kalman_check.py and dot_check.py. As Copilot
pointed out, the commands as written wouldn't run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants