Repository navigation
torch pth: reject tensor shapes whose element count overflows - #4322
Merged
Merged
Conversation
This was referenced Nov 21, 2026
ashhart
force-pushed
the
lead/torch-pth-overflow
branch
from
November 21, 2026 19:01
4e42a01 to
d436d60
Compare
ashhart
added a commit
that referenced
this pull request
Nov 22, 2026
Unreleased: the five (#N) placeholders get their PR numbers, the two (#PR) duplicates go, #3192's line goes (#4427 replaced that behaviour on main and its line refs #3192), #3960 is named as the PR that landed #2799, and the penalty under --instruct-sampling card; ?token= Web addresses and pull's digest and size checks). Sixteen PRs merged 20-21 Nov with no line anywhere: a blank lines file replaced each PR's own line at landing. #4321 and #4322 go under Unreleased, the twelve that shipped in 1.3.3 under 1.3.3, and the two 1.3.1 lines that carried no PR number get #3941 and #4022. docs/environment.md: Flash Next checks 37 settings, and TF_GLM_INDEX_SPLIT (registered by #4510) gets its row.
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.
Torch
.pthcheckpoints: a tensor shape whose element count overflowsu64now returnsBadArchiveinstead of panicking (Debug) or wrapping (release).Both readers,
readRawandreadF32, now multiply the dimensions with checkedu64arithmetic. A count of exactly2^64 - 1is still representable;2^64and above is refused. Zero dimensions and every valid shape keep their existing arithmetic and stride checks, and the storage-size multiplication was already checked.Test:
zig build test-torch-pth-overflow-hostreads a contiguous[2^32, 2^32]tensor through both readers. On main it panics with integer overflow; here both return the archive error.