Skip to content

[BugFix] Handle invalid masked categorical values - #4754

Open
pradeep-ramola wants to merge 1 commit into
pytorch:mainfrom
pradeep-ramola:fix/masked-categorical-bounds
Open

pradeep-ramola wants to merge 1 commit into
pytorch:mainfrom
pradeep-ramola:fix/masked-categorical-bounds

Conversation

@pradeep-ramola

Copy link
Copy Markdown

Fixes #4752

Summary

  • prevent masked Categorical.is_in() from indexing the mask with out-of-range values
  • clamp masked projections before mask lookup and preserve the spec dtype when resampling
  • add regression coverage for out-of-range membership and masked int32 projection

Testing

  • python -m compileall -q torchrl/data/tensor_specs.py test/test_specs.py
  • git diff --check
  • Attempted: python -m pytest test/test_specs.py -k masked_categorical_project_and_is_in_handle_out_of_bounds -q
    • Could not start because this Windows environment does not have the torch package installed (ModuleNotFoundError: No module named 'torch').

@pytorch-bot

pytorch-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 16 Awaiting Approval

As of commit a6f6cff with merge base df1db3d (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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

@meta-cla meta-cla 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 Nov 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugFix 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.

[BUG] Masked Categorical spec: is_in / project crash on out-of-range values

1 participant