Skip to content

sm_120 arch forces SDPA attention, even with functional xformers #4631

Closed

Description

@schonsense

Basically the title.

attention_dispatch.py currently has this code:

if HAS_FLASH_ATTENTION:
    from flash_attn import flash_attn_func, flash_attn_varlen_func
HAS_XFORMERS = xformers is not None
#xformers kernels (FA3, FA2, cutlass) only support compute capability <= 9.0.
#Disable xformers on newer GPUs (e.g. RTX 5070 Ti / sm_120) and fall back to SDPA.
if HAS_XFORMERS and torch.cuda.is_available():
    _cc = torch.cuda.get_device_capability()
    if _cc[0] >= 12:
        HAS_XFORMERS = False

Even without FA3, FA2, or cutlass, xformers still gives an over 50% VRAM savings over SDPA.

You can replace that code block with the following if you have a functional xformers build. Remove the debug print if you'd like.

if HAS_FLASH_ATTENTION:
    from flash_attn import flash_attn_func, flash_attn_varlen_func
HAS_XFORMERS = xformers is not None
# TEMP DEBUG: do not disable xformers on cc >= 12
if HAS_XFORMERS and torch.cuda.is_available():
    _cc = torch.cuda.get_device_capability()
    print("[ATTN_DEBUG] compute capability =", _cc, "keeping HAS_XFORMERS =", HAS_XFORMERS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions