Repository navigation
Compute contiguity from the actual occupied data - #3475
Merged
Merged
Conversation
zcbenz
approved these changes
May 5, 2026
zcbenz
left a comment
Member
There was a problem hiding this comment.
This looks good to me, but I'm not sure about the negative stride part. @angeloskath
Member
Indeed the contiguous flag could in theory be set even with negative strides, however, the way we use it, it unfortunately cannot be. The contiguous flag would be used mostly for unary ops to select a fast path that doesn't care about indices. Starts at 0 and computes for data_size elements. However if there are negative strides, it should start at low and compute data_size elements. Anyway, clean improvement in the PR as you also said. |
maxjustus
added a commit
to maxjustus/resemble-enhance
that referenced
this pull request
Jul 4, 2026
MLX <= 0.31.2 miscomputes data_size for overlapping as_strided views (ml-explore/mlx#3475), causing occasional Metal page faults when the views feed rfft/einsum. mx.contiguous is numerically identity; no measurable perf change on the 5s enhance benchmark.
1 task done
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.
Proposed changes
Compute
AsStridedcontiguity from the actual occupied data instead of only checking row or column contiguous layouts.This allows dense non-row/column views, such as dense stride permutations, to be marked contiguous while keeping overlapping, gapped, broadcast-style, and negative-stride views conservative. It also computes a more accurate
data_sizeforas_stridedviews.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes