Repository navigation
perf: a faster compiled kernel for the distributed helix friction model - #12
Merged
Merged
Conversation
The distributed model (friction_model="distributed", and "auto" on non-planar paths) spent all of its time in the compiled increment solver: on an hour of the 66 kV template at 10 Hz about 1.28 million substeps of 0.1 kappa_on, each with 3.8 Newton solves on average. compute_fatigue on one thread, warm: 43.0 s before, 13.1 s after, against 3.2 s for the direction-tied cap (13.6x -> 4.1x); shipped fatigue examples 1.14-1.59x -> 1.01-1.28x of the direction-tied time. _distributed_kernel_fast solves the same increments with the same equations, convergence tests, fall-backs and substep rule: - Newton starts from the increment of the last substep (1.2-1.6 solves per substep instead of 3.8); an increment is solved again from zero, as in the reference, if that start fails, and the slide of a full-slip increment is fixed by the same rule as in the reference (_full_slip_slide), so the start does not reach the kept fields; - the Jacobian factorisation is kept between solves and eliminated from both ends towards the middle row (twisted, with the Sherman-Morrison corner correction), so a changed row refactors only the rows between it and the middle; - residual, bound and stick/slip pattern in one pass per iterate, reciprocals instead of divisions. The previous kernel stays as the reference, used without numba (CABLEXSEC_DISABLE_NUMBA=1). tests/test_distributed_fast.py compares the two (planar, rotating, one-sided, full slip; signed and uniform bound; contact shape, pressure history, pressure factor, static and dynamic law; kept kinematics), checks the kept factorisation against dense algebra after row changes, singular pivots and the fall-backs; the stick_check reference values hold for both kernels. Round-off differences: wire stress at most 3.4e-15 of the largest, damage 1.2e-15 (66 kV template) and at most 1.4e-12 relative (shipped examples), energies 1e-15, kept u, p and step slip to round-off. With a finite healing time heal/break-away events are round-off sensitive in either kernel alone. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
Owner
Author
|
@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. You're on a roll. 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". |
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
A faster compiled kernel for the distributed helix friction model (
friction_model="distributed", and"auto"on non-planar paths). The model runs about 3× faster on the 66 kV template.The substep rule, the equations, the convergence tests and the defaults are unchanged. The direction-tied default path is not touched.
Timings
compute_fatigueon one thread, warm. The 66 kV case is one hour of the template at 10 Hz: 36 001 samples, both armour layers.Where the time was
All of it was in the compiled increment solver. That means about 1.28 million substeps of 0.1 κ_on, each with 3.8 Newton solves on average, and several passes over the 556–580 helix nodes per solve. The Python wrappers took almost nothing.
What the new kernel does
The previous kernel is kept as the reference. It runs without numba (
CABLEXSEC_DISABLE_NUMBA=1), and the tests compare the two.Equivalence (fast against reference)
Known limit: with a finite healing time of a friction law, a node's heal and break-away events can move by one substep under any round-off change. This is a property of the reference too.
Side effect: from the predicted start, the fast kernel converges on some extreme inputs where the reference gives up. One example is a reversal of 1e10 onset curvatures with k̂ = 1e8.
Tests
New:
tests/test_distributed_fast.py, 26 tests. They compare the two kernels on:They also check the kept factorisation against dense algebra after row changes, singular pivots, and the fall-backs.
Changed: the
stick_checkreference-value tests now run on both kernels. The independent solver's recorded values hold for both to 1e-10.Coverage:
release/check_coverage.pynow includes the new test file.Checks
On this branch, rebased on #11:
CABLEXSEC_DISABLE_NUMBA=1: 4261 passed, 117 skipped.mypy srcreports no issues in 118 files.checkandformat --checkare clean on the CI paths.