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

[AMD GPU] NotImplementedError: No operator found for memory_efficient_attention_forward with inputs #1175

Open
Looong01 opened this issue Dec 15, 2024 · 3 comments

Comments

@Looong01
Copy link

🐛 Bug

Traceback (most recent call last):
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/call_queue.py", line 74, in f
    res = list(func(*args, **kwargs))
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/call_queue.py", line 53, in f
    res = func(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/txt2img.py", line 109, in txt2img
    processed = processing.process_images(p)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/processing.py", line 847, in process_images
    res = process_images_inner(p)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/processing.py", line 988, in process_images_inner
    samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/processing.py", line 1362, in sample
    return self.sample_hr_pass(samples, decoded_samples, seeds, subseeds, subseed_strength, prompts)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/processing.py", line 1461, in sample_hr_pass
    decoded_samples = decode_latent_batch(self.sd_model, samples, target_device=devices.cpu, check_for_nans=True)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/processing.py", line 632, in decode_latent_batch
    sample = decode_first_stage(model, batch[i:i + 1])[0]
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/sd_samplers_common.py", line 76, in decode_first_stage
    return samples_to_images_tensor(x, approx_index, model)
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/sd_samplers_common.py", line 58, in samples_to_images_tensor
    x_sample = model.decode_first_stage(sample.to(model.first_stage_model.dtype))
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/sd_hijack_utils.py", line 22, in <lambda>
    setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
  File "/mnt/4T/Codes/stable-diffusion-webui/modules/sd_hijack_utils.py", line 36, in __call__
    return self.__orig_func(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 826, in decode_first_stage
    return self.first_stage_model.decode(z)
  File "/mnt/4T/Codes/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/autoencoder.py", line 90, in decode
    dec = self.decoder(z)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/diffusionmodules/model.py", line 631, in forward
    h = self.mid.attn_1(h)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
    return forward_call(*args, **kwargs)
  File "/mnt/4T/Codes/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/diffusionmodules/model.py", line 258, in forward
    out = xformers.ops.memory_efficient_attention(q, k, v, attn_bias=None, op=self.attention_op)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/xformers/ops/fmha/__init__.py", line 306, in memory_efficient_attention
    return _memory_efficient_attention(
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/xformers/ops/fmha/__init__.py", line 467, in _memory_efficient_attention
    return _memory_efficient_attention_forward(
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/xformers/ops/fmha/__init__.py", line 486, in _memory_efficient_attention_forward
    op = _dispatch_fw(inp, False)
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/xformers/ops/fmha/dispatch.py", line 135, in _dispatch_fw
    return _run_priority_list(
  File "/mnt/4T/Codes/stable-diffusion-webui/stable-diffusion-webui/lib/python3.10/site-packages/xformers/ops/fmha/dispatch.py", line 76, in _run_priority_list
    raise NotImplementedError(msg)
NotImplementedError: No operator found for `memory_efficient_attention_forward` with inputs:
     query       : shape=(1, 24576, 1, 512) (torch.float16)
     key         : shape=(1, 24576, 1, 512) (torch.float16)
     value       : shape=(1, 24576, 1, 512) (torch.float16)
     attn_bias   : <class 'NoneType'>
     p           : 0.0
`ckF` is not supported because:
    max(query.shape[-1], value.shape[-1]) > 256

Environment

Please copy and paste the output from the
environment collection script from PyTorch
(or fill out the checklist below manually).

You can run the script with:

python3.10 -m torch.
utils.collect_env
/usr/lib/python3.10/runpy.py:126: RuntimeWarning: 'torch.utils.collect_env' found in sys.modules after import of package 'torch.utils', but prior to execution of 'torch.utils.collect_env'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
Collecting environment information...
PyTorch version: 2.5.1+rocm6.2
Is debug build: False
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: 6.2.41133-dd7f95766

OS: Ubuntu 22.04.5 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.30.5
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-125-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: Radeon RX 7900 XTX (gfx1100)
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: 6.2.41133
MIOpen runtime version: 3.2.0
Is XNNPACK available: True

CPU:
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        39 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               8
On-line CPU(s) list:                  0-7
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
CPU family:                           6
Model:                                158
Thread(s) per core:                   1
Core(s) per socket:                   8
Socket(s):                            1
Stepping:                             13
CPU max MHz:                          4700.0000
CPU min MHz:                          800.0000
BogoMIPS:                             6000.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            256 KiB (8 instances)
L1i cache:                            256 KiB (8 instances)
L2 cache:                             2 MiB (8 instances)
L3 cache:                             12 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-7
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds:                  Mitigation; Microcode
Vulnerability Tsx async abort:        Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.2
[pip3] open-clip-torch==2.20.0
[pip3] pytorch-lightning==1.9.4
[pip3] pytorch-triton-rocm==3.1.0
[pip3] torch==2.5.1+rocm6.2
[pip3] torchaudio==2.5.1+rocm6.2
[pip3] torchdiffeq==0.2.5
[pip3] torchmetrics==1.6.0
[pip3] torchsde==0.2.6
[pip3] torchvision==0.20.1+rocm6.2
[conda] numpy                     2.1.2                    pypi_0    pypi
@bottler
Copy link
Contributor

bottler commented Dec 15, 2024

The problem is exactly as stated: the head dimension of your data (512) is too big to use xformers memory_efficient_attention !

@Looong01
Copy link
Author

The problem is exactly as stated: the head dimension of your data (512) is too big to use xformers memory_efficient_attention !

But there is no problem like this with CUDA and Nvidia GPU.

@bottler
Copy link
Contributor

bottler commented Dec 17, 2024

The implementations (Ops) behind fmha are different on different platforms. On nvidia there's the cutlass backend which supports very large embedding dimensions. On AMD there's only the ck ones.

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

No branches or pull requests

2 participants