Repository navigation
Whole lectures: lecture-python.myst on the T4 runner and its CPU - #22
Merged
Merged
Conversation
Run 41271786393 of the run_lectures job with lecture-python (#19), on RunsOn's g4dn.2xlarge, three runs of the 33 lectures on each device. The README's lecture-python section gains the per-lecture table. run_lecture.py: a lecture that asks for a platform the run withholds (sargent_surico sets jax_platform_name to cpu, under JAX_PLATFORMS=cuda) made jax.devices() raise after the cells had run, so no row was written. It now resets the platform, records platform_error, and keeps the row. Also corrects the README's sargent_surico comparison with QuantEcon/lecture-python.myst#1022, whose 157 s is the NUTS cell, not the lecture. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The review surfaced no objective defects, with the lone code change being a small, well-scoped harness fix and the remaining files intentionally committed benchmark artifacts and traceback evidence.
No open issues 🎉
What changed in this PR
This PR records the results of running lecture-python.myst's 33 JAX lectures three times each on the lectures' CI runner (RunsOn g4dn.2xlarge) — on the T4 GPU and on its host Xeon CPU — as part of issue #4, using the run_lectures job added in #19. Alongside the data, it makes one harness fix so that sargent_surico (which pins JAX to the CPU, a backend withheld under JAX_PLATFORMS=cuda) still produces a result row instead of crashing the whole run.
Changes:
- Harness fix in
lectures/run_lecture.py: wrapjax.devices()in atry/except RuntimeError, record the failure asplatform_error, resetjax_platform_name, and retry so the row (with its failed cells) is still written. - Commit per-lecture benchmark results as
cuda-*/cpu-*JSON underlectures/results/runson-g4dn.2xlarge/2026-11-01/lecture-python/. - Keep the three pre-fix
sargent_surico/cuda-*.errtracebacks as evidence of the failure the harness change addresses.
| File | Description |
|---|---|
lectures/run_lecture.py |
Adds try/except around jax.devices() to tolerate a withheld platform, record platform_error, and still write the row. The retry resolves to the available backend under the job's JAX_PLATFORMS, and all cells have already run/been recorded by this point, so the inline comment holds. |
.../lecture-python/sargent_surico/cuda-{1,2,3}.err |
Pre-fix tracebacks (RuntimeError: Unknown backend cpu) kept as the evidence motivating the harness change; not matched by any gitignore rule, so intentionally committed. |
.../lecture-python/mccall_risk/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of mccall_risk (as-written, float32). |
.../lecture-python/mccall_persist_trans/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of mccall_persist_trans. |
.../lecture-python/mccall_model_with_separation/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of mccall_model_with_separation. |
.../lecture-python/kesten_processes/{cuda,cpu}-as-written-{1,2,3}.json |
Runs showing the T4's large lead (GPU ~5 s vs CPU ~150 s on the plotting cell). |
.../lecture-python/jv/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of jv. |
.../lecture-python/inventory_dynamics/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of inventory_dynamics. |
.../lecture-python/ifp_advanced/{cuda,cpu}-as-written-{1,2,3}.json |
Runs where the CPU is far slower (~10 min vs ~22 s). |
.../lecture-python/endogenous_lake/{cuda,cpu}-as-written-{1,2,3}.json |
Runs showing the T4 losing badly (~499 s vs ~24 s) due to the Python bisection loop. |
.../lecture-python/career/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of career. |
.../lecture-python/ar1_turningpts/{cuda,cpu}-as-written-{1,2,3}.json |
Three T4 and three Xeon runs of the NumPyro/ArviZ lecture ar1_turningpts. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lecture-python.myst's 33 JAX lectures on the lectures' CI runner, RunsOn's
g4dn.2xlarge: three runs of each on the T4 and on its own Xeon, from run 41271786393 of therun_lecturesjob added in #19. Part of #4. The per-lecture table is in the README's lecture-python section, beside the M5 Pro's.sargent_suricoimp_sample,kesten_processes,ifp_advancedandaiyagari_egm. Its own CPU is ahead by more than 2× on 5.imp_sample: 4,050 s on the Xeon, against 104 s on the T4.endogenous_laketakes 499 s on the T4 against 24 s on the Xeon. One cell runs a Python bisection 1,200 times, each step a jitted solve with alax.while_loopof small iterations, so the card pays its latency at every step. It carries 475 s of the ~840 s that building each lecture on the faster device would save.sargent_suricopins its JAX to the CPU, in the cell that first imports JAX, so its time on the runner is the Xeon's: 874 s, close to the 14m52s jax on the GPU runner is >2.7x slower than its CPU for a small float64 model (sargent_surico NUTS cell) lecture-python.myst#1022 reports for it there once pinned.A harness change in
lectures/run_lecture.py. Under the card'sJAX_PLATFORMS=cuda,sargent_surico's request for the CPU made the harness's ownjax.devices()raise after every cell had run, so the three runs wrote no result (their tracebacks are thecuda-*.errfiles). It now resets the platform, records the error asplatform_error, and keeps the row with its failed cells. Tested locally with a two-cell lecture that asks for a withheld platform: before, no row; after, the row with the failed cell and the error.A correction to the README. It said
sargent_surico's 158 s on the M5 Pro matches #1022's 157 s, but #1022's figure is its NUTS cell, not the lecture. On the M5 Pro that cell takes 67 s, and #1022 reports 309 s for the lecture on a laptop.The two jobs'
environment.txtfiles are identical, so one is kept. The artifact's2026-10-25/whole/directory is the committed lecture-jax results that the upload's path also matched, and is left out.🤖 Generated with Claude Code