Skip to content

perf: a faster compiled kernel for the distributed helix friction model - #12

Merged
SMI-Lab-Inha merged 1 commit into
devfrom
perf/distributed-friction
Nov 17, 2026
Merged

SMI-Lab-Inha merged 1 commit into
devfrom
perf/distributed-friction

Conversation

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner

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_fatigue on one thread, warm. The 66 kV case is one hour of the template at 10 Hz: 36 001 samples, both armour layers.

Case Direction-tied Distributed, before Distributed, after
66 kV template, 1 h 3.2 s 43.0 s (13.6×) 13.1 s (4.1×)
Shipped fatigue examples – 1.14–1.59× 1.01–1.28×

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

  • Predicted start: Newton starts from the increment of the last substep. The substeps of a sample are equal steps, so the start usually already has the converged stick/slip pattern, and the solve count drops from 3.8 to 1.2–1.6 per substep.
  • Restart from zero: if the predicted start fails, the increment is solved again from zero, as before.
  • Kept factorisation: the Jacobian factorisation is kept between solves. It is eliminated from both ends towards the middle row, with the Sherman–Morrison correction for the periodic corner, so a row that changes refactors only the rows between it and the middle.
  • One pass per iterate: the residual, bound and pattern of an iterate are formed together.

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)

Quantity Largest difference
Wire stress 3.4e-15 of the largest value
Damage, 66 kV template 1.2e-15 relative
Damage, shipped examples (damages of order 1e-12) 1.4e-12 relative
Energies 1e-15 of the largest value
Kept displacement and slip fields round-off; both kernels fix the slide of a full-slip increment by the rule of #11

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.

  • On a 32-node helix with the uniform bound, a relative change of 1e-15 in the curvature moves the reference stress by 0.24 %.
  • The two kernels differ by the same 0.24 % there.
  • With the default node count they differ by 4e-15.

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:

    • planar, rotating, one-sided and full-slip paths;
    • both bound forms;
    • contact shape and pressure history;
    • the pressure factor and the static/dynamic law;
    • the kept kinematics.

    They also check the kept factorisation against dense algebra after row changes, singular pivots, and the fall-backs.

  • Changed: the stick_check reference-value tests now run on both kernels. The independent solver's recorded values hold for both to 1e-10.

  • Coverage: release/check_coverage.py now includes the new test file.

Checks

On this branch, rebased on #11:

  • Full suite: 4374 passed, 4 skipped.
  • With CABLEXSEC_DISABLE_NUMBA=1: 4261 passed, 117 skipped.
  • mypy: mypy src reports no issues in 118 files.
  • ruff: check and format --check are clean on the CI paths.
  • Test taxonomy: 29 unmarked tests added, so each "deselected" figure rises by 29; checked against the collected test IDs.

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>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T01:36:59.217947Z 8979fe1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CableXSec | 🛠️ Build #35944708 | 📁 Comparing 8979fe1 against latest (240bf9c)

  🔍 Preview build  

17 files changed · ± 17 modified

± Modified

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 8979fe1c96

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@SMI-Lab-Inha
SMI-Lab-Inha merged commit f4fc3c7 into dev Nov 17, 2026
12 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the perf/distributed-friction branch November 17, 2026 02:17
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.

1 participant