Float32 fidelity: which float64 lectures need float64, and can the heaviest step drop to float32?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- machine-learning, performance
Direzione di ricerca
Start with lectures/run_lecture.py and the lecture implementations listed in the issue; compare each lecture's recorded answers and convergence behavior under --dtype float32 and --dtype float64. Then examine aiyagari_jax's get_greedy for the mixed-precision variant, measuring policy changes, runtime, and equilibrium capital across the stated grids and devices. Done means producing the per-lecture and mixed-precision result tables, saving results under lectures/results/<host>/<date>/, and recording findings in the benchmarks repository.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Run the 13 float64 lectures in lecture-jax in float32 and record whether each still reaches its answer, then try a mixed-precision version of aiyagari_jax's greedy step. The aim is to know where QuantEcon's JAX code needs float64, and where it is a precaution.
Why
- The lectures don't say what float64 protects. 13 of the 29 lectures in
lecture-jaxturn it on, each with the same sentence, "to increase the precision". None says what goes wrong without it. - #3 found that float32 fails
aiyagari_jaxin two ways, and neither is a slightly worse answer.- Two of its 50 solves stall at an error of about 2.5e-4, against the lecture's tolerance of 1e-4, and run to the 10,000-iteration cap. That makes the lecture about 12× slower as used.
- On the TITAN RTX at a 5,000-point grid, its values went NaN in all three runs, from a
bicgstabbreakdown (QuantEcon/project-benchmarks-jax#5). The loop's testerror > tolis false for NaN, so it stopped after two iterations with a policy wrong almost everywhere, and raised no error. Both CPUs stayed finite. - When float32 did converge, equilibrium capital matched float64 to 2e-5.
ifp_egm_jaxconverges in float32, to within 1.6e-4 of the float64 policy.- So float32 fails by not finishing, or by failing silently, and the failure can depend on the device. Two lectures don't say which of the other eleven share that.
- #4 runs these lectures in float32 for time. This issue asks whether the answer survives.
- The step that float64 makes expensive may not need it. In dense discrete choice the costly step recomputes rewards and takes the maximum over choices: 26.8× slower in float64 than in float32 on the TITAN RTX (#6). That step only has to pick the best choice. The value update, the convergence test, policy evaluation and the equilibrium search could stay in float64.
Part 1: the 13 lectures in float32
| Lecture | Solver and tolerance, as written |
|---|---|
aiyagari_jax |
Policy iteration, 1e-4; equilibrium capital by bisection, xtol 1e-4 |
arellano_jax |
Joint iteration on the repay and default value functions, 1e-8 |
hopenhayn |
Value function iteration, 1e-6; the entry price by bisection, 1e-4 |
ifp_egm_jax |
Endogenous grid method, 1e-5 |
inventory_ssd |
Value function iteration, 1e-6 |
jax_intro_jax |
None; it turns float64 on to show the difference |
job_search |
Value function iteration, 1e-4 |
markov_asset_jax |
A linear solve for the price-dividend ratio, after a spectral-radius check |
mle_jax |
Newton–Raphson, 1e-3 and 1e-5 |
newtons_method |
Newton's method, 1e-5; float64 is turned on in exercise 1's solution, for tolerances of 1e-7 and 1e-15 |
opt_invest |
Value function and optimistic policy iteration, 1e-5 |
opt_savings_1 |
Value function iteration, 1e-5 |
opt_savings_2 |
Value function and optimistic policy iteration, 1e-5 |
Also the two float32 lectures that solve to a tolerance, overborrowing (1e-5) and lucas_model_jax (1e-6): whether they meet it, or stop at their iteration cap.
Method:
lectures/run_lecture.pywith--dtype float32and--dtype float64, at thelecture-jaxcommit #4 used. Each of the 13 has exactly onejax_enable_x64line, as--dtype float32requires.--recordeach lecture's answer: the equilibrium values, prices, estimates or policies it reports. Choosing the expressions lecture by lecture is part of the work.- For each solve: whether it met its tolerance or stopped at its cap, and how many iterations it took. Where a solver doesn't return these, read them from its printed output.
- Check every recorded value for NaN and Inf. Don't rely on a loop's exit: a NaN error ends
while error > tolas if it had converged. - One run per configuration, and three where results vary between runs.
Platforms:
| Device | Why |
|---|---|
M6 CPU, qe-mini1, with its agents paused |
Seconds per lecture; the CPU answer |
TITAN RTX, qe-wharton1-gpu, card 0b:00.0 |
The silent NaN appeared only on the GPU |
T4, RunsOn g4dn.2xlarge |
The lectures' CI device, if it is cheap to add to #4's job |
Result: one table, lecture by device, giving whether float32 converges (yes, stops at its cap, NaN, or raises), the largest gap from float64 in the recorded answers, and whether that gap is within the lecture's own tolerance.
Part 2: a mixed-precision greedy step for aiyagari_jax
- The variant: with float64 on,
get_greedycasts to float32, computes rewards and the argmax over next-period assets, and returns the policy. The value function,get_value'sbicgstabsolve, the convergence test and the equilibrium bisection stay in float64. - Then one float64 greedy step at the converged solution, counting the policy points that change. That catches choices decided by a near-tie.
- At the grids #3 used, 200 to 10,000 asset points, on the TITAN RTX and the M6.
- Record: time per policy-iteration loop, against pure float64 and pure float32; the policy points that differ from float64, and by how many grid steps; the gap in equilibrium capital; iterations to converge.
- If it is ready in time, add it to #1's Phase 2 runs. A Blackwell workstation card does float64 at 1:64 of float32, so that is where the float32 step would matter most.
What the results would change
| If | Then |
|---|---|
| A float64 lecture reaches its answer in float32, within its tolerance, on every device | Float64 is a precaution there. The lecture can say so, or say what it guards against |
| A lecture stalls, goes NaN, or moves its answer past its tolerance in float32 | It needs float64 as written, and the lecture can say why |
| The mixed step gives float64's answer at a fraction of float64's cost | Research-scale discrete-choice models can run their heavy step at a card's float32 rate. That changes which card suits them, which project-compute weighs |
| It doesn't | Dense discrete choice needs float64 throughout, and a card's float64 rate decides |
Deliverables
- the results, under
lectures/results/<host>/<date>/as #4's are; - the per-lecture table, and Part 2's table of time and gaps;
- a finding in QuantEcon/project-benchmarks-jax's
findings/, with its hardware consequence going to project-compute.
Related
- #1, the precision experiment, with #3 and #6, which measured
aiyagari_jax's float32 failures and float64's cost by kernel type - #4, the whole-lecture run, which times these lectures in float32
- QuantEcon/project-benchmarks-jax#5, the
bicgstabbreakdown
🤖 Generated with Claude Code
- Lingua principale
- Python
- Stelle
- 0
- Fork
- 1
- Merge medio
- 3h 29m
- PR unite (30g)
- 64
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di QuantEcon/benchmarks
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
QuantEcon/benchmarks#78 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
QuantEcon/benchmarks#72 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
P5: Markov chains, starting with the stationary distribution of a savings policy (aiyagari_jax)Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
QuantEcon/benchmarks#47 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
QuantEcon/benchmarks#27 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 32/100
QuantEcon/benchmarks#5 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di QuantEcon/benchmarks
Issue simili
-
needs-triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
flashinfer-ai/flashinfer#9803 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
cuadrao-ai/argus#2328 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
nikhilb2/simple_invoicing#907 ·