-
Notifications
You must be signed in to change notification settings - Fork 363
Simplify pass manager debug system #3530
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
Merged
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/pass_manager.py 2025-05-22 18:46:05.781604+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/pass_manager.py 2025-05-22 18:46:29.397584+00:00
@@ -31,11 +31,11 @@
Callable[
[torch.fx.GraphModule, CompilationSettings], torch.fx.GraphModule
]
]
] = None,
- constraints: Optional[List[Callable]] = None
+ constraints: Optional[List[Callable]] = None,
):
super().__init__(passes, constraints)
@classmethod
def build_from_passlist(
@@ -66,11 +66,11 @@
def remove_pass_with_index(self, index: int) -> None:
del self.passes[index]
def insert_debug_pass_before(
- self, passes: List[str], output_path_prefix: str=tempfile.gettempdir()
+ self, passes: List[str], output_path_prefix: str = tempfile.gettempdir()
) -> None:
"""Insert debug passes in the PassManager pass sequence prior to the execution of a particular pass.
Args:
passes: List of pass names to insert debug passes before
@@ -80,18 +80,22 @@
in the pass sequence.
"""
new_pass_list = []
for ps in self.passes:
if ps.__name__ in passes:
- new_pass_list.append(_generate_draw_fx_graph_pass(output_path_prefix, f"before_{ps.__name__}"))
+ new_pass_list.append(
+ _generate_draw_fx_graph_pass(
+ output_path_prefix, f"before_{ps.__name__}"
+ )
+ )
new_pass_list.append(ps)
self.passes = new_pass_list
self._validated = False
def insert_debug_pass_after(
- self, passes: List[str], output_path_prefix: str=tempfile.gettempdir()
+ self, passes: List[str], output_path_prefix: str = tempfile.gettempdir()
) -> None:
"""Insert debug passes in the PassManager pass sequence after the execution of a particular pass.
Args:
passes: List of pass names to insert debug passes after
@@ -102,12 +106,15 @@
"""
new_pass_list = []
for ps in self.passes:
new_pass_list.append(ps)
if ps.__name__ in passes:
- new_pass_list.append(_generate_draw_fx_graph_pass(output_path_prefix, f"after_{ps.__name__}"))
-
+ new_pass_list.append(
+ _generate_draw_fx_graph_pass(
+ output_path_prefix, f"after_{ps.__name__}"
+ )
+ )
self.passes = new_pass_list
self._validated = False
def __call__(self, gm: Any, settings: CompilationSettings) -> Any:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/pass_manager.py 2025-05-22 18:46:09.557792+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/pass_manager.py 2025-05-22 18:46:31.279116+00:00
@@ -31,11 +31,11 @@
Callable[
[torch.fx.GraphModule, CompilationSettings], torch.fx.GraphModule
]
]
] = None,
- constraints: Optional[List[Callable]] = None
+ constraints: Optional[List[Callable]] = None,
):
super().__init__(passes, constraints)
@classmethod
def build_from_passlist(
@@ -66,11 +66,11 @@
def remove_pass_with_index(self, index: int) -> None:
del self.passes[index]
def insert_debug_pass_before(
- self, passes: List[str], output_path_prefix: str=tempfile.gettempdir()
+ self, passes: List[str], output_path_prefix: str = tempfile.gettempdir()
) -> None:
"""Insert debug passes in the PassManager pass sequence prior to the execution of a particular pass.
Args:
passes: List of pass names to insert debug passes before
@@ -80,18 +80,22 @@
in the pass sequence.
"""
new_pass_list = []
for ps in self.passes:
if ps.__name__ in passes:
- new_pass_list.append(_generate_draw_fx_graph_pass(output_path_prefix, f"before_{ps.__name__}"))
+ new_pass_list.append(
+ _generate_draw_fx_graph_pass(
+ output_path_prefix, f"before_{ps.__name__}"
+ )
+ )
new_pass_list.append(ps)
self.passes = new_pass_list
self._validated = False
def insert_debug_pass_after(
- self, passes: List[str], output_path_prefix: str=tempfile.gettempdir()
+ self, passes: List[str], output_path_prefix: str = tempfile.gettempdir()
) -> None:
"""Insert debug passes in the PassManager pass sequence after the execution of a particular pass.
Args:
passes: List of pass names to insert debug passes after
@@ -102,12 +106,15 @@
"""
new_pass_list = []
for ps in self.passes:
new_pass_list.append(ps)
if ps.__name__ in passes:
- new_pass_list.append(_generate_draw_fx_graph_pass(output_path_prefix, f"after_{ps.__name__}"))
-
+ new_pass_list.append(
+ _generate_draw_fx_graph_pass(
+ output_path_prefix, f"after_{ps.__name__}"
+ )
+ )
self.passes = new_pass_list
self._validated = False
def __call__(self, gm: Any, settings: CompilationSettings) -> Any:
cehongwang
approved these changes
May 23, 2025
cehongwang
pushed a commit
that referenced
this pull request
Jun 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cla signed
component: api [Python]
Issues re: Python API
component: dynamo
Issues relating to the `torch.compile` or `torch._dynamo.export` paths
component: lowering
Issues re: The lowering / preprocessing passes
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.
Description
Reduces the amount of hardcoding in the debug pass.
Example use:
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: