forked from isaac-sim/IsaacLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds setting of environment seed at initialization (isaac-sim#940)
# Description Various randomization and procedural generation operations happen at initialization. However, as noted in one of the issues, the seed setting happens after all these operations are performed. This means that the creation of the environment is not completely deterministic. This MR resolves this issue by adding a `seed` configuration to the environment. Fixes isaac-sim#904 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Screenshots The before and after results over **three runs** with the default seed (seed: 42) ```bash ./isaaclab.sh -p source/standalone/workflows/rsl_rl/train.py --task Isaac-Velocity-Rough-Anymal-C-v0 --headless --run_name seed ``` | Results over three runs | | ------ | | Before (main at 788a061) ![before](https://github.com/user-attachments/assets/21a6a9f3-7438-4e73-92dd-a32106272fcb) | | Now (this MR) ![after](https://github.com/user-attachments/assets/821b9c63-34b7-4ce2-8d36-4c979c47070b) | ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Mayank Mittal <12863862+Mayankm96@users.noreply.github.com>
- Loading branch information
Showing
23 changed files
with
337 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Reproducibility and Determinism | ||
------------------------------- | ||
|
||
Given the same hardware and Isaac Sim (and consequently PhysX) version, the simulation produces | ||
identical results for scenes with rigid bodies and articulations. However, the simulation results can | ||
vary across different hardware configurations due to floating point precision and rounding errors. | ||
At present, PhysX does not guarantee determinism for any scene with non-rigid bodies, such as cloth | ||
or soft bodies. For more information, please refer to the `PhysX Determinism documentation`_. | ||
|
||
Based on above, Isaac Lab provides a deterministic simulation that ensures consistent simulation | ||
results across different runs. This is achieved by using the same random seed for the | ||
simulation environment and the physics engine. At construction of the environment, the random seed | ||
is set to a fixed value using the :meth:`~omni.isaac.core.utils.torch.set_seed` method. This method sets the | ||
random seed for both the CPU and GPU globally across different libraries, including PyTorch and | ||
NumPy. | ||
|
||
In the included workflow scripts, the seed specified in the learning agent's configuration file or the | ||
command line argument is used to set the random seed for the environment. This ensures that the | ||
simulation results are reproducible across different runs. The seed is set into the environment | ||
parameters :attr:`omni.isaac.lab.envs.ManagerBasedEnvCfg.seed` or :attr:`omni.isaac.lab.envs.DirectRLEnvCfg.seed` | ||
depending on the manager-based or direct environment implementation respectively. | ||
|
||
For results on our determinacy testing for RL training, please check the GitHub Pull Request `#940`_. | ||
|
||
.. tip:: | ||
|
||
Due to GPU work scheduling, there's a possibility that runtime changes to simulation parameters | ||
may alter the order in which operations take place. This occurs because environment updates can | ||
happen while the GPU is occupied with other tasks. Due to the inherent nature of floating-point | ||
numeric storage, any modification to the execution ordering can result in minor changes in the | ||
least significant bits of output data. These changes may lead to divergent execution over the | ||
course of simulating thousands of environments and simulation frames. | ||
|
||
An illustrative example of this issue is observed with the runtime domain randomization of object's | ||
physics materials. This process can introduce both determinacy and simulation issues when executed | ||
on the GPU due to the way these parameters are passed from the CPU to the GPU in the lower-level APIs. | ||
Consequently, it is strongly advised to perform this operation only at setup time, before the | ||
environment stepping commences. | ||
|
||
|
||
.. _PhysX Determinism documentation: https://nvidia-omniverse.github.io/PhysX/physx/5.4.1/docs/API.html#determinism | ||
.. _#940: https://github.com/isaac-sim/IsaacLab/pull/940 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.