#1399·xformers

module 'xformers.ops' has no attribute 'memory_efficient_attention'

Author: edisonchanCreated Jun 23, 2026Updated Jun 23, 2026

Bug

Run flux.2 klein workflow bundle with ComfyUI popup error message:

[ERROR] !!! Exception during processing !!! module 'xformers.ops' has no attribute 'memory_efficient_attention'
[ERROR] Traceback (most recent call last):
  File "/home/edison/Downloads/ComfyUI/execution.py", line 542, in execute
    output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/edison/Downloads/ComfyUI/execution.py", line 341, in get_output_data
    return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/edison/Downloads/ComfyUI/execution.py", line 315, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "/home/edison/Downloads/ComfyUI/execution.py", line 303, in process_inputs
    result = f(**inputs)
  File "/home/edison/Downloads/ComfyUI/nodes.py", line 364, in encode
    t = vae.encode(pixels)
  File "/home/edison/Downloads/ComfyUI/comfy/sd.py", line 1163, in encode
    model_management.raise_non_oom(e)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/home/edison/Downloads/ComfyUI/comfy/model_management.py", line 394, in raise_non_oom
    raise e
  File "/home/edison/Downloads/ComfyUI/comfy/sd.py", line 1156, in encode
    out = self.first_stage_model.encode(pixels_in)
  File "/home/edison/Downloads/ComfyUI/comfy/ldm/models/autoencoder.py", line 208, in encode
    z = self.encoder(x)
  File "/home/edison/Downloads/ComfyUI/.venv/lib/python3.14/site-packages/torch/nn/modules/module.py", line 1778, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/edison/Downloads/ComfyUI/.venv/lib/python3.14/site-packages/torch/nn/modules/module.py", line 1789, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/edison/Downloads/ComfyUI/comfy/ldm/modules/diffusionmodules/model.py", line 673, in forward
    h = self.mid.attn_1(h)
  File "/home/edison/Downloads/ComfyUI/.venv/lib/python3.14/site-packages/torch/nn/modules/module.py", line 1778, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/edison/Downloads/ComfyUI/.venv/lib/python3.14/site-packages/torch/nn/modules/module.py", line 1789, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/edison/Downloads/ComfyUI/comfy/ldm/modules/diffusionmodules/model.py", line 374, in forward
    h_ = self.optimized_attention(q, k, v)
  File "/home/edison/Downloads/ComfyUI/comfy/ldm/modules/diffusionmodules/model.py", line 298, in xformers_attention
    out = xformers.ops.memory_efficient_attention(q, k, v, attn_bias=None)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'xformers.ops' has no attribute 'memory_efficient_attention'

Command

To Reproduce

Steps to reproduce the behavior:

cd /home/edison/Downloads/ComfyUI source .venv/bin/activate

cd /home/edison/Downloads/xformers pip install -v --no-build-isolation -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers

cd /home/edison/Downloads/ComfyUI python main.py --listen --enable-manager

Expected behavior

Environment

Ubuntu 26.04 cuda toolkit 13.3 python 3.14 pytorch 2.12

python -m xformers.info
/home/edison/Downloads/ComfyUI/.venv/lib/python3.14/site-packages/torch/cuda/__init__.py:63: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
  import pynvml  # type: ignore[import]
xFormers 0.0.35+42fc265.d20260623
indexing.scaled_index_addF:                        available
indexing.scaled_index_addB:                        available
indexing.index_select:                             available
sp24.sparse24_sparsify_both_ways:                  available
sp24.sparse24_apply:                               available
sp24.sparse24_apply_dense_output:                  available
sp24._sparse24_gemm:                               available
[email protected]:                 available
[email protected]:                        available
is_triton_available:                               True
pytorch.version:                                   2.12.1+cu130
pytorch.cuda:                                      available
gpu.compute_capability:                            12.0
gpu.name:                                          NVIDIA GeForce RTX 5070
dcgm_profiler:                                     unavailable
build.info:                                        available
build.cuda_version:                                1303
build.hip_version:                                 None
build.python_version:                              3.14.4
build.torch_version:                               2.12.1+cu130
build.env.TORCH_CUDA_ARCH_LIST:                    None
build.env.PYTORCH_ROCM_ARCH:                       None
build.env.XFORMERS_BUILD_TYPE:                     None
build.env.XFORMERS_ENABLE_DEBUG_ASSERTIONS:        None
build.env.NVCC_FLAGS:                              None
build.env.XFORMERS_PACKAGE_FROM:                   None
build.nvcc_version:                                13.3.33
source.privacy:                                    open source
(.venv) edison@u24:~/Downloads/ComfyUI$ pip install nvidia-ml-py
Looking in indexes: https://mirrors.cloud.tencent.com/pypi/simple/
Requirement already satisfied: nvidia-ml-py in ./.venv/lib/python3.14/site-packages (13.610.43)
(.venv) edison@u24:~/Downloads/ComfyUI$ nvidia-smi
Tue Jun 23 23:53:26 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 610.43.02              KMD Version: 610.43.02     CUDA UMD Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 5070        Off |   00000000:01:00.0  On |                  N/A |
|  0%   45C    P8              4W /  250W |      34MiB /  12227MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

