Skip to content

Temporary fix to workaround the mutable decomposition error. #3636

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 4 commits into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion py/torch_tensorrt/dynamo/runtime/_MutableTorchTensorRTModule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inspect
import logging
import warnings
from copy import deepcopy
from enum import Enum, auto
from typing import Any, Dict, Iterator, Optional, Set, Union
Expand Down Expand Up @@ -476,6 +477,12 @@ def _process_kwarg_inputs(inputs: Any) -> Any:
)

def forward(self, *args: Any, **kwargs: Any) -> Any:
warnings.warn(
"Direct calls to {self.__class__}.forward() are currently broken by due to https://github.com/pytorch/pytorch/issues/157183. Either call {self.__class__}(...) directly or use {self.__class__}._forward as a work around"
)
return self._forward(*args, **kwargs)

def _forward(self, *args: Any, **kwargs: Any) -> Any:
# Step 1: Check whether the input shape has changed
kwargs = MutableTorchTensorRTModule._process_kwarg_inputs(kwargs)
self._validate_inputs(*args, **kwargs)
Expand Down Expand Up @@ -535,7 +542,9 @@ def __deepcopy__(self, memo: Any) -> Any:
return result

def __call__(self, *args: Any, **kwargs: Any) -> Any:
return self.forward(*args, **kwargs)
# Due to https://github.com/pytorch/pytorch/issues/157183, we cannot use forward call, use _forward as a workaround.
# This is a temporary fix.
return self._forward(*args, **kwargs)

def __getattr__(self, name: str) -> Any:
if name in self.__dict__:
Expand Down
Loading