|
1 | 1 | # This file was modified for portability to AMDGPU |
2 | | -# Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved. |
| 2 | +# Copyright (c) 2025-2026, Advanced Micro Devices, Inc. All rights reserved. |
3 | 3 | # Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
4 | 4 | # |
5 | 5 | # See LICENSE for license information. |
|
13 | 13 | import transformer_engine |
14 | 14 | from transformer_engine_torch import NVTE_Fused_Attn_Backend |
15 | 15 |
|
16 | | -# Add test_fused_attn to the sys path |
| 16 | +# Add TE repo root to the sys path |
17 | 17 | tests_path = os.path.abspath( |
18 | | - os.path.join(os.path.dirname(__file__), "../../tests/pytorch/fused_attn") |
| 18 | + os.path.join(os.path.dirname(__file__), "../../") |
19 | 19 | ) |
20 | 20 | sys.path.append(tests_path) |
21 | 21 |
|
22 | | -from test_fused_attn import ( |
| 22 | +from tests.pytorch.utils import ( |
23 | 23 | ModelConfig, |
24 | | - _get_attention_backends, |
25 | | - _run_dot_product_attention, |
| 24 | + get_available_attention_backends, |
26 | 25 | ) |
| 26 | +from tests.pytorch.attention.test_attention import _run_dot_product_attention |
27 | 27 |
|
28 | 28 | pd.set_option("display.precision", 4) |
29 | 29 |
|
|
46 | 46 | is_training = True |
47 | 47 |
|
48 | 48 | model_configs = { |
49 | | - # test: b, h, hg, d, sq, skv, p, mask, bias |
50 | | - "test_0": ModelConfig(2, 16, 16, 64, 512, 512, 0.0, "no_mask", "no_bias"), # short seq |
51 | | - "test_1": ModelConfig(2, 16, 16, 128, 2048, 2048, 0.0, "causal", "no_bias"), # longer seq, mask |
52 | | - "test_2": ModelConfig(2, 16, 16, 128, 2048, 2048, 0.0, "causal", "post_scale_bias"), # bias |
53 | | - "test_3": ModelConfig(2, 32, 4, 128, 8192, 8192, 0.0, "causal", "no_bias"), # GQA |
54 | | - "test_4": ModelConfig(2, 128, 8, 128, 8192, 8192, 0.0, "causal_bottom_right", "no_bias") |
| 49 | + # b, sq, h, dqk |
| 50 | + "test_0": ModelConfig(2, 512, 16, 64), # short seq |
| 51 | + "test_1": ModelConfig(2, 2048, 16, 128, attn_mask_type="causal"), # longer seq, mask |
| 52 | + "test_2": ModelConfig(2, 2048, 16, 128, attn_mask_type="causal", attn_bias_type="post_scale_bias"), # bias |
| 53 | + "test_3": ModelConfig(2, 8192, 32, 128, num_gqa_groups=4, attn_mask_type="causal"), # GQA |
| 54 | + "test_4": ModelConfig(2, 8192, 128, 128, num_gqa_groups=8, attn_mask_type="causal_bottom_right") |
55 | 55 | } |
56 | 56 |
|
57 | 57 | # DataFrame indices and columns for results |
@@ -303,7 +303,7 @@ def sanity_checks( |
303 | 303 | } |
304 | 304 |
|
305 | 305 | for model, cfg in model_configs.items(): |
306 | | - avail, _, fused_bes = _get_attention_backends( |
| 306 | + avail, _, fused_bes = get_available_attention_backends( |
307 | 307 | cfg, |
308 | 308 | qkv_dtype=dtype, |
309 | 309 | qkv_layout=qkv_layout, |
@@ -364,7 +364,7 @@ def main(args): |
364 | 364 | # Benchmarking starts.. |
365 | 365 | for model in model_configs.keys(): |
366 | 366 | config = model_configs[model] |
367 | | - available_backends, _, fused_attn_backends = _get_attention_backends( |
| 367 | + available_backends, _, fused_attn_backends = get_available_attention_backends( |
368 | 368 | config, |
369 | 369 | qkv_dtype=dtype, |
370 | 370 | qkv_layout=qkv_layout, |
|
0 commit comments