Fix compiled negative-strided slice updates#3735
Closed
chrismicah wants to merge 1 commit into
Closed
Conversation
Contributor
Author
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.
Summary
Fix compiled slice updates when a negative-strided input is used by an
elementwise expression assigned into a negative-strided output slice.
Details
Issue #3716 reports that
mx.compilecan write only one element for patternslike:
The compiled Metal kernel used unsigned index math for 1D strided kernels. When
the collapsed stride is negative, the input location wraps instead of walking
backward. This change selects the large-index strided kernel path whenever a
compiled kernel has negative strides, and lets the 1D strided index helper use
the selected signed index type.
Tests
CMAKE_BUILD_PARALLEL_LEVEL=8 python setup.py build_ext --inplace PYTHONPATH=python python -m pytest python/tests/test_compile.py -q -k negative_strided_slice_update_expr --tb=short PYTHONPATH=python python -m pytest python/tests/test_compile.py -q -k 'negative_strided_slice_update_expr or compile_nonfinite_constants or tuple_output_in_thread' --tb=short git diff --checkI also ran a direct CPU/GPU eager-vs-compiled repro for both
+=and=negative-strided update forms.
Fixes #3716