Repository navigation
fix: a repeated sample keeps the distributed state; capstan bounds overflow to inf as Python - #50
Conversation
…erflow to inf as Python A constant curvature cycled in the distributed helix model. The compiled kernel started a sample that repeats the last one from the increment of the last substep and converged to a drift of the Newton tolerance (2e-6 Pa per sample on the 33 kV template's inner armour at 0.01 1/m and 200 kN), which compute_fatigue counted as 1e-58 damage where the reference kernel gave 0. Both kernels also moved the segment forces by one ulp on such a sample (1e-69 damage on the outer armour). Under the Coulomb bound a repeated sample now keeps the state in both kernels, with no substep; under a friction law it is still solved (a node can heal while it sticks), the compiled kernel starting it from a zero increment as the reference does. Run as Python (without numba), the compiled direction-tied and progressive kernels raised OverflowError from math.expm1 where compiled they return inf. friction_law._expm1_or_inf gives inf past log(DBL_MAX) on both, bit for bit equal to math.expm1 below it. Without numba this made compute_fatigue(..., friction_model="progressive", mu=1e6) fail. The reference progressive history holds such a sub-element cap at 1e300 Pa, as the reference Papailiou bound does, so it sticks where the compiled kernel does. Compiled results are unchanged. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The interpreted fall-back test counts fixed-point calls. Its first sample repeats the stress-free start (zero curvature), which now keeps the state without a solve, so the failing call falls on sample 4 instead of 3. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
This PR fixes two kernel defects. Each made the compiled and the reference path give different answers on a valid input:
compute_fatigue(cable, kx=0.01, ky=0, tension_N=2e5, friction_model="distributed"), 33 kV templatecompute_fatigue(..., friction_model="progressive", mu=1e6)withCABLEXSEC_DISABLE_NUMBA=1;fast_slipforced without numbaOverflowError: math range errorfrommath.expm1, thenFloatingPointErrorin the reference progressive historymu = 3e4(from where the progressive model is fully stuck on the probe history)1. A repeated sample keeps the distributed state
The friction stress of the distributed helix model at a constant curvature of 0.01 1/m and 200 kN behaved differently on the two kernels:
1e-12 htimes the force scale). The rainflow counter counted that drift as cycles.Changes:
Only histories with exactly repeated samples change: the repeated samples themselves, and the later samples at round-off (Newton tolerance).
2. Capstan bounds overflow to
infas Python tooCompiled,
math.expm1of an argument beyondlog(DBL_MAX)returnsinf, and the wires stick. Run as Python (the kernels without numba, and the kernel-coverage pass), it raisesOverflowError.friction_law._expm1_or_infreturnsinfpastlog(DBL_MAX) = 709.782712893384andmath.expm1below it. Its overflow point matches numba's and CPython's:expm1(709.782712893384)is finite on both, and the next double givesinfcompiled and an error in Python.fast_slipand the progressive caps use the helper. Compiled results are therefore unchanged at every argument.inf, orinf - infbetween two such cumulative bounds) is now held at 1e300 Pa, like the reference Papailiou bound (fix: adversarial inputs of the public API are refused early or answered on both kernel paths #41). The history sticks where the compiled kernel sticks.I first tried capping the exponent at
_EXP_LIMIT = 600, asfriction_lawalready does. That is wrong for the progressive model: its sub-element caps are differences of cumulative bounds, so capped elements get zero cap. Atmu = 1e4the damage fell from the stuck limit 9.25e-7 to 8.4e-9. It is not used.Damage of the progressive model against
muon the probe history (outer armour):OverflowError)Reviewed, not changed
friction_lawalready caps its exponents at 600. That is right there, because its bounds are not differenced.fast_rainflowevaluates10 ** (log C - m log10 S). This overflows only for subnormal stress ranges, which no history reaches.Tests
test_fast_kernel_fall_backsnow expects the fixed point to fail on sample 4 instead of 3, because sample 0 repeats the stress-free start.tests/test_distributed_fast.py(fail without the fix):test_a_repeated_sample_keeps_the_state[signed, uniform]: ramp, hold, reversal and second hold. In both kernels the held samples equal the last sample bit for bit (wire forces, segment field, energies, slip fraction), take no substep, and agree between the kernels.test_a_repeated_sample_under_a_friction_law_is_solved_from_zero: with healing, the fast kernel still matches the reference.tests/test_robustness_inputs.py:test_constant_curvature_gives_no_distributed_damage[reference, fast]: zero damage on both layers. Fails without the fix.test_very_large_mu_sticks_in_the_progressive_model:mu = 1e6equalsmu = 3e4. Fails without numba before the fix.test_expm1_guard_is_the_compiled_expm1_at_every_argument.test_very_large_mu_sticks_on_both_kernel_pathsnow forces thefast_slipkernel in every environment, including without numba.No tolerance or band changed.
Gates
On f8438f5. The next commit changes only the CHANGELOG wording. 439624b changes only
test_fast_kernel_fall_backs, an interpreted-kernel test that counts fixed-point calls: its first sample repeats the stress-free start and now needs no solve, so the failing call moves from sample 3 to sample 4.NUMBA_NUM_THREADS=1: 4879 passed, 4 skippedCABLEXSEC_DISABLE_NUMBA=1: 4761 passed, 2 failed, 120 skipped. The two failures weretest_fast_kernel_fall_backs[0.127, 0.0], fixed in 439624b;tests/test_distributed_fast.pythen passes in full, 29 tests without numba and 26 with (3 skipped).python -m mypy: no issues in 120 source files;ruff checkandruff format --checkonsrc tests examples validation release doc: clean--collect-onlyper marker: unchanged at 1248 / 77 / 59 (the new tests carry no marker)