Skip to content
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

Module 'SABlock' has no attribute 'causal_mask' #7936

Closed
KumoLiu opened this issue Jul 22, 2024 · 1 comment · Fixed by #7937
Closed

Module 'SABlock' has no attribute 'causal_mask' #7936

KumoLiu opened this issue Jul 22, 2024 · 1 comment · Fixed by #7937
Labels
bug Something isn't working

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Jul 22, 2024

[2024-07-20T23:15:47.067Z] ======================================================================
[2024-07-20T23:15:47.067Z] ERROR: test_script_00 (tests.test_vit.TestViT)
[2024-07-20T23:15:47.067Z] ----------------------------------------------------------------------
[2024-07-20T23:15:47.067Z] Traceback (most recent call last):
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/parameterized/parameterized.py", line 620, in standalone_func
[2024-07-20T23:15:47.067Z]     return func(*(a + p.args), **p.kwargs, **kw)
[2024-07-20T23:15:47.067Z]   File "/home/jenkins/agent/workspace/Monai-latest-image/tests/test_vit.py", line 114, in test_script
[2024-07-20T23:15:47.067Z]     torch.jit.script(net)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 1338, in script
[2024-07-20T23:15:47.067Z]     return torch.jit._recursive.create_script_module(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 558, in create_script_module
[2024-07-20T23:15:47.067Z]     return create_script_module_impl(nn_module, concrete_type, stubs_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 631, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 647, in _construct
[2024-07-20T23:15:47.067Z]     init_fn(script_module)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 607, in init_fn
[2024-07-20T23:15:47.067Z]     scripted = create_script_module_impl(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 631, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 647, in _construct
[2024-07-20T23:15:47.067Z]     init_fn(script_module)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 607, in init_fn
[2024-07-20T23:15:47.067Z]     scripted = create_script_module_impl(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 631, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 647, in _construct
[2024-07-20T23:15:47.067Z]     init_fn(script_module)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 607, in init_fn
[2024-07-20T23:15:47.067Z]     scripted = create_script_module_impl(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 635, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     create_methods_and_properties_from_stubs(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 467, in create_methods_and_properties_from_stubs
[2024-07-20T23:15:47.067Z]     concrete_type._create_methods_and_properties(
[2024-07-20T23:15:47.067Z] RuntimeError: 
[2024-07-20T23:15:47.067Z] Module 'SABlock' has no attribute 'causal_mask' :
[2024-07-20T23:15:47.067Z]   File "/home/jenkins/agent/workspace/Monai-latest-image/monai/networks/blocks/selfattention.py", line 137
[2024-07-20T23:15:47.067Z]     
[2024-07-20T23:15:47.067Z]         if self.causal:
[2024-07-20T23:15:47.067Z]             att_mat = att_mat.masked_fill(self.causal_mask[:, :, : x.shape[1], : x.shape[1]] == 0, float("-inf"))
[2024-07-20T23:15:47.067Z]                                           ~~~~~~~~~~~~~~~~ <--- HERE
[2024-07-20T23:15:47.067Z]     
[2024-07-20T23:15:47.067Z]         att_mat = att_mat.softmax(dim=-1)
[2024-07-20T23:15:47.067Z] 
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Jul 22, 2024

[2024-07-20T23:15:47.067Z] ======================================================================
[2024-07-20T23:15:47.067Z] ERROR: test_script_01 (tests.test_vit.TestViT)
[2024-07-20T23:15:47.067Z] ----------------------------------------------------------------------
[2024-07-20T23:15:47.067Z] Traceback (most recent call last):
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/parameterized/parameterized.py", line 620, in standalone_func
[2024-07-20T23:15:47.067Z]     return func(*(a + p.args), **p.kwargs, **kw)
[2024-07-20T23:15:47.067Z]   File "/home/jenkins/agent/workspace/Monai-latest-image/tests/test_vit.py", line 114, in test_script
[2024-07-20T23:15:47.067Z]     torch.jit.script(net)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 1338, in script
[2024-07-20T23:15:47.067Z]     return torch.jit._recursive.create_script_module(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 558, in create_script_module
[2024-07-20T23:15:47.067Z]     return create_script_module_impl(nn_module, concrete_type, stubs_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 631, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 647, in _construct
[2024-07-20T23:15:47.067Z]     init_fn(script_module)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 607, in init_fn
[2024-07-20T23:15:47.067Z]     scripted = create_script_module_impl(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 631, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 647, in _construct
[2024-07-20T23:15:47.067Z]     init_fn(script_module)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 607, in init_fn
[2024-07-20T23:15:47.067Z]     scripted = create_script_module_impl(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 631, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_script.py", line 647, in _construct
[2024-07-20T23:15:47.067Z]     init_fn(script_module)
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 607, in init_fn
[2024-07-20T23:15:47.067Z]     scripted = create_script_module_impl(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 635, in create_script_module_impl
[2024-07-20T23:15:47.067Z]     create_methods_and_properties_from_stubs(
[2024-07-20T23:15:47.067Z]   File "/usr/local/lib/python3.10/dist-packages/torch/jit/_recursive.py", line 467, in create_methods_and_properties_from_stubs
[2024-07-20T23:15:47.067Z]     concrete_type._create_methods_and_properties(
[2024-07-20T23:15:47.067Z] RuntimeError: Can't redefine method: forward on class: __torch__.monai.networks.blocks.selfattention.SABlock (of Python compilation unit at: 0x55ced5d1e180)

@KumoLiu KumoLiu added the bug Something isn't working label Jul 22, 2024
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Jul 22, 2024
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant