Repository navigation
Batch GGV constraint Jacobians through one vectorized 3DOF evaluation - #173
Merged
Merged
Conversation
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>
SLSQP's finite-difference Jacobians were about 85% of a GGV slice, one scalar model call per column. The constraint Jacobians now come from engines/dynpy/jacobian.py, which takes SciPy's 2-point steps exactly and hands every column point to model.evaluate_batch first. The 3DOF QSS batch (aero, loads, kinematics per rack, tires, load transfer) matches row-by-row evaluate bit for bit, so the solve takes the same path. Full GGV: 192 s to 67 s on 4 cores, CSVs byte-identical to main. 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>
This was referenced Nov 24, 2026
raorjun
marked this pull request as ready for review
November 24, 2026 19:01
rhorvath02
approved these changes
Nov 26, 2026
rhorvath02
left a comment
Member
There was a problem hiding this comment.
Reviewed the current revision; no actionable code findings. Current CI checks pass. Please preserve the stack order: #172 → #171 → #164 → #173.
Validation scope: focused tests were checked during review, but I did not independently rerun the full vehicle/GGV regression. The PR reports byte-identical GGV outputs. Before merging the final integrated stack, please retain or refresh that comparison on the final revisions, checking envelope and track outputs against the baseline.
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.
What
Before: SLSQP built each GGV constraint Jacobian by finite differences, one scalar model call per unknown. That was about 85% of a GGV slice.
After: the constraint Jacobians come from
engines/dynpy/jacobian.py, which takes SciPy's 2-point steps exactly and hands every column point tomodel.evaluate_batchbefore any column is read. The 3DOF QSS model evaluates those rows as arrays: aero, loads, kinematics per unique rack, tires, load transfer and slip slopes. Each row matches row-by-rowevaluatebit for bit, so the solver takes the same path and the output does not change. Other fidelities get a row-by-rowevaluate_batchuntil they have their own vectorized path.Full GGV on 4 cores goes from 192 s to 67 s. One slice (index 6) goes from 58 s to 20 s.
How to check
python -m pytest -n auto tests,ruff check ., andmake typecheckall pass locally.tests/test_dynpy_batch.py(25 tests) covers:evaluate, with shared and distinct racks, steering input, unloaded corners and no aero;AeroMap.wrench_batchand the batched slip slopes;forward_difference_jacobianagainst SciPy'sapprox_derivativebit for bit: interior, step flip at a bound, narrow boxes forward and backward, and clipping;python -m simulations.envelope.ggv.ggv_generationon this branch and on main produces byte-identicalggv_first_principles.csv,ggv_track_performance_profile.csvandggv_track_velocity_profile.csv.ruff check .andmake typecheckclean.Notes
ggv_generation.pykeeps both new imports (this branch'sforward_difference_jacobianand Speed up GGV: cheaper cross product, one worker per slice #164'svector.cross), and a duplicatecollections.abcimport from the merge was dropped.lru_cachein_solve_envelope_limitis replaced by a small LRU dict, so the batch can fill the cache before SLSQP reads it.