Repository navigation
[BugFix] Exclude sparse padding from categorical entropy - #4513
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
AHMETHAKANBEZIR1 wants to merge 1 commit into
Conversation
Co-authored-by: Codex <noreply@openai.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4513
Note: Links to docs will display an error until the docs builds have been completed.
|
This branch has not been deployed
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 #4512
Summary
Sparse
MaskedCategorical.entropy()skipped masking entirely. Padded indices therefore produce NaN withneg_inf=-inf, or contribute to entropy whenneg_infis finite. A valid sparse action with probability zero has the same0 * -infproblem.Apply the existing finite-minimum masking and entropy renormalization to sparse padding and non-finite logits as well as dense invalid actions. Sampling,
log_prob, mode and distribution construction are unchanged. This is independent of #4509 and #4511.Tests in the existing distribution test file compare public entropy and gradients with compact
torch.distributions.Categoricalreferences. They cover both masked distribution classes, two padding sentinels, finite/infinite masking values, float32/float64, two batch dimensions and mixed padded/unpadded rows. Separate zero-probability tests include dense controls.Validation
8f92a50: 18 new cases fail, 2 dense controls pass.torch.compile(backend="eager", fullgraph=True)entropy and gradient comparisons against the independent reference.pre-commit run --all-filespasses;git diff --checkpasses. The Windows symlink placeholder forAGENTS.mdwas normalized by the EOF hook during the initial run and restored afterward; it is not part of this change.Issue #4512 was assigned to AHMETHAKANBEZIR1 through the repository's
/assignworkflow before implementation. Prepared with Codex assistance; the reproductions, independent reference/gradient checks, compile checks and lint checks were run locally, and Codex is recorded as co-author.