Repository navigation
Check dim order in the optimized mm and bmm as the portable ones do - #22355
Merged
JakeStevens merged 1 commit intoSep 10, 2026
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22355
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit 1249f01 with merge base 60cb889 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following job failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
Author
|
@pytorchbot label "release notes: ops & kernels" |
JakeStevens
approved these changes
Sep 10, 2026
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
Follow-up to #21866, which did the same for the optimized
layer_norm.opt_mm_outandopt_bmm_outcarry no dim order check, while portablemm_outandbmm_outeach carry two:The shared
check_mm_argsandcheck_bmm_argsdo not supply them either, so choosing the optimized kernels quietly drops a check the portable path enforces.opt_mm_outpasses raw data pointers tocpublas::gemmwith the leading dimensions taken from sizes rather than strides, which describes a row-major matrix only in the default dim order.opt_bmm_outdoes the same per batch. Thus, the arithmetic also needs it.This PR adds portable guards to both the kernels, placed in the same position relative to the resize.
Not reachable from export today, in the same way the
select_scatterhalf of #21915 was not, since_get_channels_last_dim_orderraises for any rank other than 4 and so a 2Dmmor 3Dbmminput cannot be given a non-default dim order. It is still worth adding because the optimized kernels are currently less strict than the portable ones with nothing recording that as intentional, and because #16429 asks for these layouts to be supported, at which point the optimized path would return wrong numbers where the portable path errors.Test plan
A
NonDefaultDimOrderDiesper op.op_mm_test.cppandop_bmm_test.cppare both in_optimized_kernels_test_sources, so the same test body runs against both kernel sets, which makes the gap visible directly:optimized_kernels_testoptimized_kernels_testportable_kernels_testAll three tensors in each test share the same non-default dim order, so the same dim order check passes and only the default dim order check can reject. Both skip under
is_aten.cc @larryliu0820 @manuelcandales @JakeStevens