Skip to content

Adds optimizations and additional training configs for SB3 - #2022

Merged
kellyguo11 merged 45 commits into
isaac-sim:mainfrom
araffin:feat/sb3-optim
Jun 25, 2025
Merged

kellyguo11 merged 45 commits into
isaac-sim:mainfrom
araffin:feat/sb3-optim

Conversation

@araffin

@araffin araffin commented Mar 5, 2025

Copy link
Copy Markdown
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

Implement part of #1769 (optimization)

This is a breaking change because the fast variant is now enabled by default.

I also improve sb3 training script, fixed loading of normalization and fixed the humanoid hyperparameters to be similar to rsl-rl, so we can compare apples to apples in terms of training speed.

I will probably open another PR for the rest of the proposals.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

With respect to testing, how do you run a single test?
and is there anything I should add?

Checklist

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@araffin

araffin commented Mar 7, 2025

Copy link
Copy Markdown
Contributor Author

@Mayankm96 failure on the CI seems to be due to a timeout, probably unrelated to this PR?

@araffin

araffin commented Mar 22, 2025

Copy link
Copy Markdown
Contributor Author

@Mayankm96 when do you think that you or someone from your team can have a look at this PR? and do you need anything else from me?

@Mayankm96
Mayankm96 requested a review from Toni-SM March 23, 2025 11:45
@Mayankm96

Copy link
Copy Markdown
Contributor

Hi @araffin , sorry for the delay. I have assigned @Toni-SM to help review this MR. Thanks a lot for the improvements introduced!

@Toni-SM Toni-SM self-assigned this Mar 30, 2025
print("[INFO] Unfortunately a pre-trained checkpoint is currently unavailable for this task.")
return
elif args_cli.checkpoint is None:
# FIXME: last checkpoint doesn't seem to really use the last one'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I open a separate issue? (it is already broken on master and not related to this PR which is about speed optim)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to be picking up the last checkpoint in my test, what was the issue you were seeing? this might not work with envs that have a PLAY cfg for inferencing. it will not be able to find for example logs/sb3/Isaac-Velocity-Rough-Unitree-A1-Play-v0. is there a way to specify an experiment name or directory in the agent cfg like the other libraries?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue was that it is using alphabetical order instead of number of timesteps to decide which checkpoint is last.
I'll try to give you an example to reproduce.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, we can probably pass sort_alpha=False in get_checkpoint_path to sort it by timestamp then

Comment thread source/isaaclab_rl/isaaclab_rl/sb3.py Resolved
Comment thread source/isaaclab_rl/isaaclab_rl/sb3.py Resolved
Comment thread source/isaaclab_rl/isaaclab_rl/sb3.py Resolved

We performed training with each RL library on the same ``Isaac-Humanoid-v0`` environment
with ``--headless`` on a single RTX 4090 GPU
with ``--headless`` on a single RTX 4090 GPU using 4096 environments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the number of environments is not necessary. Any configuration used is implicit in the task: Isaac-Humanoid-v0

@araffin araffin Mar 31, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as https://github.com/isaac-sim/IsaacLab/pull/2022/files#r2020574675, as a user I would need to really dig in the code to know what is happening (for instance if you want to compare to another simulator).

EDIT: if the default number of envs is changed in the future, those results won't be valid anymore, being explicit makes it more reproducible

@Mayankm96

Copy link
Copy Markdown
Contributor

@Toni-SM could you please re-review this MR so we can merge it in a timely manner. Thank you!

@araffin

araffin commented Jun 11, 2025

Copy link
Copy Markdown
Contributor Author

@Mayankm96 could you maybe assign someone else?
Antonio seems pretty busy those last months.

@kellyguo11

Copy link
Copy Markdown
Contributor

Toni has reviewed the PR, we'll try to get this merged in soon. Thanks for staying on top of this, @araffin!

@kellyguo11 kellyguo11 self-assigned this Jun 11, 2025

@kellyguo11 kellyguo11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the update! the humanoid environment now trains in just 300s!!

Comment thread source/isaaclab_rl/docs/CHANGELOG.rst Resolved
checkpoint_path = args_cli.checkpoint
log_dir = os.path.dirname(checkpoint_path)

