Rewrite the Mahler & Yum example in modern pylcm style#363
Open
hmgaudecker wants to merge 8 commits into
Open
Conversation
Derive the example from the standalone Replication_MY2024 project: an in-DAG model (health-transition logit and income computed inside the DAG, not precomputed grids), public `lcm` API only, labeled pandas grids, and a `create_inputs` that returns a DataFrame of initial conditions. Collapse the package into `__init__.py`. Carry the replication's behavioral-moment tests as tests/test_mahler_yum_2024.py and drop the opaque pickle regression; update the benchmark, the example docs, and generate_benchmark_data.py to the new create_inputs signature. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Mahler & Yum solve is GPU-scale and float32-unstable (XLA's float32 fused kernels accumulate ~1e-3 errors across the large state space). Mark the example tests GPU-only and pin the behavioral moments to their float64 values. Regenerate pixi.lock onto current jax/numpy/pandas. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
Benchmark comparison (main → HEAD)Comparing
|
…r-yum-from-replication
Documentation build overview
34 files changed ·
|
…r-yum-from-replication
The behavioral-moment bands (`abs(count - expected) <= 5`,
`atol=0.01` on means, `atol=0.005` on fractions) are calibrated to
the paper's 64-bit replication. Under 32-bit precision the
simulation drifts past every band — counts off by 16, 30, 45 against
±5 bands; mean wealth off by enough to miss `atol=0.01`. Skip the
module at 32-bit so the GPU 32-bit-precision job is not blocked by
drift in a test whose role is paper replication, which has a single
canonical precision.
The dtype-correctness side of 32-bit is covered by the per-precision
regression pickles in `tests/data/regression_tests/{f32,f64}/` for
the mortality and precautionary-savings models.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…r-yum-from-replication
…r-yum-from-replication
…r-yum-from-replication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the precomputed-grid
lcm_examples/mahler_yum_2024/_model.pywith anin-DAG model:
inside the regime DAG, not precomputed into grids. Removes the import-time
tr2yp_gridtensor and thefrom _lcm.utils.dispatchers import productmapprivate-API import.
lcmAPI only, real@categoricalfor the 40-levelEffort,labeled
pd.Seriesgrids,fixed_params/START_PARAMSsplit, and acreate_inputsthat returns a(model_params, initial_conditions_DataFrame)pair. Dead
ProductivityShockcategorical dropped.__init__.py(the_model.pyindirection is gone).tests/test_mahler_yum_2024.py;the opaque pickle regression (
test_regression_mahler_yum) and its fixturesare dropped. Benchmark, docs, and
generate_benchmark_data.pyupdatedto the new
create_inputssignature.Notes for review
utility_constant = 11.0fromthe other repo's
START_PARAMS. The previous standalone example used13.108(which looks like a paper estimate).are GPU-only and run at float64.
Test plan
test_mahler_yum_2024.py— 29 passed on GPU at float64ty,prekclean🤖 Generated with Claude Code