-
-
Notifications
You must be signed in to change notification settings - Fork 132
PolicyEngine-UK compatibility: Loosen SS tolerances and add Numba optimizations #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
PolicyEngine-UK compatibility: Loosen SS tolerances and add Numba optimizations #1082
Conversation
- Loosen mindist_SS from 1e-9 to 1e-3 for faster GE loop convergence - Loosen RC_SS from 1e-8 to 1e-4 for resource constraint check - Add optional Numba JIT compilation for hot paths: - household.py: marg_ut_cons, marg_ut_labor - tax.py: ETR_wealth, MTR_wealth - txfunc.py: DEP tax rate calculations - Numba is optional - falls back to NumPy if not installed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
These are parameter changes right? Why do we need to change the defaults, we can just change them in og-uk no? |
I started working on Numba JIT optimizations for hot-path functions (compiling Python loops to fast machine code). Still, after benchmarking, most of the speedup is actually coming from the changes to the tolerance parameters (mindist_SS, RC_SS). I can move those parameter changes to OG-UK via p.update_specifications() instead of changing OG-Core defaults. |
| "value": [ | ||
| { | ||
| "value": 1e-09 | ||
| "value": 1e-03 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vahid-ahmadi I echo @nikhilwoodruff, let's not change the default values in OG-Core. These parameters can be adjusted for particular runs (e.g., you can set a looser tolerance if you want a quicker solution).
| "range": { | ||
| "min": 1e-13, | ||
| "max": 0.001 | ||
| "max": 0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This max value seems too high to allow. For example, module units for labor supply are typically less than 0.5. So this would mean an error of 20% or more is ok. I think that's too much for any simulation.
|
@vahid-ahmadi Thanks for thinking about improvements to the solution of OG-Core. Can you report some diffs of the Numba changes only (i.e., keep the default tolerances and run with only the numba changes). What is the speed up? These are pretty small loops (and sometimes vectorized operations) so I'm skeptical there would be much improvement. |
Performance Optimizations for Steady State Solver
Summary
Changes
1. Solver Tolerance Adjustments (
default_parameters.json)mindist_SS1e-91e-3RC_SS1e-81e-4Benchmark results:
2. Optional Numba JIT Compilation
Added Numba-optimized versions of hot-path functions:
household.py:marg_ut_cons,marg_ut_labortax.py:ETR_wealth,MTR_wealthtxfunc.py: DEP tax rate calculationsFeatures:
@njit(cache=True)for compilation cachingprangewhere applicableTest Plan
🤖 Generated with Claude Code