Skip to content

Keep scaled continuation means finite near float max - #628

Open
hmgaudecker wants to merge 29 commits into
codex/on-nodes-transition-rulesfrom
codex/514-continuation-overflow
Open

hmgaudecker wants to merge 29 commits into
codex/on-nodes-transition-rulesfrom
codex/514-continuation-overflow

Conversation

@hmgaudecker

@hmgaudecker hmgaudecker commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Scaled continuation expectations can overflow before normalization when values are near the floating-point limit. Small coefficients and small values can also underflow before their finite normalized mean is formed. This change normalizes coefficient mantissas and tracks binary scales so these intermediate operations preserve the represented contributions.

The derivative rule forms normalized finite slopes and transports the centered residual separately. This preserves finite coefficient derivatives when the rounded mean equals a neighboring value, while retaining zero-weight and nonfinite-input conventions. The implementation uses existing JAX binary scaling; it adds no runtime accuracy certificate or exact-arithmetic fallback.

Validation covers float32 and float64 eager, JIT, mapped, forward- and reverse-mode paths with exact-rational references, public continuation/policy examples, and existing CE controls. Tests also check equivalent coefficient/shift representations and the physical scale returned by the shared helper.

The added arithmetic has a measured cost. Relative to the prior revision, the bounded CPU kernel is about 1.5–1.8 times slower for primal evaluation and 1.17–1.20 times slower for coefficient gradients. A matched bounded Eichenbaum A100 solve showed no measurable slowdown: warm solves were 6.16 seconds, within the repeated baseline's 0.44% spread, with unchanged device peak memory and bitwise-identical values and sampled policies. This covers the tested profile; whole-model differentiation and larger calibration grids remain unmeasured. CPU kernel and differentiation cost acceptance remains open.

Process-edge continuation now uses one shared corner program. The loop keeps the certainty equivalent inside each joint corner and retains the original corner order. This removes exponential copies of the continuation graph without changing the economic rule. A regression test limits program construction to two continuation programs.

The additional checks cover 202 native mathematical cases and 1,106 source mutations. On the benchmark runner's V100, the selected ACA simulation program built in 2.13 seconds; both old-code arms exceeded 82 seconds in that phase before the 120-second process cap. The repaired replay matched the captured outputs and layouts exactly, rejected output mutations, and ran three warm calls in 2.412–2.414 seconds. Baseline warm time and a full-model speedup remain unmeasured.

The normal ACA benchmark class completed on the V100 with a fresh JAX cache and configured FP64: cold automatic solve and simulation took 1,803.34 seconds, the following warm call took 250.28 seconds, and the measured CPU-memory peak was 11.14 GiB. Total benchmark-cache setup took 36 minutes 44 seconds. These are one cold and one warm observation on eight CPU cores; a source-only certificate used separate cores during part of the run. There is no controlled full-baseline or A/A comparison. The earlier graph-construction hang is repaired; the remaining full-model cost needs review. This direct invocation used the original benchmark class and measurement subprocess; it does not establish a successful GitHub ASV CLI run.

Reuse the existing scaled-lottery reduction so a weighted mean reserves numerator headroom and scales its denominator consistently. Preserve the ordinary unscaled reduction and assert both the public continuation value and axis/sign variants.
@read-the-docs-community

read-the-docs-community Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

hmgaudecker and others added 20 commits October 26, 2026 17:01
# Conflicts:
#	tests/candidate_certificate/sources.json
The ci-workload-weights hook filled the missing weights of test files that
arrived through the stack merge and rebalanced the shards accordingly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LAZ63AjbZFLweWuJyPUs6S
A scaled lottery mean lowered each normalized coefficient before multiplying
it into its value. With values near the bottom of the normal range, a
product with a coefficient below one became subnormal and a flushing
backend dropped it, so a normal, well-conditioned mean such as values
[1.5 tiny, 1.5 tiny] under the probability row [3/4, 1/4] came back 25%
low.

Replace the formation shared by zero_safe_average and both
aggregate_scaled routes. Every node's weighted value is now the product of
two normal significands, carried with the integer exponent
coefficient - shift + value. The numerator is placed so its largest term
sits in [1, 4) and the mass so its likeliest node sits in [1, 2); each
term is lowered only by its distance to the largest one. A term lost on
the way down is below the largest by the whole normal range, so absent
cancellation it cannot be material at any scale. Neither sum can
overflow, and the two exponents meet once in the final ratio.

Poison rows, null events against infinite values, the eager zero-mass
guard, the centered-residual JVP and the aggregate_scaled AD refusal are
unchanged. The certificate pins for zero_safe.py are resealed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LAZ63AjbZFLweWuJyPUs6S
…ation-overflow

# Conflicts:
#	tests/candidate_certificate/direct_flow.py
#	tests/candidate_certificate/sources.json
…ation-overflow

# Conflicts:
#	tests/candidate_certificate/sources.json
A Tauchen-family process reads its law's own transition row at the actual
current value (the tabulated row at a node), so a value between or beyond
the nodes, in a solve or a simulation, prices a genuine lottery. Rouwenhorst
rows exist at nodes only: between nodes the two neighbouring rows are
blended; beyond them clip_lookup/clip_state read the edge row and
"extrapolate" extends the continuation linearly from the edge row's and its
neighbour's continuations, linear in the certainty equivalent. A carried
Rouwenhorst state whose fixed nodes differ between regimes is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
Tauchen panels move where a simulated state lies between nodes, because its
transition row is now the law's row at that value rather than an interpolation
of node rows. The uniform and Rouwenhorst panels differ in the last bit only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.77401% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.10%. Comparing base (7b7d298) to head (10ecfe0).

Files with missing lines Patch % Lines
tests/test_process_simulation_laws.py 99.44% 2 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                         @@
##           codex/on-nodes-transition-rules     #628      +/-   ##
===================================================================
+ Coverage                            94.06%   94.10%   +0.03%     
===================================================================
  Files                                  660      660              
  Lines                               109752   110569     +817     
===================================================================
+ Hits                                103240   104052     +812     
- Misses                                6512     6517       +5     
Flag Coverage Δ
cpu-python 94.10% <99.77%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regime-weighted continuation overflows to inf near float max in eager mode

1 participant