Repository navigation
perf: fused fixed-fibre counting and one-pass stress field in compute_fatigue - #44
Conversation
…_fatigue compute_fatigue counts every fixed fibre of a layer in one compiled pass (fast_rainflow.fibre_miner_damage): each fibre history is reduced to its turning points while it is formed from the field components, without branches, the reversal scan feeds the three-point stack directly, and one count serves the unit and the termination stress-range factor. The fibre histories are no longer formed in NumPy. The stress field of wire_stress_field is assembled in one compiled pass (fast_field.assemble_wire_field) with the operations of the NumPy expressions in the same order; without numba the NumPy path computes the local bending stress once instead of twice and no longer forms the per-wire copies of the axial and thermal stress. The direction-tied friction kernel keeps its bounds in place instead of allocating them at every sample. All damage is bit for bit equal to the previous build on the throughput workload (one-hour sea state, 66 kV template, every case) and in the suite; entries where the reference would raise are recomputed on the reference path in the order of the former loop. The sea-state batch has no upper limit on the worker count (the pool starts at most one worker per run); MAX_WORKERS is removed. validation/scripts/benchmark_throughput.py records the one-core throughput of the sea-state path, the damage differences from an earlier build and the batch time against the worker count; tests/test_fast_fatigue_path.py checks the fused path against the arithmetic it replaces. 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. Already looking forward to the next diff. 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". |
Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
The CHANGELOG entry gives the timings of the throughput benchmark against dev e74e01f without this change, measured in one session on one machine: direction-tied 2.5 to 2.8 times faster, distributed 29.2 s to 27.5 s, batch of 48 runs 107.6 s to 42.6 s on one worker and 61.1 s to 26.9 s on two. All 24 damage arrays of the benchmark are bitwise equal to that build with numba, and the 12 of the direction-tied cases without numba. The 16 persistent cache slots of the batch workers stay as they were now that the worker count has no upper limit. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 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
compute_fatigueruns 2.3–3.0 times faster on the default direction-tied model. Every damage value is unchanged bit for bit. The sea-state batch no longer caps the worker count. A throughput benchmark script records the timings, and a light test checks the fast path against the arithmetic it replaces.Registered targets
Targets (a)–(c) and the removal of the worker cap were fixed before any change was made; the numerical threshold of (d), 0.8 efficiency at 8 workers, was set after the measurements (the original target said only "near-linear"). Workload: one-hour synthetic sea state on the 66 kV template (
kappa_x,kappa_yirregular, peak period 10 s, standard deviations 0.004 and 0.002 1/m, tension 100 ± 10 kN, 20 000 samples at 0.18 s), numba, one thread (AMD Zen 4 core), compilation excluded, minimum of 3 calls.Reference basis. A commercial cross-section tool reports 270 one-hour sea states × 76 locations × 48 series (12 positions × 4 hot spots of one layer) × 20 000 steps, about 1.97 × 10¹⁰ stress evaluations, in about 5.8 h on one core of a 2008 laptop: 1.06 µs per evaluation. That core is estimated (not measured) at 4–6 times slower than a Zen 4 core, which puts the reference at about 180–265 ns per evaluation on this machine. Target (a) is its per-location time normalised the same way (about 1.0 s per location-sea-state / (4–6)). Target (b) was registered as 1.0 ns per series-step from a figure that has since been found to be off by a factor of 1000; it is kept here as registered and reported as not met. On the corrected basis CableXSec, at 4.9 ns per series-step after this change (13.3 ns before), is about 36–54 times faster per evaluation than the normalised reference (14–20 times before).
(c) and the "after" ratio: the distributed time fell from 25.8 s to 23.3 s, but the direction-tied time fell more. (d): efficiency is speed-up over worker count, against 1 worker.
Timings at 39c1f81 (before the dev merge)
validation/scripts/benchmark_throughput.py --repeat 3. Before (4a6541b) and after were run in the same session on the same machine.Batch (
run_sea_state_batch, synthetic CableDyn runs of 20 000 samples, one section, all wires, 32 fibres):The remainder is a fixed cost of about 2.5 s at 8 workers: each spawned worker imports the package (1.2 s) and loads the compiled kernels before its first run. This cost is the same for any number of runs, so efficiency rises with campaign size.
Without numba (
CABLEXSEC_DISABLE_NUMBA=1, 3 000 samples), the run is no slower: 0.89 → 0.88 s (all wires, 4 fibres) and 0.65 → 0.65 s (12 positions, 32 fibres). Damage is bitwise equal there too.Re-measured after merging dev e74e01f
dev moved the damage since
4a6541b, by up to 8.7 % relative on this workload (#39, the Yun shear stack stopping at the armour support, and the later merges). So the reference was rebuilt: the same benchmark script was run on deve74e01fwithout this PR (--referenceagainst the old build records those differences). This PR, merged with that dev (31b87f8), was then compared against the rebuilt reference. Both were run in one session on the same machine, with numba, one thread and--repeat 3. Other work was running on the machine, so the absolute times carry some noise.e74e01fTargets on these numbers:
Batch, 48 synthetic one-hour runs (20 000 samples, one section, all wires, 32 fibres):
e74e01fThe annual damage does not depend on the worker count in either build. The 4- and 8-worker rows of the batch table below come from
39c1f81, before the merge. They were not re-run here because this machine was limited to two concurrent jobs. dev's numba cache slots for batch workers (#48) were sized as2 * MAX_WORKERS. With the cap removed, they are fixed at 16, the same number. Up to 8 workers nothing changes, and a worker beyond the 16 slots gets a temporary cache.Without numba (
CABLEXSEC_DISABLE_NUMBA=1, direction-tied cases, 3 000 samples, one call), times are 0.891 → 0.871 s (all wires, 4 fibres), 4.762 → 4.749 s (32 fibres) and 0.338 → 0.336 s (12 positions).Profile (before)
Direction-tied, 32 fibres, 2.34 s in total:
at_fibre)miner_rows)Distributed: 21.9 of 22.4 s are in the compiled increment solver. That is 2.85 million substeps of 0.1
κ_onover 556–580 helix nodes, with 1.13–1.28 Newton solves per substep and about 8 µs per substep. The curvature reaches 91 and 293κ_on, which gives 34–108 substeps per sample. Rainflow counting and section-state setup take under 3 ms per call. In the batch, each run costs 0.14 s of fatigue work plus 0.04 s for the reader.Changes
Fused fibre counting (
fast_rainflow.fibre_miner_damage, used bycompute_fatigue). Each fibre history is reduced to its turning points while it is formed from the field components,(mean + radial n) + tangential l, which is the arithmetic ofat_fibre. The turning-point scan has no branches. The reversal scan feeds the three-point stack directly. One count serves both the unit factor and the termination SCF. Entries where the reference sum would raise are recomputed on the reference path, in the order of the former loop, so the errors are unchanged. Non-finite fibres are found from bounds on the component magnitudes.One-pass field assembly (
fast_field.assemble_wire_field). It does the NumPy operations in the same order, and the trigonometric factors are still evaluated by NumPy. The NumPy path, used without numba, now forms the local bending stress once instead of twice and no longer builds per-wire copies of the axial and thermal stress.Direction-tied friction kernel: the bounds are kept in place instead of being allocated at every sample.
Batch:
MAX_WORKERSis removed.workerstakes any positive integer, and the pool starts at most one worker per run.validation/scripts/benchmark_throughput.py: the cases above,--referencefor damage differences against another build, and--batch-workersfor batch scaling.tests/test_fast_fatigue_path.py(added to the kernel-coverage list) checks:miner_rowson the fibre histories, bitwise, for 3 curves × 4 start offsets × 1 or 2 factors;compute_fatiguewith the compiled counter against the reference loop, with lead-in and selected positions;No wall-clock assertions.
Equality
e74e01fwithout this PR: all 24 damage arrays of the six cases (D_bulk_per_fibreandD_total_per_wire, both layers) are bitwise equal. Maximum absolute and relative difference: 0.39c1f81the same held against4a6541b.Why (b) and (c) are not met
(b) At 32 fibres on this record, the measured costs per series-step are:
cos,asin, twoexpm1) needed bit for bitlog10andpow, 14 ns per cycle)That adds up to about 4.4 ns against 4.9 ns measured, so 1.0 ns cannot be reached while results stay bit for bit. A Miner sum written as
count * S**m / Cwith integer powers would remove most of the last line, but it changes every damage value at round-off. It is left out of this PR for a separate decision.(c) The distributed cost is the implicit solve itself, not a fixed overhead. The stick/slip pattern changes in almost every substep (1.1–1.3 Newton solves each), and about 10 passes over the helix nodes run per substep at about 1.5 ns per node and pass. Reaching 5× the new direction-tied time would mean about 4.5 s, a 5× cut. That needs either fewer substeps, which changes the results by the discretisation error rather than at round-off, or a different solver.
Gates
On
31b87f8, the merge with deve74e01f.040fe9bchanges only the CHANGELOG numbers.NUMBA_NUM_THREADS=1: 4872 passed, 4 skippedCABLEXSEC_DISABLE_NUMBA=1: 4756 passed, 120 skippedpython -m mypy: no issues in 120 source filesruff checkandruff format --checkonsrc tests examples validation release doc: clean--collect-onlyper marker: unchanged at 1248 / 77 / 59 (the new and removed tests carry no marker)sea_state_batch.py: the removed cap next to dev's option checks; both kept, cache slots as abovedoc/global_local_guide.md: the worker bullet, with the slot caches added