perf(rbd): optional GPU contact reduction (merge per-pair manifolds to ≤4 points)#17
Open
haixuanTao wants to merge 1 commit into
Open
perf(rbd): optional GPU contact reduction (merge per-pair manifolds to ≤4 points)#17haixuanTao wants to merge 1 commit into
haixuanTao wants to merge 1 commit into
Conversation
Training-grade, default OFF (pipeline.contact_reduction). A convex resting on a trimesh emits one manifold per overlapping triangle, all sharing one colliders key and one collider-A local frame; the mb contact-constraint kernels then pay 6 solver slots per point (4-8x flat-ground cost). The pass compacts each batch's contacts in place after pfm_pfm: first record of a pair copies verbatim (flat-ground = bit-identical, verified on the trainer's iter-0 reference), later records merge via the existing manifold_reduction selector (pool <=8 points, deepest manifold's normal, deepest+spread down to 4). threads(1) per batch, single writer. Documented approximations: one normal per merged manifold, greedy emission-order merging. Full-stack terrain @4096: 3.8 -> 3.3 s/iter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
haixuanTao
force-pushed
the
perf/contact-reduction
branch
from
July 16, 2026 16:02
45e455c to
65e01c0
Compare
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
Opt-in narrow-phase pass (
RbdPipeline::contact_reduction, default off) that compacts each batch's contacts in place afterpfm_pfm: the first record of each collider pair is kept verbatim, and every later record with the same key (e.g. per-triangle trimesh manifolds under one foot) is merged into it — pool both manifolds' points (≤8), keep the deeper manifold's normal, and reuse the existingmanifold_reductiondeepest+spread selector down toMAX_MANIFOLD_POINTS.Why
A convex collider resting on a trimesh emits one manifold per overlapping triangle, all sharing one
colliderskey and one collider-A local frame. Downstream solver kernels then pay per-point cost for near-duplicate information — on our rough-terrain RL workload the multibody contact-constraint kernels ran 4–8× their flat-ground cost (169 vs 76 µs/call). Merging to one ≤4-point manifold per pair is the standard engine remedy (PhysX/MuJoCo do the equivalent).Measured on a 29-DOF humanoid batch (4096 envs, trimesh terrain, RTX 5090, native-CUDA backend): full training iteration 3.8 → 3.3 s (−13%), contact-constraint kernels 2–4× cheaper. Flat-ground scenes are unaffected.
Design notes
init_contacts_indirect_argsruns on the untouched counts.threads(1), grid[1, num_batches, 1], two-cursor in-place compaction (write cursor ≤ read cursor);contacts_lenrewritten by the single writer per batch.manifold_reductionis dim3); dim2 keeps compiling — the flag is accepted and ignored.Documented approximations (why it's opt-in)
cargo checkclean onnexus_rbd3d,nexus_rbd2d, and both shader crates.🤖 Generated with Claude Code
https://claude.ai/code/session_01U2n9RqmxTJb8UG5d1Sjw4W