Repository navigation
Description
For QuantEcon/project-benchmarks-jax#1, whose tracker lists it as a candidate for #5: where a GPU overtakes a CPU on step-by-step work, as a rule of thumb for a JAX for Economists guide. Drafted 2026-11-10 at Matt's go-ahead. The plan below is agreed (Matt, 2026-11-10), with the changes from review folded in: 300 and 3,000 filters added, serial Numba dropped from 1,000 filters up, and a 1,800 s limit on the new sweeps' cells.
The question
P7's two sweeps are each one line through a plane. batch varies the number of filters at 10 states, and state varies the states for one filter. Neither says how the crossover moves when both grow, which is what a model being estimated does: more states, and a likelihood evaluated at many parameter values at once.
What #26 (b98983c) and #25 (387351b) found on 2026-11-02, warm, each device's fastest stack:
| M6 | TITAN RTX | Who wins | |
|---|---|---|---|
| float64, 1,000 filters at 10 states | 0.220 s, numba-parallel |
0.372 s | M6, 1.7× |
| float64, 10,000 filters at 10 states | 2.28 s, numba-parallel |
3.15 s | M6, 1.4× |
| float64, one filter at 200 states | 0.107 s, numba |
0.494 s | M6, 4.6× |
| float32, 100 filters at 10 states | 0.0256 s, numba-parallel |
0.135 s | M6, 5.3× |
| float32, 1,000 filters at 10 states | 0.242 s, numba-parallel |
0.135 s | TITAN, 1.8× |
| float32, 10,000 filters at 10 states | 2.37 s, numba-parallel |
0.518 s | TITAN, 4.6× |
| float32, one filter at 200 states | 0.0577 s, numpy |
0.115 s | M6, 2.0× |
So in float64 the card never caught the M6 on either line, and in float32 it did only on the batch line, between 100 and 1,000 filters. The card pays about 0.13 ms a step whatever the size, against about 1.4 µs for one filter on the M6. Cold, its first answer takes at least 1.2 s.
What's expected off the two lines: a step's work grows as filters × states³. Once that work, not the card's fixed cost per step, sets the card's time, the comparison becomes throughput against throughput. In float32 that favours the card, since Turing runs float32 at about 16 TFLOPS. In float64 it may not, since Turing runs float64 at 1/32 of that rate, about 0.5 TFLOPS, which is the range of the M6's CPU. Whether the float64 crossover exists at all on this card is part of the question.
The plan
1. A harness change first, by PR. P7 gains three batch sweeps at more states. Each runs 1, 10, 100, 300, 1,000, 3,000 and 10,000 filters, with --quick at 10. The 300 and 3,000 are there because the float32 crossover at 10 states already falls between 100 and 1,000, and sizes 10× apart leave each crossover a 10× span.
| Sweep | States | Filters |
|---|---|---|
batch (as now) |
10 | 1 to 10,000, by decades |
batch20 |
20 | 1 to 10,000, with 300 and 3,000 |
batch50 |
50 | 1 to 10,000, with 300 and 3,000 |
batch100 |
100 | 1 to 10,000, with 300 and 3,000 |
state (as now) |
2 to 200 | 1 |
- The new sweeps run only when named in
--sweeps, so a default run of the suite stays Phase 1's.summarise.pyalready handles any sweep name. kalman.pytakes the states from the sweep, throughspec.KALMAN_BATCH_STATES. The model is otherwise unchanged: A's off-diagonal draws are already scaled by 1/√K, and each filter has its own A, as now.spec.py's memory estimate becomes 20 × filters × states² × the item size. The largest cell, 10,000 filters at 100 states in float64, comes to 14.9 GiB. That's under the 0.8 limit on both the M6 (32 GB) and the TITAN (24 GB), so nothing is skipped for memory.- States stop at 100. At 200 states, 10,000 filters would need about 60 GiB by the same estimate, and hours on the CPU.
2. The M6 half, on qe-mini1. Three invocations of problems/run_suite.py, each with --problems kalman --label kalman-grid, from a runs checkout at the harness PR's merge commit:
| Part | Sweeps | Filters | Stacks | Cell limit |
|---|---|---|---|---|
| a | batch20, batch50, batch100 |
1 to 300 | numpy, numba, numba-parallel, jax-cpu |
1,800 s |
| b | batch20, batch50, batch100 |
1,000 to 10,000 | numpy, numba-parallel, jax-cpu |
1,800 s |
| c | batch, state |
their usual sizes | all four | 900 s, as before |
- Both precisions. The harness's defaults stay otherwise: five warm runs or 60 s.
- Serial Numba is left out from 1,000 filters.
numba-parallelruns the same code faster there, so serial never wins. - The 1,800 s limit: by the estimate below, NumPy's and JAX's cells at 10,000 filters and 100 states take about 7 and 17 minutes with their cold run.
- Part c is a same-day baseline: the last M6 rows are from macOS 27.0.1, and the Mac now runs 27.2.1 (26B131).
- JAX's float32 stays at XLA's defaults. On the Mac it pays about 1 µs a small float32 product (QuantEcon/project-benchmarks-jax#4), but it was the M6's fastest P7 stack in only 3 of the 24 cells on 2026-11-02. The finding will note it.
- Window: a quiet window agreed with the sessions on
qe-mini1, which stay running, with the console logged in.--quickfirst, as a check. - Expected time, an estimate: about 2 hours.
- The test run: the harness PR's
--quickrun, at 10 filters, cost these per filter and step at 100 states in float64:numpy21 µs,numba26 µs,jax-cpu51 µs, andnumba-parallel9.8 µs with 10 filters on 12 cores. - Scaled to 10,000 filters: taken linearly,
jax-cpuwould take about 8.5 minutes a run andnumpyabout 3.5. Parallel batching may do better than linear. - The rest: most of the remaining time is the 3,000-filter cells and the 60 s floor on every cell from 300 filters up.
- The test run: the harness PR's
3. The TITAN half, on qe-wharton1-gpu.
- What runs:
jax-gpuonly, on the card at0b:00.0, both precisions, the same five sweeps, under econ-on-ai-hardware's lock. - Environment: the runs checkout's own venv, as on 2026-11-02.
- Why
jax-gpuonly: the Threadripper's fastest CPU stack is 4 to 21 times slower than the M6's on P7, so it doesn't bear on the crossover. - Expected time: about 15 minutes. The card's driver is now 595.99.02, newer than on 2026-11-02, so
batchandstaterun again here too.
4. Not now: the M5 Pro, which ran P7's batch of 10,000 filters 1.45× as fast as the M6, and would move the crossover up. Rented cards too, through run_by_hand.sh --sweeps. The RTX PRO 6000 and the H100 pay about 0.07 ms to 0.11 ms a step, and run float64 far faster than Turing.
What comes out
- For each precision, a map of who wins at each pair of filters and states, warm and cold, with the margin.
- A rule of thumb, if one fits: the card wins once filters × states³ passes some figure, in float32. In float64, either the same with a larger figure, or "not on a Turing card".
- The time a step costs on each device and stack, as filters × states³ grows, to show where each device's fixed cost per step gives way to its throughput.
Done when
- The harness PR is merged: Problems: P7 batch sweeps at 20, 50 and 100 states, run only when named #60 (
0222630). - The M6's rows and the TITAN RTX's rows are merged here, with their run notes: 2026-11-10: P7's Kalman filters by filters and states, on the M6, the M5 Pro and the TITAN RTX #61 (
4bf6f72), with the M5 Pro's, and the rented cards' in 2026-11-10: P7's Kalman filters by filters and states, on an H100 and an RTX PRO 6000 #63 (18199ee). - A finding in QuantEcon/project-benchmarks-jax gives the map and the rule of thumb, and the tracker, QuantEcon/project-benchmarks-jax#1, links it:
findings/2026-11-10-kalman-filters-cpu-against-a-gpu.md(24b5555), summarised below.
Activity
Problems: P7 batch sweeps at 20, 50 and 100 states, run only when nam…
2026-11-10: the same Kalman set on qe-wharton2's M5 Pro
2026-11-10: P7's Kalman filters by filters and states, on the M6, the…
run_by_hand: run part of the suite, through PROBLEMS, SWEEPS, TIMEOUT…
2026-11-10: P7's Kalman filters by filters and states, on an H100 and…
mmcky commentedon Nov 11, 2026
Done: the map and a rule of thumb. The finding is in QuantEcon/project-benchmarks-jax (
findings/2026-11-10-kalman-filters-cpu-against-a-gpu.md, merged as24b5555). Beyond the plan, at Matt's request, the M5 Pro and two rented cards ran too. The rows are #61's (4bf6f72: the M6, the M5 Pro and the TITAN RTX) and #63's (18199ee: an H100 and an RTX PRO 6000), run with #60's sweeps (0222630) and, on the rented cards, #62's variables (314b061). Every cell ran (246 on each Mac, 66 on each card), and every answer agreed with NumPy's in float64.Warm, against the M6 / the M5 Pro, at 10, 20, 50 and 100 states (a dash: never):
Cold, from a fresh process to the first answer, the crossovers move 3× to 10× higher: 10,000, 3,000, 1,000 and 300 filters on the TITAN in float32 and the H100 in both precisions. The RTX PRO 6000's compiles, up to 17 s a fresh process, push its float64 crossovers to 3,000 or 10,000 filters, or past the sizes measured.
The margin at 10,000 filters (the M6's time over the card's, at 10 to 100 states):
One filter stays on the CPU, from 2 to 200 states, except at 200 states, where the H100 is 1.27× the M6 in float64 and the RTX PRO 6000 is level with the Macs in both precisions (0.93× to 1.09×).
The Done-when: