[inductor] [cpp] fix the input contiguous check in max-autotune#135561
Merged
kit1980 merged 1 commit intopytorch:release/2.5from Sep 20, 2024
Merged
[inductor] [cpp] fix the input contiguous check in max-autotune#135561kit1980 merged 1 commit intopytorch:release/2.5from
kit1980 merged 1 commit intopytorch:release/2.5from
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/135561
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit d6c6981 with merge base b7eb725 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Collaborator
Author
|
Other PRs submitted to release/2.5 also meet the same CI failure. |
Collaborator
Author
|
@pytorchbot rebase |
Collaborator
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
Collaborator
|
Successfully rebased |
f09b719 to
404abcb
Compare
kit1980
approved these changes
Sep 20, 2024
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.
Cherry-pick #134982 to the release/2.5 branch.
This is a critical correctness issue fix for inductor max-autotune on CPU, which is a new prototype feature that will be introduced in the PyTorch 2.5 release.
Description
Fixes the FP32 accuracy failure of
resmlp_12_224and BF16 accuracy failure ofvolo_d1_224in timm.In this PR, we check whether input is contiguous using the following way: If it has
FixedLayout, we know the accurate strides. ForFlexibleLayout, if its data is aComputedBuffer, we could get the fill order of the buffer to decide whether it's contiguous. For the other cases, we won't use GEMM template as we can't infer whether it's contiguous.Additional context
The current GEMM template only supports this case:
input.get_stride()[-1] == 1. Inresmlp_12_224, when we run into this check, the layout ofinputis aFlexibleLayout. The reason is that when realizing the input which is aViewIR, theconvert_to_reinterpret_viewcall fails:pytorch/torch/_inductor/ir.py
Lines 4712 to 4715 in d14fe3f
And it finally runs into this
copy_inputand returns aFlexibleLayout.pytorch/torch/_inductor/ir.py
Line 4722 in d14fe3f
When checking its stride, this
FlexibleLayoutindeed satisfiesinput.get_stride()[-1] == 1but it is later decided as aFixedLayoutwithsize = (3072, 196), stride = (1, 3072), which is not supported by the GEMM template, thus causing accuracy issue in this model. TheFlexibleLayoutis converted toFixedLayoutduring CppPackedGemmTemplate.add_choices which calls slice_nd when rendering the kernel (slice_nd(X)). When creating theSliceViewIR, as_storage_and_layout invokes decide_layout and converts it to aFixedLayoutwithsize = (3072, 196), stride = (1, 3072).Pull Request resolved: #134982
Approved by: https://github.com/jgong5, https://github.com/leslie-fang-intel, https://github.com/jansel
cc @XilunWu @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @rec @LucasLLC @MeetVadakkanchery @mhorowitz @pradeepfn