agent_cfg = load_yaml(os.path.join(log_dir, "params", "agent.yaml"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this file different than loading it from load_cfg_from_registry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually an important small detail. This loads the exact config used to train the agent, not the default one present in IsaacLab.

"env_cfg_entry_point": f"{__name__}.rough_env_cfg:UnitreeA1RoughEnvCfg",
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:UnitreeA1RoughPPORunnerCfg",
"skrl_cfg_entry_point": f"{agents.__name__}:skrl_rough_ppo_cfg.yaml",
"sb3_cfg_entry_point": f"{agents.__name__}:sb3_ppo_cfg.yaml",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this didn't seem to train well for me with the default parameters. was it training fine on your end?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you didn't try with num_envs=1024? (see discussion above about this hyperparameter)
i fixed it and tested it, should work out of the box now.

print("[INFO] Unfortunately a pre-trained checkpoint is currently unavailable for this task.")
return
elif args_cli.checkpoint is None:
# FIXME: last checkpoint doesn't seem to really use the last one'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to be picking up the last checkpoint in my test, what was the issue you were seeing? this might not work with envs that have a PLAY cfg for inferencing. it will not be able to find for example logs/sb3/Isaac-Velocity-Rough-Unitree-A1-Play-v0. is there a way to specify an experiment name or directory in the agent cfg like the other libraries?

Comment thread source/isaaclab_rl/isaaclab_rl/sb3.py Resolved
@kellyguo11

kellyguo11 commented Jun 23, 2025 •

Copy link
Copy Markdown
Contributor

do you mind adding in the version update in extension.toml? then we can get this merged.

Signed-off-by: Kelly Guo <[email protected]>
@kellyguo11 kellyguo11 changed the title feat: SB3 optimizations (3x faster) Adds optimizations and additional training configs for SB3 Jun 25, 2025
@kellyguo11
kellyguo11 merged commit ad14a67 into isaac-sim:main Jun 25, 2025
harry-wf-cheung pushed a commit to harry-wf-cheung/IsaacLab-Harry that referenced this pull request Jul 30, 2025
…#2022)

# Description

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context.
List any dependencies that are required for this change.

Implement part of isaac-sim#1769
(optimization)

This is a breaking change because the fast variant is now enabled by
default.

I also improve sb3 training script, fixed loading of normalization and
fixed the humanoid hyperparameters to be similar to rsl-rl, so we can
compare apples to apples in terms of training speed.

I will probably open another PR for the rest of the proposals.

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- This change requires a documentation update

With respect to testing, how do you run a single test?
and is there anything I should add?


## 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
- [ ] 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

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------

Signed-off-by: Antonin RAFFIN <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
LJones-alt pushed a commit to LJones-alt/IsaacLab-Laura that referenced this pull request Jul 1, 2026
…#2022)

# Description

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context.
List any dependencies that are required for this change.

Implement part of isaac-sim#1769
(optimization)

This is a breaking change because the fast variant is now enabled by
default.

I also improve sb3 training script, fixed loading of normalization and
fixed the humanoid hyperparameters to be similar to rsl-rl, so we can
compare apples to apples in terms of training speed.

I will probably open another PR for the rest of the proposals.

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- This change requires a documentation update

With respect to testing, how do you run a single test?
and is there anything I should add?


## 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
- [ ] 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

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------

Signed-off-by: Antonin RAFFIN <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
csj-275 pushed a commit to csj-275/IsaacLab that referenced this pull request Jul 8, 2026
…#2022)

# Description

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context.
List any dependencies that are required for this change.

Implement part of isaac-sim#1769
(optimization)

This is a breaking change because the fast variant is now enabled by
default.

I also improve sb3 training script, fixed loading of normalization and
fixed the humanoid hyperparameters to be similar to rsl-rl, so we can
compare apples to apples in terms of training speed.

I will probably open another PR for the rest of the proposals.

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- This change requires a documentation update

With respect to testing, how do you run a single test?
and is there anything I should add?


## 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
- [ ] 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

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------

Signed-off-by: Antonin RAFFIN <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants