Repository navigation
Don't report a fall as a time-out in inverted_pendulum - #681
Open
YannBerthelot wants to merge 1 commit into
Open
YannBerthelot wants to merge 1 commit into
YannBerthelot wants to merge 1 commit into
Conversation
inverted_pendulum set info['time_out'] to done, so with bootstrap_on_timeout=True PPO bootstrapped every fall as if the episode had been cut short. The env has no time limit of its own, so it now reports no time-outs. Fixes google#680
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.
Fixes #680. This implements the fix proposed in the issue:
inverted_pendulumnow setsinfo['time_out']to 0 instead of copyingdone. A fall ends the episode but is not a time-out, so PPO withbootstrap_on_timeout=Trueno longer addsgamma * V(s)to falls. The env still provides thetime_outkey, so the option keeps working with it.The reproduction script from the issue, before:
After:
Tests run (CPU, Python 3.12, JAX 0.12.0.1):
testInvertedPendulumFallIsNotTimeOutinbrax/envs/env_test.py: after a fall,doneis 1 andtime_outis 0. It fails on main and passes with the fix.brax/training/agents/ppo/train_test.py, the tests that train on this env:testTrainWithNetworkParams(all 24 cases, 12 of them withbootstrap_on_timeout=True) andtestTrainWithDistributionalCritic. All 25 pass.pyinkis clean on the changed lines. Both files already have other pyink diffs on main.Not run: the rest of the suite (
pytest --ignore=brax/v1). The SAC, APG, ARS and ES tests also train on this env, but they don't readtime_out.About
testTrainWithNetworkParams: it only checks that training runs. Withbootstrap_on_timeout=Trueit still runs the code path (PPO collectstime_outand adds the bootstrap term), but for this env the term is now always 0, so the test no longer covers a non-zero bootstrap. It did not check the bootstrap value before either.The issue mentions an alternative: a demo env with its own step limit, which would show the option with real time-outs. I'm happy to switch to that if you prefer.
Disclosure: AI-assisted (Claude); I reviewed and tested every change.