When _shuffled_index and __getitem__ receive NumPy integer scalars, divmod propagates the NumPy types. Downstream modulo operations like (seed + epoch) % 2**32 can then fail with OverflowError: Python integer 4294967296 out of bounds for int32 if the scalar is np.int32 (or narrower) because Python delegates to the NumPy ufunc which attempts to coerce 2**32 into the scalar's precision.#1366
Open
copybara-service[bot] wants to merge 1 commit into
Open
When _shuffled_index and __getitem__ receive NumPy integer scalars, divmod propagates the NumPy types. Downstream modulo operations like (seed + epoch) % 2**32 can then fail with OverflowError: Python integer 4294967296 out of bounds for int32 if the scalar is np.int32 (or narrower) because Python delegates to the NumPy ufunc which attempts to coerce 2**32 into the scalar's precision.#1366copybara-service[bot] wants to merge 1 commit into
_shuffled_index and __getitem__ receive NumPy integer scalars, divmod propagates the NumPy types. Downstream modulo operations like (seed + epoch) % 2**32 can then fail with OverflowError: Python integer 4294967296 out of bounds for int32 if the scalar is np.int32 (or narrower) because Python delegates to the NumPy ufunc which attempts to coerce 2**32 into the scalar's precision.#1366copybara-service[bot] wants to merge 1 commit into
Conversation
…s, `divmod` propagates the NumPy types. Downstream modulo operations like `(seed + epoch) % 2**32` can then fail with `OverflowError: Python integer 4294967296 out of bounds for int32` if the scalar is `np.int32` (or narrower) because Python delegates to the NumPy ufunc which attempts to coerce `2**32` into the scalar's precision. By casting the input index to `int` early in `ShuffleMapDataset._shuffled_index`, `WindowShuffleMapDataset._shuffled_index`, `MixedMapDataset.__getitem__`, and `_ConcatSelectionMap.__getitem__`, we ensure downstream operations remain Python integers, guarding against unexpected overflows regardless of caller inputs. PiperOrigin-RevId: 952392989
copybara-service
Bot
force-pushed
the
test_952392989
branch
from
July 22, 2026 23:38
e607477 to
3859c90
Compare
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.
When
_shuffled_indexand__getitem__receive NumPy integer scalars,divmodpropagates the NumPy types. Downstream modulo operations like(seed + epoch) % 2**32can then fail withOverflowError: Python integer 4294967296 out of bounds for int32if the scalar isnp.int32(or narrower) because Python delegates to the NumPy ufunc which attempts to coerce2**32into the scalar's precision.By casting the input index to
intearly inShuffleMapDataset._shuffled_index,WindowShuffleMapDataset._shuffled_index,MixedMapDataset.__getitem__, and_ConcatSelectionMap.__getitem__, we ensure downstream operations remainPython integers, guarding against unexpected overflows regardless of caller inputs.