Skip to content

[Performance] Enable worker metadata for automatic parallel envs - #4093

Draft
vmoens wants to merge 1 commit into
mainfrom
codex/auto-worker-metadata
Draft

[Performance] Enable worker metadata for automatic parallel envs#4093
vmoens wants to merge 1 commit into
mainfrom
codex/auto-worker-metadata

Conversation

@vmoens

@vmoens vmoens commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • automatically enable worker-originated metadata when environment convenience constructors create a ParallelEnv from num_workers
  • cover Gym, DMControl, Brax, Habitat, LIBERO, Genesis, MJLab, MuJoCo Playground, and process-based custom MuJoCo environments
  • retain parent-side metadata for known heterogeneous LIBERO schemas and Habitat device assignments
  • document the automatic behavior and extend the existing integration tests

Motivation

metadata_from_workers=True was introduced in #4028 to avoid constructing temporary environments in the parent process. Convenience constructors such as GymEnv(..., num_workers=N) synthesized a ParallelEnv without enabling that mode, so they still paid the parent-side construction cost unless users built the ParallelEnv manually.

This follow-up makes the optimized path automatic when the generated workers have compatible tensor schemas. Gym's native num_envs vectorization remains unchanged.

User impact

Automatically generated process-based environments now start their workers during construction and use pipe-based communication (use_buffers=False), as required by worker-originated metadata. Expensive simulator environments are no longer instantiated solely for metadata in the parent process.

Validation

  • pytest -q test/envs/test_parallel.py -k metadata_from_workers
  • focused num_workers tests across Gym, LIBERO, Habitat, Genesis, MJLab, custom MuJoCo, Brax, DMControl, and MuJoCo Playground
  • pre-commit hooks for all changed files (ufmt run directly from the cached Python 3.11 hook environment)

Local result: 16 passed. Seven optional-dependency cases were collected and skipped because those dependencies or CUDA were unavailable locally; the ci/optdeps label requests their full CI coverage.

@pytorch-bot

pytorch-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4093

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (6 Unrelated Failures)

As of commit e5726f0 with merge base 4169419 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@vmoens vmoens added the ci/optdeps Run the full tests-optdeps suite on this PR label Aug 11, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 11, 2026
@github-actions github-actions Bot added Documentation Improvements or additions to documentation Environments Adds or modifies an environment wrapper Environments/habitat Touches habitat code. Requires habitat run in PRs Environments/gym Environments/brax Environments/mjlab Environments/mujoco_playground Environments/dm_control Environments/libero Performance Performance issue or suggestion for improvement labels Aug 11, 2026
@vmoens
vmoens force-pushed the codex/auto-worker-metadata branch from ee9a6cb to e5726f0 Compare August 11, 2026 15:26
@vmoens

vmoens commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@ParamThakkar123 @itwasabhi, would you be able to review this follow-up? It automatically enables metadata_from_workers=True for the num_workers constructor paths. Param, you implemented constructor-level parallelization across Gym, DMControl, Brax, Habitat, and Genesis; Abhishek, you introduced the MuJoCo Playground integration and its parallel constructor path. Feedback on eager worker startup, use_buffers=False, and the heterogeneous-schema fallback would be especially valuable.

@ParamThakkar123

Copy link
Copy Markdown
Contributor

Sure @vmoens, I will review this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/optdeps Run the full tests-optdeps suite on this PR CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Documentation Improvements or additions to documentation Environments/brax Environments/dm_control Environments/gym Environments/habitat Touches habitat code. Requires habitat run in PRs Environments/libero Environments/mjlab Environments/mujoco_playground Environments Adds or modifies an environment wrapper Performance Performance issue or suggestion for improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants