Skip to content

Adds per-head entropy coefficients to PPOLoss #2972

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

felixsittenauer
Copy link

Description

Adds per-head entropy coefficients to PPOLoss.

  • entropy_coef now accepts
    • scalar (legacy behaviour) or
    • Mapping[str, float] — one coefficient per action head.
  • New helper _weighted_entropy applies the correct weighting:
    • scalar path: -coef * entropy
    • mapping path: -Σ coef_head * entropy_head
  • forward() switches from direct multiplication to _weighted_entropy.
  • Keeps self.entropy_coef buffer for backward-compat (dummy 0.0 when mapping used).
  • Docstrings updated.

Motivation and Context

Composite / multi-head policies often need different exploration pressure on
each sub-action (e.g. steering vs. throttle).
This change lets users express that directly via a dict instead of patching the
loss externally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Copy link

pytorch-bot bot commented May 22, 2025

🔗 Helpful Links

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

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

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

@facebook-github-bot facebook-github-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 May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants