Skip to content

Commit 3198bed

Browse files
jstacclaude
andcommitted
Add @jax.jit decorators to VFI and OPI functions
- Improves performance by JIT compiling the main iteration routines - Speedup now consistently 2.5-2.6x (vs 2.4-2.5x before) - Absolute times also improved (OPI: ~0.3-0.4s vs ~0.4-0.5s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d08c096 commit 3198bed

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lectures/ifp_opi.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def iterate_policy_operator(σ, v, m, model):
222222
For comparison, here's VFI from {doc}`ifp_discrete`:
223223

224224
```{code-cell} ipython3
225+
@jax.jit
225226
def value_function_iteration(model, tol=1e-5, max_iter=10_000):
226227
"""
227228
Implements VFI using successive approximation.
@@ -252,6 +253,7 @@ The algorithm alternates between
252253
2. Computing a new greedy policy based on the updated value function
253254

254255
```{code-cell} ipython3
256+
@jax.jit
255257
def optimistic_policy_iteration(model, m=10, tol=1e-5, max_iter=10_000):
256258
"""
257259
Implements optimistic policy iteration with step size m.

0 commit comments

Comments
 (0)