-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Make PPO compatible with composite actions and log-probs #2665
base: gh/vmoens/58/base
Are you sure you want to change the base?
Conversation
ghstack-source-id: cbdaf533a39aeea41e3fbcda4e9d95a116eabfe1 Pull Request resolved: #2665
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2665
Note: Links to docs will display an error until the docs builds have been completed. ❌ 10 New Failures, 8 Unrelated FailuresAs of commit 3caa87c with merge base d009835 (): NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was 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. |
In this PR, I propose to let PPO have series of actions defined in the in-keys (rather than a single one) to accomodate CompositeDistributions better. This PR requires pytorch/tensordict#1146 and pytorch/tensordict#1145 to be merged or checked out. Here is a demo: |
Cool! Just to understand a bit, how is this related to multiagent? I see in the example that you are using different agent groups, but the feature seems to be more suited for composite single-agent actions. In multiagent, the suggested way to do things was to create a different loss for each group. This is to avoid losses taking a list of dones, rewards, and actions and have to match them. I think this feature for me makes sense for composite actions within a single-agent or a single marl group (avoiding taking a list of rewards and dones). |
Also in the example you are using a single module to output actions for multiple groups. |
I don't have a strong feeling RE multiagent or not, the use case that was suggested to me here had a composite action space where each leaf was labelled "agent_x" log_prob = make_some_tensordict(...)
prev_log_prob = make_some_tensordict(...)
advantage = make_a_tensordict_or_a_tensor(...)
loss = (log_prob - prev_log_prob).exp().clamp(...) * advantage and your loss will be a tensordict itself. |
This makes sense for a composite action space yes. But in your PR i see you are also allowing lists of dones and rewards. This is a bit less trivial as it opens up to a bunch of compatibility usecases if you want to use this in MARL.
Supporting all these usecases might become a big headacke which is why I preferred to stick with one reward and done key per loss class. |
ghstack-source-id: f465f2017843904a510aa06768ced457df987e94 Pull Request resolved: #2665
Stack from ghstack (oldest at bottom):