Repository navigation
Conversation
- Add JAX imports and GPU acceleration warning - Convert @jitclass WealthDynamics to NamedTuple + factory pattern - Replace @jit functions with pure JAX functions using jax.lax.scan - Implement explicit JAX random key management - Update all application code and exercises to use JAX implementation - Follow QuantEcon JAX style guide rules for functional programming
- Replace jnp.arange(n-1) with length=n-1 in jax.lax.scan calls - Add static_argnums=(2,) to wealth_time_series jit compilation - Use None as xs input since scan functions don't need iteration values Fixes ConcretizationTypeError when JAX tries to compile functions with dynamic array sizes in scan operations.
🔧 Bug Fix: JAX Concretization ErrorsFixed execution errors that occurred during testing of the JAX conversion. Issue Encountered:The code was throwing ConcretizationTypeError when executing the wealth_time_series function due to JAX compilation issues with dynamic array sizes. Root Cause:JAX jax.lax.scan was receiving jnp.arange with dynamic size as the xs parameter. When JAX tried to JIT compile the function, it could not determine the concrete array size at compile time. Solutions Applied:✅ Fixed wealth_time_series function:
✅ Fixed update_cross_section function:
Technical Details:
Result:✅ All JAX functions now execute without concretization errors |
|
📖 Netlify Preview Ready! Preview URL: https://pr-639--sunny-cactus-210e3e.netlify.app (ef9b075) 📚 Changed Lecture Pages: wealth_dynamics |
Summary
This PR performs a comprehensive review and update of the wealth_dynamics lecture for QuantEcon style guide compliance and converts the implementation from Numba to JAX.
Style Guide Compliance Review
Systematically reviewed and corrected all QuantEcon style guide violations:
✅ Critical Issues Fixed:
✅ Mandatory Issues Fixed:
✅ Best Practice Improvements:
%%timemagic commands withqe.Timer()context managerJAX Conversion
Converted the lecture from Numba to JAX following QuantEcon style guide rules:
JAX Conversion (following style guide rules):
Code Improvements:
Benefits:
Testing:
All existing functionality preserved - the lecture should run identically but with potential for significant performance improvements on GPU hardware and full style guide compliance.