Repository navigation
Open
Description
Overview
Build a comprehensive benchmarks suite for computational libraries commonly used in QuantEcon projects to help define optimal workflow and program structure guidelines.
Motivation
Different computational backends (Numba, Dask, JAX CPU, JAX GPU) have different performance characteristics and overheads:
- JAX GPU has kernel launch overheads, making it only worthwhile for problems above a certain size
- Numba has JIT compilation overhead on first call
- Dask has scheduling overhead that may not pay off for small datasets
- JAX CPU vs GPU crossover points vary by operation type
Currently, guidance on when to use each backend is based on rules of thumb. A systematic benchmarking suite would provide data-driven recommendations.
Proposed Features
1. Benchmark Categories
- Array operations: matrix multiplication, element-wise ops, reductions
- Numerical algorithms: linear solvers, optimization, root finding
- Monte Carlo simulations: varying sample sizes
- Dynamic programming: value function iteration, policy iteration
- Common QuantEcon patterns: Markov chains, asset pricing, etc.
2. Problem Size Scaling
For each benchmark, test across problem sizes to identify:
- Minimum problem size where GPU becomes beneficial
- Crossover points between backends
- Memory bandwidth vs compute bound regimes
3. Automated Results Updates
- CI workflow that runs benchmarks on schedule (weekly/monthly)
- Triggered on new releases of key libraries (JAX, Numba, etc.)
- Results published to a dashboard or static site
- Historical tracking to show performance changes over versions
4. Guidelines Generation
- Automatically generate recommendations based on benchmark results
- "Use JAX GPU when matrix size > N" type guidance
- Integration with lecture documentation
Example Output
Matrix Multiplication Crossover Points (JAX 0.4.x, CUDA 12.x, A100)
-------------------------------------------------------------------
Size < 500x500: CPU faster (GPU overhead dominates)
Size 500-2000: Similar performance
Size > 2000x2000: GPU 10-100x faster
Recommendation: Use JAX GPU for matrices larger than 1000x1000
Technical Approach
- Use
pytest-benchmarkor similar for consistent measurement - Run on standardized hardware (GitHub Actions runners, cloud GPU instances)
- Store results in structured format (JSON/Parquet)
- Generate reports and visualizations automatically
Related
- QuantEcon lectures on JAX: https://jax.quantecon.org
- Numba lectures: https://python-programming.quantecon.org
- Google JAX benchmarks: https://github.com/google/jax/tree/main/benchmarks
Questions to Explore
- What hardware configurations should we benchmark on?
- Should this be a standalone repo or part of an existing project?
- How to handle GPU availability in CI (cost considerations)?
- What's the update frequency that balances freshness vs compute cost?
Metadata
Metadata
Assignees
Labels
No labels
Activity
mmcky commentedon Oct 24, 2026
Workstream A's first experiment is scoped as QuantEcon/benchmarks#1: float64 against float32 on CPU, CUDA and Apple Silicon, split by kernel type (compute-, memory- and launch-bound). Its problem-size sweeps also give this issue's CPU/GPU crossover curves. It extends
hardware/benchmark_hardware.pyrather than replacing it, and keeps the programme's as-used method: a fresh process per measurement, with compile time counted.It runs first on
qe-wharton1-gpu, which takes up the hardware offer on #335. Phase 0 needs none of that machine's time: the harness is built and calibrated on Apple Silicon and the RunsOn T4 while the machine is brought back online.mmcky commentedon Nov 3, 2026
Workstream A's first crossovers by problem type (2026-11-03). QuantEcon/benchmarks#5's Phase 1 has run four of its eight problem types. Each is written in NumPy, Numba and JAX and timed as used: a fresh process per cell, compile included, cold and warm times kept apart, and every answer checked against NumPy's. It ran on an Apple M6 (
qe-mini1) and onqe-wharton1-gpu's Threadripper 2990WX and TITAN RTX. The tables are in QuantEcon/benchmarks'problems/README.md(QuantEcon/benchmarks#25, QuantEcon/benchmarks#26, QuantEcon/benchmarks#28).Where the TITAN RTX overtakes the M6's fastest stack, in float64. "From N" means at N and at every larger size measured.
How this fits with the earlier results:
Still to come: