Skip to content

Fix duplicate pattern error#139321

Closed
eellison wants to merge 7 commits into
gh/eellison/716/basefrom
gh/eellison/716/head
Closed

Fix duplicate pattern error#139321
eellison wants to merge 7 commits into
gh/eellison/716/basefrom
gh/eellison/716/head

Conversation

@eellison

@eellison eellison commented Oct 30, 2024

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

vllm had an error when we were incorrectly stating two patterns are duplicates. See, comment inline:

For a particular generated pattern repr, store all the equivalent graphs that used to generate them. Because we ignore certain patterns in searching, but not in matching, use the graph to distinguish if two equivalent searches are actually different.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov

…rch patterns but different match

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Oct 30, 2024

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139321

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 6a86ef7 with merge base cf76c05 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

eellison added a commit that referenced this pull request Oct 30, 2024
…rch patterns but different match

ghstack-source-id: b9efb7f
Pull Request resolved: #139321
@eellison eellison changed the title Fix incorrect duplicate pattern on patterns which have equivalent search patterns but different match Fix duplicate pattern error for patterns with different match graphs Oct 30, 2024
@eellison eellison changed the title Fix duplicate pattern error for patterns with different match graphs Fix duplicate pattern error Oct 30, 2024
@ProExpertProg

Copy link
Copy Markdown

Any reason _seen_patterns is not a property of PatternMatcherPass? Running into some weird lifetime semantics because a pattern can only be registered once.

@eellison

eellison commented Nov 1, 2024

Copy link
Copy Markdown
Contributor Author

@ProExpertProg yes, agreed, they could be scoped to a pass. will update

vllm had an error when we were incorrectly stating two patterns are duplicates. See, comment inline:

For a particular generated pattern repr, store all the equivalent graphs that used to generate them. Because we ignore certain patterns in searching, but not in matching, use the graph to distinguish if two equivalent searches are actually different. Element are first inserted as graphs and lazily converted to their str reprs when there is a duplicate. If the graph is not present we will error on duplicate.


cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
eellison added a commit that referenced this pull request Nov 13, 2024
…rch patterns but different match

ghstack-source-id: 49a8bb8
Pull Request resolved: #139321
@eellison eellison added the topic: not user facing topic category label Dec 26, 2024
@eellison

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Rebase failed due to Command git -C /home/runner/work/pytorch/pytorch rebase refs/remotes/origin/viable/strict gh/eellison/716/orig returned non-zero exit code 1

Rebasing (1/1)
Auto-merging test/inductor/test_pattern_matcher.py
Auto-merging torch/_inductor/pattern_matcher.py
CONFLICT (content): Merge conflict in torch/_inductor/pattern_matcher.py
error: could not apply 2071620ae60... Fix incorrect duplicate pattern on patterns which have equivalent search patterns but different match
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Could not apply 2071620ae60... Fix incorrect duplicate pattern on patterns which have equivalent search patterns but different match

Raised by https://github.com/pytorch/pytorch/actions/runs/12507427410

[ghstack-poisoned]

@shunting314 shunting314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the PR change the duplication check from

  • check string representation of pattern
    to
  • check string representation of the fx graph generating the pattern
    ?

My questions is, why two patterns with the same string representation could be generated by different fx graphs (in the vllm case). Due to Ignored() pattern?

Comment thread torch/_inductor/pattern_matcher.py Outdated
[ghstack-poisoned]
@eellison

eellison commented Dec 26, 2024

Copy link
Copy Markdown
Contributor Author

@shunting314 yes, due to Ignored. The actual search graph is the same but the underlying pattern is different.

[ghstack-poisoned]
Comment thread test/inductor/test_pattern_matcher.py Outdated
return x - 2

patterns = PatternMatcherPass()
torch.set_default_device("cuda")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that potentially affect other tests in a very weird ways? Shouldn't one better use with torch.device("cuda"): or just alloc next tensor on the device you want?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @eellison can you help to fix the issue #143974 before re-land? Just use GPU_TYPE instead of "cuda" as #143975 do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malfet was reusing repro and forgot to update, agreed. although having said that - there are a few tests which use this pattern.. so if it is harmful, we should fix them.

galexite pushed a commit to graphcore/pytorch-fork that referenced this pull request Dec 30, 2024
vllm had an error when we were incorrectly stating two patterns are duplicates. See, comment inline:

For a particular generated pattern repr, store all the equivalent graphs that used to generate them. Because we ignore certain patterns in searching, but not in matching, use the graph to distinguish if two equivalent searches are actually different.

Pull Request resolved: pytorch#139321
Approved by: https://github.com/shunting314
pytorchmergebot added a commit that referenced this pull request Dec 31, 2024
…de in (#143975)"

This reverts commit 7c1c073.

Reverted #143975 on behalf of https://github.com/jeanschmidt due to Need to revert in order to be able to revert #139321 feel free to merge it back once conflicts are cleared ([comment](#143975 (comment)))
@jeanschmidt

Copy link
Copy Markdown
Contributor

@pytorchbot revert -m "breaking internal signals" -c ghfirst

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@eellison your PR has been successfully reverted.

pytorchmergebot added a commit that referenced this pull request Dec 31, 2024
This reverts commit 9e8d84f.

Reverted #139321 on behalf of https://github.com/jeanschmidt due to breaking internal signals ([comment](#139321 (comment)))
@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Dec 31, 2024
[ghstack-poisoned]
eellison added a commit that referenced this pull request Jan 6, 2025
…rch patterns but different match

ghstack-source-id: 3c883ef
Pull Request resolved: #139321
@eellison

eellison commented Jan 6, 2025

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

etaf added a commit that referenced this pull request Jan 9, 2025
…device-bias hard code in"


Re-land #143975. Fix "cuda" hard code in test_pattern_matcher.py introduced by #139321
Fix #143974

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
etaf added a commit that referenced this pull request Jan 9, 2025
… code in"


Re-land #143975. Fix "cuda" hard code in test_pattern_matcher.py introduced by #139321
Fix #143974

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
etaf added a commit that referenced this pull request Jan 9, 2025
…device-bias hard code in"


Re-land #143975. Fix "cuda" hard code in test_pattern_matcher.py introduced by #139321
Fix #143974

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
etaf added a commit that referenced this pull request Jan 9, 2025
… code in"


Re-land #143975. Fix "cuda" hard code in test_pattern_matcher.py introduced by #139321
Fix #143974

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Jan 10, 2025
…144456)

Re-land #143975. Fix "cuda" hard code in test_pattern_matcher.py introduced by #139321
Fix #143974

Pull Request resolved: #144456
Approved by: https://github.com/EikanWang, https://github.com/malfet, https://github.com/jansel
ghstack dependencies: #144457
@github-actions github-actions Bot deleted the gh/eellison/716/head branch February 9, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants