Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2b9fbc5
refactor nvte_get_fused_attn_backend with FE calls
cyanguwa May 6, 2026
16b837c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 6, 2026
5a482f9
Merge branch 'main' into fe_check_support
cyanguwa May 6, 2026
42bcd89
replace code+string with string only
cyanguwa May 7, 2026
de8e814
clean up logic/comments/structure
cyanguwa May 8, 2026
4b8c7ed
Merge branch 'main' into fe_check_support
cyanguwa May 8, 2026
81e59a9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
5640c68
Merge branch 'main' into fe_check_support
cyanguwa May 8, 2026
6c5126d
fix compilation errors
cyanguwa May 8, 2026
d35bff7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
f6fc585
remove handle from API; add bottom_right_diagonal
cyanguwa May 8, 2026
3e666b0
add batch_size to API
cyanguwa May 8, 2026
056aba6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
e054863
fix jax binding
cyanguwa May 8, 2026
a7fe928
specify o_dtype for FP8s
cyanguwa May 8, 2026
c9b22b5
fix BRCM and custom_fp8 tests
cyanguwa May 8, 2026
ac44e66
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
9131b2d
add o_format/etc to API and other tweaks
cyanguwa May 8, 2026
956f159
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
b21f606
minor tweaks for docstring
cyanguwa May 8, 2026
3421920
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
7956b43
replace with nvte_get_fused_attn_backend_v2 and add NVTEFusedAttnConfig
cyanguwa May 8, 2026
e86fc67
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 8, 2026
e2561d0
fix FP8 tests
cyanguwa May 12, 2026
724a12f
add do_dtype and dqkv_dtype to API
cyanguwa May 12, 2026
3ae36df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 12, 2026
3532e98
Merge branch 'main' into fe_check_support
cyanguwa May 12, 2026
3bed68d
Merge branch 'main' into fe_check_support
cyanguwa Jul 7, 2026
d634f3b
Merge branch 'main' into fe_check_support
cyanguwa Jul 8, 2026
1c09072
replace with opaque handle
cyanguwa Jul 11, 2026
ac19f9d
repeat with fwd/bwd params
cyanguwa Jul 14, 2026
88a327c
remove bucketed b/t_q/t_kv
cyanguwa Jul 14, 2026
391fe2e
thread _v2 through, fix default scaling mode, make config specific to…
cyanguwa Jul 14, 2026
877bf99
Merge branch 'main' into fe_check_support
cyanguwa Jul 14, 2026
261bb9a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2026
c03d852
reorder struct fields, consolidate APIs to derive, make_config, make_…
cyanguwa Jul 15, 2026
eadd005
simplify fused attn config/params wrappers via set_attr helper, add g…
cyanguwa Jul 16, 2026
d052fcd
Merge branch 'main' into fe_check_support
cyanguwa Jul 17, 2026
28f5a8c
clean up derived fields, debug probe/exec graph mismatches
cyanguwa Jul 17, 2026
ade19fe
match fused attn availability probe to runtime for FP8 specs and per-…
cyanguwa Jul 18, 2026
42e9747
fix bias for jax
cyanguwa Jul 18, 2026
c66028a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 18, 2026
cf3265e
fused-attn: share graph cache across threads via mutex, require cuDNN…
cyanguwa Jul 20, 2026
cda01d7
Cache attention-backend selection keyed on (NVTE_* env, attention_par…
cyanguwa Jul 21, 2026
aa34ccb
use macros for attr_sizes[], cache_key_tuple(), and fprintf in cache …
cyanguwa Jul 21, 2026
642b58a
Revert "use macros for attr_sizes[], cache_key_tuple(), and fprintf i…
cyanguwa Jul 21, 2026
97cb2b7
remove graph cache debug code
cyanguwa Jul 21, 2026
17e5fe0
review and clean up
cyanguwa Jul 21, 2026
f802afc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 21, 2026
d65c617
guard against pre-scale bias
cyanguwa Jul 21, 2026
47421b9
fix score mod Jax tests
cyanguwa Jul 21, 2026
b6d04eb
Mirror PyTorch NVTE_DEBUG logging in JAX fused-attn backend selection…
cyanguwa Jul 21, 2026
bcbc084
tidy up on jax side
cyanguwa Jul 21, 2026
1a8c087
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 21, 2026
1632f7b
fix lint
cyanguwa Jul 22, 2026
c0233a1
fix nvte_get_fused_attn_backend shim, docstring, bias/softmax pointers
cyanguwa Jul 22, 2026
928dd33
add device_id as a key
cyanguwa Jul 22, 2026
7ff8058
add docstring for FP8 recipes
cyanguwa Jul 22, 2026
1db50d9
fix doc/ipynb
cyanguwa Jul 22, 2026
dca9585
avoid duplicate checks for fused backend and force to 0 for bias shap…
cyanguwa Jul 22, 2026
7585a1b
reduce ipynb diffs
cyanguwa Jul 22, 2026
bd557ca
Merge branch 'main' into fe_check_support
cyanguwa Jul 22, 2026
a32b671
Merge branch 'main' into fe_check_support
cyanguwa Jul 23, 2026
cbf6550
add fused attn graph cache debug code
cyanguwa Jul 24, 2026
bf4bfc0
fix kv cache probes
cyanguwa Jul 24, 2026
c7ea7be
Merge branch 'main' into fe_check_support
cyanguwa Jul 26, 2026
c056cbe
deduplicate L0 pytest tests
cyanguwa Jul 26, 2026
e890b2a
Merge remote-tracking branch 'origin/fe_check_support' into fe_check_…
cyanguwa Jul 26, 2026
16df390
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 26, 2026
a6da26e
fix merge with torch.compile PRs
cyanguwa Jul 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/envvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ backend-selection overview.
:Default: ``1``
:Description: Enable or disable UnfusedDotProductAttention backend (native PyTorch). When set to ``0``, UnfusedDotProductAttention will not be used.

.. envvar:: NVTE_FUSED_ATTN_BACKEND

:Type: ``int`` (1 or 2)
:Default: Auto-selected
:Description: Request a cuDNN FusedAttention backend when that request is supported by the active fused-attention path. ``1`` = F16_arbitrary_seqlen (cuDNN, any seq len), ``2`` = FP8 backend. If not set, the backend is automatically selected based on the input configuration. BF16/FP16 attention uses sub-backend ``1`` when eligible. FP8 attention uses sub-backend ``2`` when FP8 DPA is enabled and supported by the architecture, cuDNN version, and input configuration.

.. envvar:: NVTE_FUSED_ATTN_USE_FAv2_BWD

:Type: ``int`` (0 or 1)
:Default: ``0``
:Description: When using FusedAttention, use FlashAttention-2 implementation for the backward pass instead of the cuDNN implementation. This can be useful due to performance differences between various versions of flash-attn and FusedAttention.

.. envvar:: NVTE_FUSED_ATTN_CACHE_DEBUG

:Type: ``int`` (0 or 1)
:Default: ``0``
:Description: Enable diagnostic logging for the FusedAttention graph cache (covers both the F16 and FP8 kernels, forward and backward). When set to ``1``, prints to stderr (prefixed ``[FUSED-ATTN-CACHE]``) a per-lookup ``HIT``/``MISS`` line with the full graph-cache key, a ``BUILD`` line whenever a new graph is constructed, an ``EXEC`` line whenever a graph is executed, a ``SUMMARY`` of graph builds vs. executions at process exit, and a breakdown of cuDNN graph-build timings. Useful for diagnosing redundant graph rebuilds or stale-cache reuse, and for profiling graph-build cost. Has negligible overhead when unset.

.. envvar:: NVTE_ALLOW_NONDETERMINISTIC_ALGO

:Type: ``int`` (0 or 1)
Expand Down
8 changes: 1 addition & 7 deletions docs/examples/attention/attention.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,11 @@
"NVTE_FUSED_ATTN = 0 # disables cuDNN attention; default = 1\n",
"```\n",
"\n",
"**cuDNN attention sub-backends:**\n",
"This environment variable allows users to express their preference of cuDNN attention sub-backends. However, the elected sub-backend will only be used *if* it is eligible, i.e. if it has support for the provided inputs and runtime environment.\n",
"```\n",
"NVTE_FUSED_ATTN_BACKEND = 1/2 # user preference of cuDNN sub-backend\n",
"```\n",
"\n",
"```\n",
"<div class=\"alert alert-info\">\n",
"<b>Note</b>\n",
" \n",
"Environment variables <code>NVTE_FLASH_ATTN</code>, <code>NVTE_UNFUSED_ATTN</code>, <code>NVTE_FUSED_ATTN_BACKEND</code>, and <code>NVTE_FUSED_ATTN_USE_FAv2_BWD</code> are supported in PyTorch. <code>NVTE_FUSED_ATTN</code> and <code>NVTE_ALLOW_NONDETERMINISTIC_ALGO</code> are supported in both PyTorch and JAX.\n",
"Environment variables <code>NVTE_FLASH_ATTN</code>, <code>NVTE_UNFUSED_ATTN</code>, and <code>NVTE_FUSED_ATTN_USE_FAv2_BWD</code> are supported in PyTorch. <code>NVTE_FUSED_ATTN</code> and <code>NVTE_ALLOW_NONDETERMINISTIC_ALGO</code> are supported in both PyTorch and JAX.\n",
"</div>\n",
"\n",
"### 2.3 Example Tests\n",
Expand Down
39 changes: 1 addition & 38 deletions tests/jax/test_distributed_fused_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,6 @@ def impl_test_self_attn(
is_training = True
batch, seqlen, num_head, hidden = data_shape

if not is_fused_attn_kernel_available(
is_training,
dtype,
dtype,
QKVLayout.BS3HD,
attn_bias_type,
attn_mask_type,
softmax_type,
dropout_prob,
num_head,
num_head,
seqlen,
seqlen,
hidden,
hidden,
None, # no window
):
pytest.skip("No FusedAttn backend found")

@cyanguwa cyanguwa Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The explicit is_fused_attn_kernel_available() pre-check is no longer needed here:
FusedAttnRunner._check_configs() now runs the cuDNN-frontend support probe during
setup and skips with a diagnostic message when no fused-attn backend is available.

col_ref = self.generate_collectives_count_ref(
mesh_shape,
mesh_axes,
Expand Down Expand Up @@ -233,25 +214,6 @@ def test_cross_attn(

batch, seqlen, num_head, hidden = data_shape

if not is_fused_attn_kernel_available(
is_training,
dtype,
dtype,
QKVLayout.BSHD_BS2HD,
attn_bias_type,
attn_mask_type,
softmax_type,
dropout_prob,
num_head,
num_head,
seqlen,
seqlen,
hidden,
hidden,
None, # no window
):
pytest.skip("No FusedAttn backend found")

col_ref = self.generate_collectives_count_ref()
runner = FusedAttnRunner(
batch,
Expand Down Expand Up @@ -425,6 +387,7 @@ def impl_test_context_parallel_attn(
def check_has_backend_for_mask(mask_type):
return is_fused_attn_kernel_available(
is_training,
batch,
dtype,
dtype,
qkv_layout,
Expand Down
22 changes: 20 additions & 2 deletions tests/jax/test_fused_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,21 @@ def _check_configs(self):
"is either BSHD_BSHD_BSHD or THD_THD_THD"
)

self.backend = FusedAttnHelper(
bias_batch = bias_heads = bias_seqlen_q = bias_seqlen_kv = None
if self.attn_bias_type == AttnBiasType.POST_SCALE_BIAS:
if self.bias_shape == BiasShape._1HSS:
bias_batch, bias_heads = 1, self.num_heads_q
elif self.bias_shape == BiasShape._B1SS:
bias_batch, bias_heads = self.batch_size, 1
elif self.bias_shape == BiasShape._BHSS:
bias_batch, bias_heads = self.batch_size, self.num_heads_q
elif self.bias_shape == BiasShape._11SS:
bias_batch, bias_heads = 1, 1
bias_seqlen_q, bias_seqlen_kv = self.max_seqlen_q, self.max_seqlen_kv

self.backend, message = FusedAttnHelper(
self.is_training,
self.batch_size,
self.dtype,
self.dtype,
self.qkv_layout,
Expand All @@ -536,9 +549,14 @@ def _check_configs(self):
self.head_dim_qk,
self.head_dim_v,
(-1, -1) if self.window_size is None else self.window_size,
self.attn_mask_type.is_bottom_right(),
bias_batch=bias_batch,
bias_heads=bias_heads,
bias_seqlen_q=bias_seqlen_q,
bias_seqlen_kv=bias_seqlen_kv,
).get_fused_attn_backend()
if self.backend != NVTE_Fused_Attn_Backend.NVTE_F16_arbitrary_seqlen:
pytest.skip("Unsupported inputs combination or device compute capability.")
pytest.skip(message)

if (
self.attn_bias_type == AttnBiasType.POST_SCALE_BIAS
Expand Down
26 changes: 15 additions & 11 deletions tests/jax/test_fused_attn_score_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from transformer_engine.jax.cpp_extensions import make_fused_attn_score_mod_config
from transformer_engine.jax.flax import transformer as flax_transformer
from transformer_engine_jax import get_device_compute_capability
from transformer_engine_jax import get_device_compute_capability, NVTE_Fused_Attn_Backend
from test_fused_attn import FusedAttnRunner, SeqDescFormat


Expand Down Expand Up @@ -397,9 +397,17 @@ def _identity_score_mod(_graph, score, _tensors):
def _install_fake_flax_fused_attn(monkeypatch, *, kernel_available=True):
captured = {}

def fake_fused_attn_kernel_check(*args, **kwargs):
captured.setdefault("kernel_checks", []).append((args, kwargs))
return kernel_available
class FakeFusedAttnHelper:
def __init__(self, *args, **kwargs):
captured.setdefault("kernel_checks", []).append((args, kwargs))

def get_fused_attn_backend(self):
if kernel_available:
return NVTE_Fused_Attn_Backend.NVTE_F16_arbitrary_seqlen, ""
return (
NVTE_Fused_Attn_Backend.NVTE_No_Backend,
"fake FusedAttnHelper: no fused attention backend available for this configuration",
)

def fake_fused_attn(
qkv,
Expand Down Expand Up @@ -454,11 +462,7 @@ def fake_fused_attn(
)
return qkv[0]

monkeypatch.setattr(
flax_transformer,
"is_fused_attn_kernel_available",
fake_fused_attn_kernel_check,
)
monkeypatch.setattr(flax_transformer, "FusedAttnHelper", FakeFusedAttnHelper)
monkeypatch.setattr(flax_transformer, "fused_attn", fake_fused_attn)
return captured

Expand Down Expand Up @@ -533,7 +537,7 @@ def test_dot_product_attention_plumbs_score_mod_to_fused_attn(monkeypatch):
assert captured["attn_bias_type"] is AttnBiasType.NO_BIAS
assert captured["qkv_layout"] is QKVLayout.BSHD_BSHD_BSHD
assert captured["softmax_type"] is AttnSoftmaxType.VANILLA_SOFTMAX
assert captured["kernel_checks"][0][0][3] is QKVLayout.BSHD_BSHD_BSHD
assert captured["kernel_checks"][0][0][4] is QKVLayout.BSHD_BSHD_BSHD


def test_dot_product_attention_unpacks_packed_score_mod_to_separate_layout(monkeypatch):
Expand All @@ -557,7 +561,7 @@ def test_dot_product_attention_unpacks_packed_score_mod_to_separate_layout(monke
assert captured["qkv"][0].shape == (1, 8, 1, 16)
assert captured["qkv_layout"] is QKVLayout.BSHD_BSHD_BSHD
assert captured["score_mod"] is _identity_score_mod
assert captured["kernel_checks"][0][0][3] is QKVLayout.BSHD_BSHD_BSHD
assert captured["kernel_checks"][0][0][4] is QKVLayout.BSHD_BSHD_BSHD


def test_multi_head_attention_plumbs_score_mod_to_dot_product_attention(monkeypatch):
Expand Down
46 changes: 43 additions & 3 deletions tests/pytorch/attention/test_attention.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# See LICENSE for license information.
import copy
import logging
import os
import sys
Expand Down Expand Up @@ -140,7 +141,7 @@ def test_dot_product_attention(
tols = dict(atol=1e-3, rtol=1e-3)
if dtype == torch.bfloat16:
tols = dict(atol=1.5e-2, rtol=1.5e-2)
config = model_configs[model]
config = copy.deepcopy(model_configs[model])
is_mla = config.head_dim_qk != config.head_dim_v
is_mqa_gqa = config.num_heads != config.num_gqa_groups
if qkv_layout is None:
Expand Down Expand Up @@ -555,6 +556,9 @@ def test_dpa_softmax(dtype, model_configs, model):
@pytest.mark.parametrize("model", model_configs_softmax.keys())
def test_dpa_softmax_thd(dtype, model_configs, model):
"""Test DotProductAttention module with different softmax types"""
config = model_configs[model]
if "padding" not in config.attn_mask_type:
pytest.skip(f"Duplicate test to others with THD and padding mask.")
test_dot_product_attention(dtype, model_configs, model, True, "thd_thd_thd", False, False)


Expand Down Expand Up @@ -825,6 +829,9 @@ def test_dpa_bias_shapes(dtype, model_configs, model):
@pytest.mark.parametrize("qkv_layout", ["thd_thd_thd", "sbhd_sbhd_sbhd"])
def test_dpa_sliding_window(dtype, model_configs, model, qkv_layout):
"""Test DotProductAttention module with sliding window attention"""
config = model_configs[model]
if qkv_layout == "thd_thd_thd" and "padding" not in config.attn_mask_type:
pytest.skip(f"Duplicate test to others with THD and padding mask.")
test_dot_product_attention(dtype, model_configs, model, False, qkv_layout, True, False)


Expand Down Expand Up @@ -1867,12 +1874,24 @@ def test_dpa_fp8_extra_state(model, dtype):
config = model_configs_fp8_extra_state[model]
# Test backend availability
is_training = True
fp8_recipe = recipe.DelayedScaling(
margin=0,
fp8_format=recipe.Format.HYBRID,
amax_history_len=1,
amax_compute_algo="most_recent",
fp8_dpa=True,
)
fp8_meta = {}
fp8_meta["recipe"] = fp8_recipe
available_backends, _, fused_attn_backends = get_available_attention_backends(
config,
qkv_dtype=torch.float8_e4m3fn,
nominal_dtype=dtype,
qkv_layout="sb3hd",
is_training=is_training,
deterministic=_deterministic,
fp8=True,
fp8_meta=fp8_meta,
)
flash_attn_supported, fused_attn_supported, unfused_attn_supported = available_backends
if not fused_attn_supported and not flash_attn_supported:
Expand Down Expand Up @@ -2068,6 +2087,9 @@ def test_mha_fp8_vs_f16(
scaling_mode,
):
"""Test MultiHeadAttention module in FP8"""
if not is_training and fp8_dpa_bwd:
pytest.skip("fp8_dpa_bwd=True not applicable for inference")

os.environ["NVTE_FP8_DPA_BWD"] = "1" if fp8_dpa_bwd else "0"
config = model_configs_fp8_vs_f16[model]

Expand Down Expand Up @@ -2098,6 +2120,7 @@ def test_mha_fp8_vs_f16(
available_backends, _, _ = get_available_attention_backends(
config,
qkv_dtype=torch.float8_e4m3fn,
nominal_dtype=dtype,
qkv_layout=qkv_format.replace("hd", "h3d"),
fp8=True,
fp8_meta=fp8_meta,
Expand Down Expand Up @@ -2316,6 +2339,10 @@ def get_dummy_cuda_rng_tracker() -> CudaRNGStatesTracker:
def test_dpa_fp8_vs_f16(dtype, model, qkv_layout, fp8_dpa_bwd, is_training, scaling_mode):
"""Test DotProductAttention module in FP8"""
config = model_configs_fp8_vs_f16[model]
if config.num_heads != config.num_gqa_groups and "3" in qkv_layout:
pytest.skip("qkv_layout not applicable for MQA/GQA")
if not is_training and fp8_dpa_bwd:
pytest.skip("fp8_dpa_bwd=True not applicable for inference")

# TODO(cyang): think of another way to verify dropout results
# test cuDNN FP8 dropout
Expand Down Expand Up @@ -2355,6 +2382,7 @@ def test_dpa_fp8_vs_f16(dtype, model, qkv_layout, fp8_dpa_bwd, is_training, scal
available_backends, _, _ = get_available_attention_backends(
config,
qkv_dtype=torch.float8_e4m3fn,
nominal_dtype=dtype,
qkv_layout=qkv_layout,
fp8=True,
fp8_meta=fp8_meta,
Expand All @@ -2374,8 +2402,6 @@ def test_dpa_fp8_vs_f16(dtype, model, qkv_layout, fp8_dpa_bwd, is_training, scal
pytest.skip("No FP8 attention backend available.")
if not fused_attn_supported_f16:
pytest.skip("No reference backend available.")
if config.num_heads != config.num_gqa_groups and "3" in qkv_layout:
pytest.skip("qkv_layout not applicable for MQA/GQA")

if flash_attn_supported:
os.environ["NVTE_FLASH_ATTN"] = "1"
Expand Down Expand Up @@ -2661,13 +2687,26 @@ def test_custom_mha_fp8_vs_f16(dtype, model):
Both paths take F16 input and output. QKV layout is bs3hd"""

config = model_configs_fp8[model]
os.environ["NVTE_UnfusedDPA_Emulate_FP8"] = "1"

# Test backend availability
is_training = True
fp8_meta = {}
fp8_recipe = recipe.DelayedScaling(
margin=0,
fp8_format=recipe.Format.HYBRID,
amax_history_len=1,
amax_compute_algo="most_recent",
fp8_dpa=True,
)
fp8_meta["recipe"] = fp8_recipe
available_backends, _, fused_attn_backends = get_available_attention_backends(
config,
qkv_dtype=torch.float8_e4m3fn,
nominal_dtype=dtype,
qkv_layout="bs3hd",
fp8=True,
fp8_meta=fp8_meta,
is_training=is_training,
deterministic=_deterministic,
)
Expand Down Expand Up @@ -2745,6 +2784,7 @@ def _run_custom_mha_fp8(dtype, config, backend):
fp8_format=recipe.Format.HYBRID,
amax_history_len=1,
amax_compute_algo="most_recent",
fp8_dpa=True,
)

mha = Custom_MHA_FP8(config).to(dtype=dtype, device="cuda")
Expand Down
4 changes: 4 additions & 0 deletions tests/pytorch/attention/test_attention_with_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ def test_cp_with_flash_attention(cp_pool, dtype, model, qkv_format, cp_comm_type
config,
qkv_dtype=dtypes[dtype],
qkv_layout="_".join([qkv_format] * 3),
cp_size=num_gpus,
cp_size_a2a=2 if cp_comm_type == "a2a+p2p" else 1,
)
flash_attn_supported, *_ = available_backends
if not flash_attn_supported:
Expand Down Expand Up @@ -638,6 +640,8 @@ def test_cp_with_fused_attention(
fp8_meta=fp8_meta,
is_training=is_training,
deterministic=_deterministic,
cp_size=num_gpus,
cp_size_a2a=2 if cp_comm_type == "a2a+p2p" else 1,
)

_, fused_attn_supported, _ = available_backends
Expand Down
8 changes: 6 additions & 2 deletions tests/pytorch/attention/test_kv_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from collections import OrderedDict
from typing import List
import copy
import os
import sys
import pathlib
Expand Down Expand Up @@ -472,8 +473,11 @@ def test_kv_cache(dtype, model, qkv_format, is_paged, backend, module, is_cuda_g
qkv_layout = qkv_format + "_" + "_".join([inference_params_qkv_format] * 2)
if is_paged:
qkv_layout = "paged_kv_" + qkv_layout
available_backends, _, fused_attn_backends = get_available_attention_backends(
config,
# probe inference configs only; reference configs are widely supported
probe_config = copy.deepcopy(config)
probe_config.attn_mask_type = "padding_causal"
available_backends, _, _ = get_available_attention_backends(
probe_config,
qkv_dtype=dtype,
qkv_layout=qkv_layout,
pad_between_seqs=False,
Expand Down
Loading
Loading