-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
[Fix] [torch.compile] Improve UUID system for custom passes #15249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
robertgshaw2-redhat
merged 5 commits into
vllm-project:main
from
neuralmagic:luka/pass-manager-uuid-fix
Mar 24, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e8b240
Removed pickling in 2.6 and improved robustness of UUID system while …
ProExpertProg bb23aec
Fix redef
ProExpertProg 7ec2665
Use importlib for __version__
ProExpertProg 46b00cf
extract CustomGraphPass
ProExpertProg 0d3feb1
formatting
ProExpertProg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from abc import ABC, abstractmethod | ||
| from typing import Any, Optional | ||
|
|
||
| import torch | ||
|
|
||
|
|
||
| class Torch25CustomGraphPass(ABC): # noqa (redefinition) | ||
| """ | ||
| This class replaces CustomGraphPass from torch==2.6 when using torch<2.6. | ||
| It conforms to the 2.6 interface but also supports pickling, as that's what | ||
| the inductor code cache uses to determine the cache key before 2.6. | ||
| (in 2.6 and above, uuid() is used.) | ||
|
|
||
| Subclasses can just "pretend" that uuid is used. | ||
| """ | ||
|
|
||
| @abstractmethod | ||
| def __call__(self, graph: torch.fx.graph.Graph) -> None: | ||
| """ | ||
| Implementation of the custom pass. | ||
| """ | ||
|
|
||
| @abstractmethod | ||
| def uuid(self) -> Optional[Any]: | ||
| """ | ||
| Return an ID to uniquely identify your custom pass implementation. | ||
| Return None to skip inductor code caching entirely. | ||
| """ | ||
|
|
||
| def __getstate__(self): | ||
| """ | ||
| Pickling is used instead of uuid() in torch<2.6. Just return uuid() | ||
| to enable subclasses to only have to implement uuid. | ||
| """ | ||
| return self.uuid() | ||
|
|
||
| def __setstate__(self, state): | ||
| raise ValueError("Cannot unpickle CustomGraphPass because pickling" | ||
| " is used for cache key uuid. Use torch>=2.6 with" | ||
| " native uuid support for custom passes.") |
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
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.
Uh oh!
There was an error while loading. Please reload this page.