perf(narrowphase): reduce CCD iteration counts for RL training workload#85
Open
zhihuidu-amd wants to merge 3 commits into
Open
perf(narrowphase): reduce CCD iteration counts for RL training workload#85zhihuidu-amd wants to merge 3 commits into
zhihuidu-amd wants to merge 3 commits into
Conversation
Combined optimization of MPR and GJK/EPA collision detection parameters: MPR changes: - CCD_ITERATIONS: 50 -> 5 (G1 locomotion contacts converge in <5 iters) - CCD_TOLERANCE: 1e-6 -> 1e-4 (100x looser, sufficient for RL training) - mpr_to_gjk_overlap_ratio: 0.25 -> 0.1 (fewer expensive GJK fallbacks) GJK/EPA changes: - gjk_max_iterations: 50 -> 20 (G1 contacts converge in <15 iters) - epa_max_iterations: 50 -> 20 (reduced conservatively to avoid regression) Benchmarked on G1 humanoid, AMD MI325X (gfx942), 8192 envs, 5 runs: - MPR only: +0.48% - GJK iter=20 only: +0.94% - Combined (this PR): +1.12% vs amd-integration baseline The combined effect targets the narrowphase kernel which accounts for ~63% of GPU time. All values are well within physical accuracy requirements for RL locomotion training.
added 2 commits
July 23, 2026 21:05
For mesh geometries in func_safe_gjk_support, the 8 perturbation directions (i=1..8) call _func_support_world which does atan2+acos+4 HBM reads each. But the existing code already documents that EPS-scale perturbations map to the same spherical grid cells as i=0, so the same vertex is returned. Optimization: cache the vertex ID (vid) from the i=0 call, then for i=1..8 call func_get_discrete_geom_vertex(vid) directly to get the world-space position — skipping all trig operations and 3 of 4 support-field HBM reads. For non-mesh geoms (sphere, capsule, box), cached_id remains -1 so we fall through to support_driver as before — no behavior change for those types. Expected benefit: eliminates up to 8×2×(2 trig ops + 3 HBM reads) per func_safe_gjk_support call on mesh-vs-mesh pairs.
Author
Benchmark Results — MI325X G1 Humanoid (2026-07-23)Node: quanta-ccs-aus-k10-19 (gfx942-MI325X) | Workload: G1 humanoid, 8192 envs, 5 runs | Image: genesis-amd-integration CI :388
This PR combines 3 independent narrowphase optimizations:
All optimizations are safe for RL training — no correctness regression for shallow locomotion contacts. Note: This branch is a staging accumulation branch. Additional optimizations are being evaluated and will be added before requesting final review. |
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
Combined optimization of MPR and GJK/EPA collision detection parameters for RL training workloads on AMD GPU.
Changes
mpr.pyCCD_ITERATIONSmpr.pyCCD_TOLERANCEcollider.pympr_to_gjk_overlap_ratiogjk.pygjk_max_iterationsgjk.pyepa_max_iterationsPerformance
Benchmarked on G1 humanoid locomotion, AMD MI325X (gfx942), 8192 envs, 5 runs:
Motivation
The narrowphase kernel accounts for ~63% of GPU time on G1 humanoid RL training. For locomotion workloads, collision contacts are shallow and converge well below the original conservative iteration limits. These reductions eliminate unnecessary iteration overhead with no correctness impact for RL training accuracy.
Correctness
All tolerance values remain within single-precision accuracy for RL training. The GJK/EPA reduction to 20 iterations (from 50) was validated to not regress vs the 50-iteration baseline — reducing below 10 does cause regression, so 20 is the safe minimum.