You can run the script with:

bash
# For security purposes, please check the contents of collect_env.py before running it.
python -m torch.utils.collect_env
python -m torch.utils.collect_env
/home/edison/Downloads/ComfyUI/.venv/lib/python3.14/site-packages/torch/cuda/__init__.py:63: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
  import pynvml  # type: ignore[import]
<frozen runpy>:128: 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
Collecting environment information...
PyTorch version: 2.12.1+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 26.04 LTS (x86_64)
GCC version: (Ubuntu 13.4.0-10ubuntu1) 13.4.0
Clang version: 20.1.8 (https://github.com/llvm/llvm-project.git 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
CMake version: version 4.2.3
Libc version: glibc-2.43

Python version: 3.14.4 (main, Apr  8 2026, 04:02:31) [GCC 15.2.0] (64-bit runtime)
Python platform: Linux-7.0.0-22-generic-x86_64-with-glibc2.43
Is CUDA available: True
CUDA runtime version: 13.3.33
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 5070
Nvidia driver version: Could not collect
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_tensor_ir.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_ext.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.22.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.22.0
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           48 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  8
On-line CPU(s) list:                     0-7
Vendor ID:                               AuthenticAMD
Model name:                              AMD Ryzen 7 9850X3D 8-Core Processor
CPU family:                              26
Model:                                   68
Thread(s) per core:                      1
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                0
Frequency boost:                         enabled
CPU(s) scaling MHz:                      50%
CPU max MHz:                             5653.6240
CPU min MHz:                             613.0440
BogoMIPS:                                9399.97
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpuid_fault cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx_vnni avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid bus_lock_detect movdiri movdir64b overflow_recov succor smca fsrm avx512_vp2intersect flush_l1d amd_lbr_pmc_freeze
Virtualization:                          AMD-V
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                8 MiB (8 instances)
L3 cache:                                96 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-7
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Mitigation; IBPB on VMEXIT only
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP disabled; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB on VMEXIT

Versions of relevant libraries:
[pip3] came-pytorch==0.1.3
[pip3] lion-pytorch==0.2.4
[pip3] numpy==2.4.0
[pip3] nvidia-cublas==13.1.1.3
[pip3] nvidia-cuda-cupti==13.0.85
[pip3] nvidia-cuda-nvrtc==13.0.88
[pip3] nvidia-cuda-runtime==13.0.96
[pip3] nvidia-cudnn-cu13==9.20.0.48
[pip3] nvidia-cufft==12.0.0.61
[pip3] nvidia-curand==10.4.0.35
[pip3] nvidia-cusolver==12.0.4.66
[pip3] nvidia-cusparse==12.6.3.3
[pip3] nvidia-cusparselt-cu13==0.8.1
[pip3] nvidia-nccl-cu13==2.29.7
[pip3] nvidia-nvjitlink==13.0.88
[pip3] nvidia-nvtx==13.0.85
[pip3] onnx==1.22.0
[pip3] onnxruntime==1.27.0
[pip3] onnxruntime-gpu==1.27.0
[pip3] open_clip_torch==3.3.0
[pip3] rotary-embedding-torch==0.9.1
[pip3] torch==2.12.1
[pip3] torchaudio==2.11.0
[pip3] torchsde==0.2.6
[pip3] torchvision==0.27.1
[pip3] triton==3.7.1
[conda] Could not collect

Additional context

Source: facebookresearch/xformers