perf(tests): reduce runtime and GPU memory - #461
Conversation
Greptile SummaryThe PR reorganizes the test suite into resource-aware CI lanes and defers simulation/task initialization to reduce runtime and GPU pressure.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure identified. The resource-aware workflow still provides lanes for the current test categories, and the simulation cleanup, lazy initialization, TF32 restoration, and solver changes preserve their relevant runtime contracts.
|
| Filename | Overview |
|---|---|
| .github/workflows/main.yml | Splits tests into documentation, parallel pure-Python, serial simulation, isolated distributed-GPU, and remaining GPU lanes. |
| tests/conftest.py | Defers task and renderer initialization, dynamically classifies simulation tests, and groups tests for resource-aware xdist execution. |
| embodichain/lab/sim/sim_manager.py | Makes cleanup queue draining race-safe and avoids waiting when no destruction task was pending. |
| embodichain/lab/sim/objects/articulation.py | Detaches drive tensors before NumPy conversion and emits scalars for single-value rows. |
| embodichain/lab/sim/solvers/srs_solver.py | Corrects module exports and supports detached Torch tensors in the CPU IK pose conversion path. |
| pyproject.toml | Excludes slow tests by default and registers the new resource and task-discovery markers. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Collected pytest items] --> B{Documentation tests?}
B -->|Yes| C[Documentation lane]
B -->|No| D{requires_sim marker or detection}
D -->|Yes| E{GPU marked?}
D -->|No| F{GPU marked?}
E -->|No| G[Serial real-simulation lane]
E -->|Yes| H{Distributed RL test?}
H -->|Yes| I[Isolated distributed GPU lane]
H -->|No| J[Remaining serial GPU lane]
F -->|No| K[GPU-hidden xdist pure-Python lane]
F -->|Yes| J
Reviews (1): Last reviewed commit: "perf(tests): reduce runtime and GPU memo..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
This PR restructures test execution to reduce overall wall time and GPU memory pressure by marking and routing tests based on simulation/GPU/task-discovery needs, and by tightening a few hot-path teardown/initialization behaviors.
Changes:
- Adds/adjusts pytest markers (
requires_sim,no_sim,requires_tasks,gpu,slow,xdist_group) and updates collection logic to better separate pure-Python vs real-simulation vs GPU workloads. - Improves simulation cleanup behavior by making
SimulationManager.flush_cleanup_queue()return immediately when there’s nothing pending, avoiding unnecessary global waits. - Updates CI workflow to run tests in staged lanes (docs, pure-Python xdist, real-sim, isolated distributed GPU, remaining GPU).
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/toolkits/test_batch_convex_collision.py | Marks CUDA-dependent collision test as gpu and reorders imports. |
| tests/sim/test_sim_profiler.py | Marks profiler unit tests as no_sim to keep them out of the simulation lane. |
| tests/sim/test_sim_manager.py | Adds regression coverage for cleanup-queue behavior and marks mock-only tests as no_sim. |
| tests/sim/planners/test_toppra_batched.py | Reduces default env/batch sizes and marks heavier multiprocessing coverage as slow. |
| tests/sim/planners/test_curobo_planner.py | Adds a module fixture to restore Torch TF32/matmul precision after cuRobo tests. |
| tests/sim/objects/test_rigid_constraint.py | Marks mock-only constraint config tests as no_sim. |
| tests/learning/test_shared_rollout.py | Splits mock-only vs real-sim + tasks tests using no_sim / requires_* markers. |
| tests/learning/test_rl.py | Marks RL training tests as requires_sim, requires_tasks, and slow. |
| tests/learning/test_rl_distributed.py | Marks distributed torchrun test as gpu and slow. |
| tests/learning/test_newton_planar_reach.py | Marks expensive APG training test as slow. |
| tests/gym/envs/test_replay.py | Marks replay env tests as requires_sim and slow. |
| tests/gym/envs/test_profiler_integration.py | Marks integration test as requires_sim. |
| tests/gym/envs/test_embodied_env.py | Marks env tests as requires_sim. |
| tests/gym/envs/test_base_env.py | Marks env tests as requires_sim. |
| tests/data_pipeline/test_online_data.py | Avoids starting the sim subprocess for sampling-only tests to reduce teardown waits. |
| tests/conftest.py | Defers task discovery to requires_tasks tests; adds real-sim classification and xdist_group routing; defers DexSim init. |
| pyproject.toml | Sets default -m "not slow" and registers new markers, plus warning filtering. |
| embodichain/lab/sim/solvers/srs_solver.py | Fixes __all__, adds future annotations, and supports Torch tensors for target poses. |
| embodichain/lab/sim/sim_manager.py | Makes cleanup flush skip global waits when nothing was drained. |
| embodichain/lab/sim/objects/articulation.py | Normalizes drive args to Python scalars when appropriate to reduce tensor->numpy friction. |
| .github/workflows/main.yml | Splits CI tests into docs/pure/real-sim/distributed-GPU/remaining-GPU stages. |
Suppressed comments (2)
.github/workflows/main.yml:168
- Same mark-expression issue as above:
-m "requires_sim and not gpu"overrides the default-m "not slow", soslowreal-simulation tests will run in this job.
echo "Real-simulation tests (one process, GPU tests excluded)"
export HF_ENDPOINT=https://hf-mirror.com
pytest tests --ignore=tests/docs -m "requires_sim and not gpu"
.github/workflows/main.yml:181
- This GPU lane also overrides the default
-m "not slow"by passing-m gpu, so anygpu and slowtests will be included here (even though slow tests are intended to be excluded by default). If the isolated distributed job is the intended home for slow GPU coverage, the remaining GPU suite should explicitly excludeslow.
- name: Run remaining GPU tests serially
run: |
echo "Dedicated GPU test suite"
export HF_ENDPOINT=https://hf-mirror.com
pytest tests --ignore=tests/docs \
--ignore=tests/learning/test_rl_distributed.py --run-gpu -m gpu
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo "Pure-Python tests (GPU hidden, four workers)" | ||
| CUDA_VISIBLE_DEVICES="" pytest tests --ignore=tests/docs \ | ||
| -m "not requires_sim and not gpu" -n 4 --dist loadgroup |
Description
This PR reduces unit-test wall time and GPU memory pressure by separating pure-Python, real-simulation, distributed-GPU, and remaining GPU workloads according to their resource needs.
It also removes redundant simulation cleanup waits, defers task discovery and renderer initialization until required, keeps mock-only tests out of the simulation lane, marks expensive coverage explicitly, and prevents cuRobo's process-wide TF32 setting from contaminating later solver tests. No dependencies are changed.
Measured impact
GPU memory was sampled every 250 ms from each pytest process tree with
nvidia-smi.For comparable non-GPU coverage, wall time drops by about 9m 18.5s (33.0%). Isolating distributed training lowers the observed aggregate GPU peak from 12,709 MiB to 10,748 MiB (15.4%), while the pure-Python xdist lane consumes no GPU memory.
Type of change
Screenshots
Not applicable.
Validation
black .— 600 files unchangedgit diff --checkpassed (actionlintwas not installed in the local image)Checklist
black .command to format the code base.