Skip to content

Commit d234051

Browse files
authored
Enable Thor (#2108)
1 parent 58fe37f commit d234051

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

csrc/cutlass

Submodule cutlass updated 285 files

flash_attn/cute/interface.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def _flash_attn_fwd(
252252
else _compute_capability
253253
)
254254

255-
assert compute_capability in [9, 10], "Unsupported compute capability. Supported: 9.x, 10.x"
255+
assert compute_capability in [9, 10, 11], "Unsupported compute capability. Supported: 9.x, 10.x, 11.x"
256256

257257
use_block_sparsity = block_sparse_tensors is not None
258258

@@ -275,7 +275,7 @@ def _flash_attn_fwd(
275275
if head_dim == head_dim_v == 128 and not causal and not local and not use_block_sparsity:
276276
n_block_size = 192
277277

278-
if compute_capability == 10:
278+
if compute_capability in [10, 11]:
279279
if (
280280
pack_gqa
281281
and (128 % qhead_per_kvhead != 0)
@@ -442,7 +442,7 @@ def _flash_attn_fwd(
442442
score_mod=score_mod,
443443
has_aux_tensors=aux_tensors is not None,
444444
)
445-
elif compute_capability == 10:
445+
elif compute_capability in [10, 11]:
446446
fa_fwd = FlashAttentionForwardSm100(
447447
head_dim,
448448
head_dim_v,
@@ -467,7 +467,7 @@ def _flash_attn_fwd(
467467
)
468468
else:
469469
raise ValueError(
470-
f"Unsupported compute capability: {compute_capability}. Supported: 9.x, 10.x"
470+
f"Unsupported compute capability: {compute_capability}. Supported: 9.x, 10.x, 11.x"
471471
)
472472
# TODO: check @can_implement
473473
_flash_attn_fwd.compile_cache[compile_key] = cute.compile(
@@ -579,7 +579,7 @@ def _flash_attn_bwd(
579579
block_sparse_tensors: Optional[BlockSparseTensorsTorch] = None,
580580
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
581581
compute_capability = _get_device_capability()
582-
assert compute_capability in [9, 10], "Unsupported compute capability. Supported: 9.x, 10.x"
582+
assert compute_capability in [9, 10, 11], "Unsupported compute capability. Supported: 9.x, 10.x, 11.x"
583583

584584
if compute_capability == 9:
585585
m_block_size = 80 if not causal else 64
@@ -686,18 +686,18 @@ def _flash_attn_bwd(
686686
qhead_per_kvhead = num_head // num_head_kv
687687
if pack_gqa is None:
688688
pack_gqa = qhead_per_kvhead > 1
689-
if compute_capability == 10:
689+
if compute_capability in [10, 11]:
690690
pack_gqa = False # override for now
691-
if compute_capability != 10:
692-
assert deterministic is False, "bwd deterministic only supported for sm100 for now"
691+
if compute_capability not in [10, 11]:
692+
assert deterministic is False, "bwd deterministic only supported for sm100/sm110 for now"
693693

694694
if score_mod is not None:
695695
assert score_mod_bwd is not None, "score_mod_bwd is required when score_mod is provided"
696696
assert softcap == 0.0, "softcap and score_mod are mutually exclusive (different log2 scaling)"
697697
assert cu_seqlens_q is None and cu_seqlens_k is None, (
698698
"varlen + score_mod not supported in bwd yet"
699699
)
700-
assert compute_capability == 10, "score_mod in bwd only supported on SM100 for now"
700+
assert compute_capability in [10, 11], "score_mod in bwd only supported on SM100/SM110 for now"
701701

702702
device = q.device
703703
out_torch_dtype = q.dtype
@@ -987,7 +987,7 @@ def _flash_attn_bwd(
987987
# Block sparse tensors for backward use Q-direction indexing (transposed from forward).
988988
# sparse_block_size_q = 2*tile_m matches forward's q_stage=2 pipelining.
989989
sparse_tensors_compile = None
990-
if block_sparse_tensors is not None and compute_capability == 10:
990+
if block_sparse_tensors is not None and compute_capability in [10, 11]:
991991
expected_count_shape, expected_index_shape = get_block_sparse_expected_shapes_bwd(
992992
batch_size, num_head, seqlen_q, seqlen_k,
993993
m_block_size, n_block_size, subtile_factor,
@@ -1028,7 +1028,7 @@ def _flash_attn_bwd(
10281028
options="--enable-tvm-ffi",
10291029
)
10301030
normalized_block_sparse_tensors = None
1031-
if block_sparse_tensors is not None and compute_capability == 10:
1031+
if block_sparse_tensors is not None and compute_capability in [10, 11]:
10321032
expected_count_shape, expected_index_shape = get_block_sparse_expected_shapes_bwd(
10331033
batch_size, num_head, seqlen_q, seqlen_k,
10341034
m_block_size, n_block_size, subtile_factor,

0 commit comments

Comments
 (0)