You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the Bug
I camp up with the following issue when using torch.fx and apex.amp together.
If a model has torch.matul operations and uses apex.amp (opt_level=O1) for mixed precision optimization, then fx will fail to recompile the model graph and will report the following error:
File "/xxxxxxxxxxxxx/dist-packages/torch/fx/node.py", line 40, in _find_module_of_method
raise RuntimeError(f'cannot find module for {orig_method}, {name}')
RuntimeError: cannot find module for <built-in method matmul of type object at 0x7f6c5fd9fe40>
Minimal Steps/Code to Reproduce the Bug
The following toy module with torch.matmul can reproduce the error.
importtorchfromtorchimportfxclassToyMod(torch.nn.Module):
def__init__(self, in_features=768, out_features=768):
super().__init__()
self.linear=torch.nn.Linear(in_features=in_features, out_features=out_features)
defforward(self, X, other):
result=torch.matmul(self.linear(input=X), other)
returnresultdeftest():
fromapeximportampmod=ToyMod().cuda()
optimizer=torch.optim.SGD(mod.parameters(), lr=1e-3)
# Allow Amp to perform casts as required by the opt_levelmodel, optimizer=amp.initialize(mod, optimizer, opt_level="O1")
graph : fx.Graph=fx.Tracer().trace(model)
fornodeingraph.nodes:
# do somethingpassgraph.lint()
returnfx.GraphModule(model, graph)
Expected Behavior
Environment
PyTorch version: 1.10.0
CUDA used to build PyTorch: 11.3
Python version: 3.7.3
Is CUDA available: True
CUDA runtime version: 11.3.109
Describe the Bug
I camp up with the following issue when using
torch.fx
and apex.amp together.If a model has
torch.matul
operations and usesapex.amp (opt_level=O1)
for mixed precision optimization, then fx will fail to recompile the model graph and will report the following error:Minimal Steps/Code to Reproduce the Bug
The following toy module with
torch.matmul
can reproduce the error.Expected Behavior
Environment
PyTorch version: 1.10.0
CUDA used to build PyTorch: 11.3
Python version: 3.7.3
Is CUDA available: True
CUDA runtime version: 11.3.109
[pip3] numpy==1.21.5
[pip3] torch==1.10.0
[pip3] torchaudio==0.10.0+cu113
[pip3] torchvision==0.11.1+cu113
apex: Version 0.1
The text was updated successfully, but these errors were encountered: