Skip to content

Speed up GGV: cheaper cross product, one worker per slice - #164

Merged
raorjun merged 12 commits into
mainfrom
claude/project-thread-qin29u
Nov 26, 2026
Merged

raorjun merged 12 commits into
mainfrom
claude/project-thread-qin29u

Conversation

@raorjun

@raorjun raorjun commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Stack: based on main now that #172 and #171 have merged. #173 sits on top of this one.

What

GGV generation is about 10% faster per speed slice, and the output is bitwise identical.

  • np.cross took 12 s of an 87 s profiled slice, mostly in moveaxis bookkeeping on 3-vectors and 4x3 corner arrays. The new engines/dynpy/vector.cross uses NumPy's component formulas without that overhead, so results don't change. It replaces np.cross in dynpy's models, aero and QSS code and in ggv_generation.py.
  • parallel.py capped the GGV pool at 4 workers for 9 independent speed slices. It now runs one worker per slice, up to the core count.

How to check

Measured back to back on a 4-core machine, Python 3.13:

Run Before After
One GGV slice (speed 7 of 9), one core 57.5 s 52.0 s
Full make envelope-ggv (4 workers) 189.2 s 176.5 s

ggv_first_principles.csv, ggv_track_performance_profile.csv and ggv_track_velocity_profile.csv are byte-identical before and after.

The worker change makes no difference on 4 cores, so it isn't measured here. On a machine with 9 or more cores, all 9 slices run at once instead of in 3 rounds.

  • tests/test_dynpy_vector.py checks that cross is bitwise equal to np.cross across the shapes dynpy uses, including broadcasting.
  • tests/test_ggv_parallel.py checks that the worker count follows the core count, capped at the slice count.
  • Locally, ruff, mypy and the full pytest suite pass (1222 passed, 23 skipped).

Notes

np.cross spent most of its time in moveaxis bookkeeping on 3-vectors and
4x3 corner arrays. engines/dynpy/vector.cross uses the same component
formulas, so results are bitwise identical. One speed slice drops from
57.5 s to 52.0 s on one core; the full GGV run from 189.2 s to 176.5 s on
4 cores with identical CSVs.

The GGV pool was capped at 4 workers for 9 independent slices. It now uses
one worker per slice up to the core count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It showed the cross product is bitwise identical to np.cross on the CI runner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make lap-eval-qss solved its nine GGV speed slices serially, which was
almost all of its wall time. The envelope workflow already solves the
same slices in spawned workers through parallel.py, but the lap path
caps drive power on both the envelope parameters and the DynPy vehicle,
so it could not call generate_ggv_from_vehicle as is.

Split parallel.py so callers can hand workers already projected
envelope parameters and an event power cap, and route the lap path
through it. Worker count stays the envelope rule: one per slice, at
most four and at most the CPU count. Slices share no solver state, so
the result is bit-identical to the serial solve; a test pins that on a
two-speed lap envelope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lateral limit coasts, so total wheel torque sits on zero, where the
drive and brake distributions switch. SLSQP's finite differences straddle
that kink and float rounding decides how, which left up to 5e-5 rad/s^2 on
the nearly lifted inside rear's spin balance. CI's runners landed past the
test's 1e-5 tolerance while local runs did not.

Polish each accepted boundary with bounded Newton steps on each side of the
kink, letting the boundary value move by about the residual. Seeded 1e-12
start nudges that reproduce CI's failure now close to about 1e-10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#171 kept the envelope's four-worker cap and moved worker choice into
ggv_worker_count. This branch removes that cap, so the merge applies
the uncapped rule there: one process per slice, up to the CPU count.
The #171 worker-count test and both docs now state that rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raorjun pushed a commit that referenced this pull request Nov 24, 2026
Keeps both new imports in ggv_generation.py: the batched Jacobian
helper from this branch and vector.cross from #164.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raorjun
raorjun changed the base branch from main to claude/project-thread-srhlvw-parallel-ggv November 24, 2026 18:55

@rhorvath02 rhorvath02 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current revision; no actionable code findings. Current CI checks pass. Please preserve the stack order: #172 → #171 → #164 → #173.

@raorjun
raorjun added this pull request to stack #175 November 26, 2026 16:35
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hread-qin29u after #172 landed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from claude/project-thread-srhlvw-parallel-ggv to main November 26, 2026 16:53
The four conflicts are #164's own edits on top of #171's lines, which main
now holds as one squash commit; #164's side is kept. Nothing else on main
touches those files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raorjun pushed a commit that referenced this pull request Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raorjun pushed a commit that referenced this pull request Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raorjun
raorjun merged commit 241a5ef into main Nov 26, 2026
6 checks passed
@raorjun
raorjun deleted the claude/project-thread-qin29u branch November 26, 2026 17:00
raorjun pushed a commit that referenced this pull request Nov 26, 2026
The two conflicts are #173's own edits on #164's lines, which main now
holds as one squash commit; #173's side is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants