[FIX][Relax] Validate DeviceMesh cardinality without overflow - #20346
Open
ruiling-smartbear wants to merge 1 commit into
Open
ruiling-smartbear wants to merge 1 commit into
ruiling-smartbear wants to merge 1 commit into
Conversation
Share checked int64 shape multiplication across both constructors and validate ranges before generating device IDs. Preserve zero-dimension and empty-shape semantics.
ruiling-smartbear
force-pushed
the
fix/device-mesh-cardinality
branch
from
September 15, 2026 21:57
506c076 to
3c5b609
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.
Fixes #20272.
Use a checked 64-bit shape product in both
DeviceMeshconstructors. Reject negative dimensions and overflow without narrowing the device count. Validate constant Range bounds and cardinality before generating IDs, and avoid overflowing the final ID.Preserve empty-shape and zero-dimension product semantics. This does not change duplicate-ID policy.
Validation on Linux CPU / LLVM 16 (
cc0f9f07, pinned TVM FFI): the original code incorrectly accepted 10 invalid-cardinality cases; after this change the complete DTensor-type test file reports 25 passed. Coverage includes both constructors, ordinary mismatches, 32/64-bit overflow, negative/zero dimensions, nonconstant ranges, and large starting IDs. Large-shape cases use empty lists or short ranges, not large allocations.Changed-file pre-commit checks passed. No GPU tests run.