Float32 fidelity: which float64 lectures need float64, and can the heaviest step drop to float32?
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 0
- 派生
- 1
- 平均合并
- 3 小时 29 分钟
- 30 天内合并 PR
- 64
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
QuantEcon/benchmarks 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
QuantEcon/benchmarks#78 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
QuantEcon/benchmarks#72 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 45/100
QuantEcon/benchmarks#47 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
QuantEcon/benchmarks#27 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 32/100
QuantEcon/benchmarks#5 · 2 条评论 ·
维护者通常 1 天内回复
查看 QuantEcon/benchmarks 的全部 Issue
相似的 Issue
-
needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
flashinfer-ai/flashinfer#9803 ·
维护者通常 1 天内回复
-
bug frontend good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
难度 2/5 1-3 小时 新手友好度 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
难度 1/5 1 小时以内 新手友好度 89/100
cuadrao-ai/argus#2328 ·
维护者通常 1 天内回复
-
bug frontend good first issue help wanted
难度 2/5 1-3 小时 新手友好度 88/100
nikhilb2/simple_invoicing#907 ·