Repository navigation
Choose transition rules for supplied AR1 nodes - #626
hmgaudecker wants to merge 41 commits into
Conversation
Documentation build overview
38 files changed ·
|
…tion' into codex/on-nodes-transition-rules # Conflicts: # tests/candidate_certificate/sources.json # tests/ci/ci-workloads.json
mj023
left a comment
There was a problem hiding this comment.
Again, no big errors that would have any impact on model execution etc. But I found some minor things that should be fixed and some cleanups that could be done before merging.
1. DensityDerivativeAccuracyError docstring promises a guard that doesn't run (src/lcm/exceptions.py:225)
The docstring says an out-of-budget derivative is rejected and that "under JIT the runtime callback reports this error". Routine AD never runs the certificate. For the row your own rejection test uses (family="central", rho), _certify_density_derivative_row raises, but jax.jit(jax.jacfwd(...)) returns 0 for the middle component instead of the reference -1.85e239, without any error. The case is extreme, but a public docstring shouldn't promise error control that doesn't exist. Could it be reworded to match the user guide, so it says the error comes only from the explicit developer certificate?
2. Test-only certificate is shipped and imported with the library (src/_lcm/processes/ar1.py:35)
density_derivative_admission.py (about 630 lines) is loaded on every import lcm, but only the private _certify_density_derivative_row oracle uses it. Since it doesn't run in solve, simulate or AD, could it live under tests/ next to test_density_derivative_accuracy.py, or at least be imported lazily inside the certify function? Then the public exception could move with it.
3. Unrelated CI change (.github/workflows/benchmark-pr.yml)
cancel-in-progress: false means a new push no longer cancels a running GPU benchmark for an outdated commit. That isn't mentioned in the description and seems unrelated to on_nodes. Was it intentional?
Cleanup
_checked_density_coefficientsstill carries theio_callbackexemption and docstring, but nothing registers it as a callback; calling_certify_density_coefficientsdirectly would remove the wrapper.- The user guide tells readers to call the private
_lcm.processes.ar1._certify_density_derivative_row; that part could go in developer docs or just point at the test file. _get_conditioned_weights_funcreadsfixed["rho"]in the new branch, thoughrho_fixedis already bound a few lines above.- The "Unknown on_nodes transition_rule" check can't fire, because beartype rejects a wrong
Literalfirst, and a singleTransitionRulealias would replace the four copies of thatLiteral.
…nodes transition rules
…t certificate Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LAZ63AjbZFLweWuJyPUs6S
The certificate runs only when a test hands it a row; solve, simulation and routine differentiation never call it. It and DensityDerivativeAccuracyError now live in tests/test_models/density_derivative_admission.py beside the other oracles, so importing lcm no longer loads it. The io_callback adapter is gone: the row entry point converts its operands and calls the keyword-only checker directly. Docs point at the test file instead of private _lcm entry points. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LAZ63AjbZFLweWuJyPUs6S
The Literal appeared on the factory, the dataclass field and the quadrature helper; all three now use one alias. The membership check in the helper could not fire, since beartype on the factory refuses an unknown rule first; a test pins that refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LAZ63AjbZFLweWuJyPUs6S
…tion' into codex/on-nodes-transition-rules # Conflicts: # tests/candidate_certificate/sources.json
This reverts commit 1b42a02.
|
Thanks, all addressed:
Cleanups:
|
…es-transition-rules # Conflicts: # src/_lcm/processes/ar1.py # tests/candidate_certificate/direct_flow.py # tests/candidate_certificate/sources.json
A process value beyond its outer nodes now follows a declared `off_grid` rule: extrapolate along the edge segment (default, unchanged numbers), read the edge node's row/continuation/policy (`clip_lookup`), additionally clip the simulated state (`clip_state`), or refuse it (`raise`). A node draw keeps sampling the edge row under every rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
The on-nodes process compared every field except the retired keyword name, so two declarations differing only in their draw mode read as distinct laws. Use the current field name, update the density tests and the user guide to the renamed keyword, and register the density test file with the CI workloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
# Conflicts: # tests/candidate_certificate/direct_flow.py # tests/candidate_certificate/sources.json # tests/ci/ci-workloads.json
…ests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## codex/553-declared-target-validation #626 +/- ##
========================================================================
+ Coverage 94.00% 94.06% +0.06%
========================================================================
Files 658 660 +2
Lines 108613 109752 +1139
========================================================================
+ Hits 102103 103240 +1137
- Misses 6510 6512 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
…20261103 # Conflicts: # tests/candidate_certificate/direct_flow.py # tests/candidate_certificate/sources.json # tests/ci/ci-workloads.json
Benchmark comparison (main → HEAD)Comparing
|
Models using supplied AR(1) state nodes can choose how transition probabilities are computed through
TauchenAR1Process.on_nodes:Quadrature accepts a Gauss–Hermite node count or explicit standardized nodes and weights. Targets outside the state grid are clipped to its endpoints. Parameters and innovation scales can vary at runtime or with the current state.
Node-based simulation uses the selected transition matrix. Continuous simulation keeps its conditional normal draws.
The implementation also stabilizes density calculations and quadrature allocation over extreme numerical ranges. Targeted CPU and A100 tests cover transition probabilities, derivatives, Bellman expectations and simulation.
Density-rule derivatives use normalized scaled arithmetic. The stronger finite-row accuracy certificate is retained in private
_lcmas a deliberately invoked developer/test oracle. It is documented with its input scope and success-or-rejection guarantee; it does not run during routine differentiation, solving or simulation at eitherruntime_checkssetting. Routine derivatives do not carry that certificate's componentwise accuracy guarantee. The usual probability and finiteness checks remain controlled byruntime_checks.Density stabilization adds compilation and memory cost in the measured small-model workload; this is not a performance estimate for every model.
Stacked on #625. Closes #586.
Validation: CPU CI · GPU CI.