You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
P7's NumPy float32 cells compute their solves in float64 #73
problems/kalman.py's NumPy version calls np.linalg.solve twice (lines 56 and 58) and np.linalg.slogdet once (line 59) at each step. NumPy's linear algebra computes in float64 even for float32 arrays. Its _commonType returns double as the computation type, and the answer is rounded back to float32, so the cell's dtype check can't see it. In a float32 cell, P7's NumPy products are float32 but its solves and log-determinants are float64.
The independent review of #71 found the same call in P5, where NumPy's float32 dense cells turned out to be float64 arithmetic. #71 changed P5 to scipy.linalg.solve, which calls LAPACK's float32 routine. Numba's and JAX's P7 versions are unaffected: both reach LAPACK's float32 routines.
Runs that carry it: every NumPy float32 P7 row, statusok, on main:
File
Rows
Label
problems/results/qe-mini1/2026-11-02.jsonl
12
none
problems/results/qe-wharton1-gpu/2026-11-02.jsonl
12
none
problems/results/qe-wharton2/2026-11-06.jsonl
12
none
problems/results/aws-c7i.8xlarge/2026-11-09.jsonl
12
none
problems/results/aws-c8a.4xlarge/2026-11-09.jsonl
12
none
problems/results/aws-c8i.8xlarge/2026-11-09.jsonl
12
none
problems/results/qe-mini1/2026-11-10.jsonl
33
kalman-grid
problems/results/qe-wharton2/2026-11-10.jsonl
33
kalman-grid
Those rows' times and answers are for float32 products with float64 solves, not for NumPy in float32. Where a summary names NumPy as the fastest float32 stack for P7, the figure comes from such a row.
To decide: how NumPy's version should solve in float32 (scipy.linalg.solve handles the batch of filters, and the log-determinant can come from the same LU), and whether to re-run NumPy's float32 P7 cells on the machines above or to mark these rows instead.
Decided on 2026-11-20 (Matt): describe these rows correctly rather than re-run them. For P7's small matrices, NumPy's own solver costs less per call than SciPy's float32 one, even with float64 inside. On qe-mini1's M6, one 10-state solve took 2.2 µs with np.linalg.solve against 5.6 µs with scipy.linalg.solve in float32, and a batch of 10,000 took 6.6 ms against 9.0 ms. So a careful NumPy author would keep np.linalg, and the 138 rows above are correct timings of what NumPy gives in float32. What they measure is float32 products with float64 solves and log-determinants, and their answers are more accurate than true float32's.
#76 records this in problems/README.md and in a comment in kalman.py, and changes no results. It also says that P5's dense sweep, one large solve, uses SciPy's float32 solve because that's the faster there.
Done as decided above. #76, merged as 1d41462, records in problems/README.md and kalman.py that NumPy's float32 P7 cells solve in float64, and which problems use SciPy instead. QuantEcon/project-benchmarks-jax#67, merged as 5db7cdf, adds a dated note to the Kalman finding. No results changed.
Activity
Problems README: P5's solve timing, measured on the solve alone (#73)
mmcky commentedon Nov 20, 2026
Decided on 2026-11-20 (Matt): describe these rows correctly rather than re-run them. For P7's small matrices, NumPy's own solver costs less per call than SciPy's float32 one, even with float64 inside. On qe-mini1's M6, one 10-state solve took 2.2 µs with
np.linalg.solveagainst 5.6 µs withscipy.linalg.solvein float32, and a batch of 10,000 took 6.6 ms against 9.0 ms. So a careful NumPy author would keepnp.linalg, and the 138 rows above are correct timings of what NumPy gives in float32. What they measure is float32 products with float64 solves and log-determinants, and their answers are more accurate than true float32's.#76 records this in
problems/README.mdand in a comment inkalman.py, and changes no results. It also says that P5's dense sweep, one large solve, uses SciPy's float32 solve because that's the faster there.Problems: say that np.linalg computes in float64, and which problems …
mmcky commentedon Nov 20, 2026
Done as decided above. #76, merged as
1d41462, records inproblems/README.mdandkalman.pythat NumPy's float32 P7 cells solve in float64, and which problems use SciPy instead. QuantEcon/project-benchmarks-jax#67, merged as5db7cdf, adds a dated note to the Kalman finding. No results changed.