Stability-AI/generative-models · warning
Attention mode '{attn_mode}' is not available. Falling back
Error message
Attention mode '{attn_mode}' is not available. Falling back to native attention. This is not a problem in Pytorch >= 2.0. FYI, you are running with PyTorch version {torch.__version__}. What it means
CrossAttention/MemoryEfficientAttention __init__ asserts attn_mode is a known mode, then warns and coerces the mode to 'softmax' if a non-default mode (e.g. 'xformers') was requested while xformers is not installed. The model still constructs, just with slower native attention.
Source
Thrown at sgm/modules/attention.py:478
}
def __init__(
self,
dim,
n_heads,
d_head,
dropout=0.0,
context_dim=None,
gated_ff=True,
checkpoint=True,
disable_self_attn=False,
attn_mode="softmax",
sdp_backend=None,
):
super().__init__()
assert attn_mode in self.ATTENTION_MODES
if attn_mode != "softmax" and not XFORMERS_IS_AVAILABLE:
logpy.warn(
f"Attention mode '{attn_mode}' is not available. Falling "
f"back to native attention. This is not a problem in "
f"Pytorch >= 2.0. FYI, you are running with PyTorch "
f"version {torch.__version__}."
)
attn_mode = "softmax"
elif attn_mode == "softmax" and not SDP_IS_AVAILABLE:
logpy.warn(
"We do not support vanilla attention anymore, as it is too "
"expensive. Sorry."
)
if not XFORMERS_IS_AVAILABLE:
assert (
False
), "Please install xformers via e.g. 'pip install xformers==0.0.16'"
else:
logpy.info("Falling back to xformers efficient attention.")
attn_mode = "softmax-xformers"View on GitHub (pinned to e8cd657656)
Solutions
- Install xformers so the requested attention mode actually becomes available
- Change attn_mode to 'softmax' explicitly in the config to silence the fallback warning
- Verify XFORMERS_IS_AVAILABLE is True after importing sgm.modules.attention before relying on xformers speedups
Example fix
// before params: attn_mode: "xformers" # xformers not installed -> silent fallback // after pip install xformers # or params: attn_mode: "softmax"
Defensive patterns
Strategy: validation
Validate before calling
import sgm.modules.attention as A
if cfg_attn_mode != "softmax" and not A.XFORMERS_IS_AVAILABLE:
print(f"{cfg_attn_mode} unavailable, will fall back to softmax") Type guard
def attn_mode_usable(mode: str) -> bool:
import sgm.modules.attention as A
return mode == "softmax" or A.XFORMERS_IS_AVAILABLE Try / catch
try:
attn = CrossAttention(..., attn_mode=cfg_attn_mode)
finally:
if attn.attn_mode != cfg_attn_mode:
logger.warning("attention mode fell back to %s", attn.attn_mode) Prevention
- Only set xformers attn_mode after verifying xformers imports
- Default configs to attn_mode 'softmax' on torch>=2.0
- Check the constructed module's final attn_mode in tests
When it happens
Trigger: Config `attn_mode: 'xformers'` (or 'torch-sdp'/'vanilla' variants requiring backends) in a CrossAttention with XFORMERS_IS_AVAILABLE False — i.e. xformers import failed at module load.
Common situations: Reusing SD configs that specify xformers attention on machines without xformers; CI/CPU environments where xformers wheels are unavailable.
Related errors
- We do not support vanilla attention anymore, as it is too ex
- unknown merge strategy {self.merge_strategy}
- Unknown loss type {self.loss_type}
- provide num_res_blocks either as an int (globally constant)
- need either 'input_key' or 'input_keys' for embedder {embedd
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/0c6585d01c6e61f2.
Report an issue: GitHub.