Skip to content

Problems: say that np.linalg computes in float64, and which problems use SciPy (#73) - #76

Merged
mmcky merged 2 commits into
mainfrom
2026-11-20-numpy-float32-solves
Nov 20, 2026
Merged

mmcky merged 2 commits into
mainfrom
2026-11-20-numpy-float32-solves

Conversation

@mmcky

@mmcky mmcky commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

For #73. np.linalg computes in float64 even for float32 arrays, then rounds its answer back to float32, so P7's NumPy float32 cells have been float32 products with float64 solves and log-determinants. This PR keeps P7's code as it is and says what those cells measure. It also says which problems use SciPy instead. Matt chose this over switching P7 to SciPy and re-running, on 2026-11-20.

Why P7 keeps np.linalg

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:

Solve np.linalg.solve scipy.linalg.solve, float32
One 10-state system 2.2 µs 5.6 µs
A batch of 10,000 6.6 ms 9.0 ms

So a careful NumPy author writing P7 would keep np.linalg. NumPy's float32 P7 rows on main, the 138 listed on #73, stand as what NumPy gives in float32, and none is re-run. P5's dense sweep is the opposite case: one large solve, where SciPy's float32 solve took 0.073 s for 4,000 states against NumPy's 0.137 s, which is why #71 made it use scipy.linalg.solve.

What changes

  • problems/README.md:
    • The numpy backend's row now says NumPy's column uses SciPy where SciPy has the faster tool.
    • A new note under the Backends table says that np.linalg computes in float64, which problems use which library and why, with the figures above, and that SciPy's BLAS may be a separate build from NumPy's. That last point is the one the organiser's reviewer raised on Problems: P5, the stationary distribution of a savings policy (#47) #71.
  • problems/kalman.py: a comment on the NumPy version saying its float32 solves are float64, and why it keeps np.linalg.

No results and no code paths change. A correction to the Kalman finding's sentence that names NumPy as the M6's fastest float32 stack at 100 states goes to QuantEcon/project-benchmarks-jax separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMZbJB4j8pmPEYyJ8SG

mmcky and others added 2 commits November 20, 2026 22:32
…use SciPy (#73)

np.linalg computes in float64 even for float32 arrays, so NumPy's float32
P7 cells have been float32 products with float64 solves. For P7's small
matrices np.linalg still costs less per call than SciPy's float32 solve,
so P7 keeps it, and the published rows stand as what NumPy gives in
float32; this records what they measure. P5's dense sweep, one large
solve, uses SciPy's float32 LU, which is faster there. The README's
NumPy row and a new note say so, and kalman.py's NumPy version says so in
a comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZbJB4j8pmPEYyJ8SG
@mmcky
mmcky merged commit 1d41462 into main Nov 20, 2026
@mmcky
mmcky deleted the 2026-11-20-numpy-float32-solves branch November 20, 2026 11:40
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.

1 participant