Skip to content

Conversation

@abdulwahabahmedkhanyusufzai

This PR fixes an AttributeError crash encountered when using is_positive_integer with Numpy types (e.g., np.int64) or on Python 3.11+ where certain types lack the .is_integer() method.

This supersedes stale PRs #903 and #930. I have consolidated the fix and added the missing unit tests requested by maintainers.

Changes:

Implemented a safe is_integer_value helper that handles int, float, and numpy types correctly.

Added tests/rl/rl_utils_test.py to verify the fix across all types.

Related Issues:

Fixes #953

Resolves #903

Resolves #902

Test Plan
Created a new test file tests/rl/rl_utils_test.py. Verified locally with python3 -m unittest tests/rl/rl_utils_test.py.

Results:

✅ int (Standard) - Passed

✅ np.int64 (Numpy) - Passed (Previously crashed)

✅ float (Standard) - Passed

✅ bool - Rejected correctly

@abdulwahabahmedkhanyusufzai
Copy link
Author

Hi @abheesht17. This PR resolves the AttributeError in is_positive_integer which is currently breaking compatibility for Python 3.11+ and NumPy users (Fixes #953).

I've consolidated the previous work from #903 and #930 and added full unit tests. Could you please approve the workflows so the CI can verify the fix? Thanks!

@cats256
Copy link

cats256 commented Jan 28, 2026

Just a note for maintainers, AI-generated pull requests (code + responses) with a clear lack of efforts have become a very prevalent issue with PyTorch and it appears this has spread to other open-source projects

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: RLOO (REINFORCE Leave-One-Out) Advantage Estimator RL utils.py has an incorrect check for is_positive_integer

2 participants