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

object has no attribute scaled_dot_product_attention #8012

Closed
KumoLiu opened this issue Aug 13, 2024 · 0 comments · Fixed by #8013
Closed

object has no attribute scaled_dot_product_attention #8012

KumoLiu opened this issue Aug 13, 2024 · 0 comments · Fixed by #8013

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 13, 2024

[2024-08-12T23:01:55.672Z] ======================================================================
[2024-08-12T23:01:55.672Z] ERROR: test_script_0 (tests.test_vit.TestViT)
[2024-08-12T23:01:55.672Z] ----------------------------------------------------------------------
[2024-08-12T23:01:55.672Z] Traceback (most recent call last):
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/parameterized/parameterized.py", line 620, in standalone_func
[2024-08-12T23:01:55.672Z]     return func(*(a + p.args), **p.kwargs, **kw)
[2024-08-12T23:01:55.672Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/tests/test_vit.py", line 114, in test_script
[2024-08-12T23:01:55.672Z]     torch.jit.script(net)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_script.py", line 1257, in script
[2024-08-12T23:01:55.672Z]     return torch.jit._recursive.create_script_module(
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 451, in create_script_module
[2024-08-12T23:01:55.672Z]     return create_script_module_impl(nn_module, concrete_type, stubs_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 513, in create_script_module_impl
[2024-08-12T23:01:55.672Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_script.py", line 587, in _construct
[2024-08-12T23:01:55.672Z]     init_fn(script_module)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 491, in init_fn
[2024-08-12T23:01:55.672Z]     scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 513, in create_script_module_impl
[2024-08-12T23:01:55.672Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_script.py", line 587, in _construct
[2024-08-12T23:01:55.672Z]     init_fn(script_module)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 491, in init_fn
[2024-08-12T23:01:55.672Z]     scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 513, in create_script_module_impl
[2024-08-12T23:01:55.672Z]     script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_script.py", line 587, in _construct
[2024-08-12T23:01:55.672Z]     init_fn(script_module)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 491, in init_fn
[2024-08-12T23:01:55.672Z]     scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 517, in create_script_module_impl
[2024-08-12T23:01:55.672Z]     create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
[2024-08-12T23:01:55.672Z]   File "/usr/local/lib/python3.9/dist-packages/torch/jit/_recursive.py", line 368, in create_methods_and_properties_from_stubs
[2024-08-12T23:01:55.672Z]     concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
[2024-08-12T23:01:55.672Z] RuntimeError: 
[2024-08-12T23:01:55.672Z] object has no attribute scaled_dot_product_attention:
[2024-08-12T23:01:55.672Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/networks/blocks/selfattention.py", line 178
[2024-08-12T23:01:55.672Z]     
[2024-08-12T23:01:55.672Z]         if self.use_flash_attention:
[2024-08-12T23:01:55.672Z]             x = F.scaled_dot_product_attention(
[2024-08-12T23:01:55.672Z]                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
[2024-08-12T23:01:55.672Z]                 query=q, key=k, value=v, scale=self.scale, dropout_p=self.dropout_rate, is_causal=self.causal
[2024-08-12T23:01:55.672Z]             )
[2024-08-12T23:01:55.672Z] 
[2024-08-12T23:01:55.672Z] 
[2024-08-12T23:01:55.672Z] ----------------------------------------------------------------------
[2024-08-12T23:01:55.672Z] Ran 15743 tests in 1891.161s
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue Aug 13, 2024
Signed-off-by: YunLiu <[email protected]>
@KumoLiu KumoLiu mentioned this issue Aug 13, 2024
7 tasks
rcremese pushed a commit to rcremese/MONAI that referenced this issue Sep 2, 2024
Fixes Project-MONAI#8012


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant