-
Notifications
You must be signed in to change notification settings - Fork 250
Remove alibi, score_max/sum_exp, and dropout randomization from test_… #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| """ | ||
| Dedicated coverage for rarely-used SDPA features that are no longer exercised | ||
| by the randomized configurations in test_mhas_v2.py: ALiBi masking, the | ||
| score_max/score_sum_exp softmax outputs, and dropout. A few deterministic | ||
| configs verify that basic graph lowering and numerics keep working. | ||
| """ | ||
|
|
||
| import cudnn | ||
| import pytest | ||
| import torch | ||
|
|
||
| from sdpa.fp16 import exec_sdpa | ||
| from sdpa.random_config import ExecConfig | ||
|
|
||
|
|
||
| def make_config( | ||
| *, | ||
| data_type=torch.bfloat16, | ||
| is_infer=True, | ||
| is_alibi=False, | ||
| is_dropout=False, | ||
| dropout_prob=0.0, | ||
| with_score_max=False, | ||
| with_score_sum_exp=False, | ||
| right_bound=None, | ||
| ): | ||
| cfg = ExecConfig( | ||
| data_type=data_type, | ||
| rng_data_seed=1234, | ||
| rng_geom_seed=5678, | ||
| is_alibi=is_alibi, | ||
| is_infer=is_infer, | ||
| is_paged=False, | ||
| is_bias=False, | ||
| is_block_mask=False, | ||
| is_padding=False, | ||
| is_cu_seq_len=False, | ||
| is_ragged=False, | ||
| is_dropout=is_dropout, | ||
| is_determin=False, | ||
| with_score_max=with_score_max, | ||
| with_score_sum_exp=with_score_sum_exp, | ||
| batches=2, | ||
| d_qk=64, | ||
| d_v=64, | ||
| s_q=512, | ||
| s_kv=512, | ||
| h_q=4, | ||
| h_k=4, | ||
| h_v=4, | ||
| diag_align=cudnn.diagonal_alignment.TOP_LEFT, | ||
| left_bound=None, | ||
| right_bound=right_bound, | ||
| dropout_prob=dropout_prob, | ||
| implementation=cudnn.attention_implementation.AUTO, | ||
| ) | ||
| cfg.fill_derived_fields() | ||
| return cfg | ||
|
|
||
|
|
||
| @pytest.mark.L0 | ||
| @pytest.mark.parametrize("is_infer", [True, False], ids=["fwd", "bwd"]) | ||
| def test_sdpa_alibi(is_infer, request, cudnn_handle): | ||
| # ALiBi requires a causal mask (right_bound=0, top-left alignment). | ||
| cfg = make_config(is_infer=is_infer, is_alibi=True, right_bound=0) | ||
| exec_sdpa(cfg, request, cudnn_handle) | ||
|
|
||
|
|
||
| @pytest.mark.L0 | ||
| @pytest.mark.parametrize("is_infer", [True, False], ids=["fwd", "bwd"]) | ||
| def test_sdpa_score_max_sum_exp(is_infer, request, cudnn_handle): | ||
| cfg = make_config(is_infer=is_infer, with_score_max=True, with_score_sum_exp=True) | ||
| exec_sdpa(cfg, request, cudnn_handle) | ||
|
|
||
|
|
||
| @pytest.mark.L0 | ||
| @pytest.mark.parametrize("is_infer", [True, False], ids=["fwd", "bwd"]) | ||
| def test_sdpa_dropout(is_infer, request, cudnn_handle): | ||
| cfg = make_config( | ||
| data_type=torch.float16, | ||
| is_infer=is_infer, | ||
| is_dropout=True, | ||
| dropout_prob=0.1, | ||
| right_bound=0, | ||
| ) | ||
| exec_sdpa(cfg, request, cudnn_handle) | ||
|
Comment on lines
+61
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== test file ==\n'
cat -n test/python/test_sdpa_unpopular_features.py | sed -n '1,220p'
printf '\n== search for support checks ==\n'
rg -n "support check|is_supported|backend_version|device_capability|skipif|pytest\.mark\.skip|cudnn\.backend_version|torch\.cuda\.get_device_capability|validate_config|exec_sdpa" test/python -S
printf '\n== nearby AGENTS ==\n'
find test -name AGENTS.md -print
if [ -f test/AGENTS.md ]; then
printf '\n== test/AGENTS.md ==\n'
cat -n test/AGENTS.md
fiRepository: NVIDIA/cudnn-frontend Length of output: 29379 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== test/python/test_sdpa_unpopular_features.py =="
sed -n '1,220p' test/python/test_sdpa_unpopular_features.py | nl -ba
echo
echo "== matching helpers in test/python =="
rg -n "def (make_config|exec_sdpa|validate_config|is_supported|supports_|skip|backend_version|get_device_capability)" test/python -S
echo
echo "== AGENTS files under test =="
find test -name AGENTS.md -printRepository: NVIDIA/cudnn-frontend Length of output: 249 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '== sdpa/fp16.py validate_config and exec_sdpa ==\n'
sed -n '1,180p' test/python/sdpa/fp16.py | cat -n
printf '\n== maybe related support helpers ==\n'
sed -n '180,260p' test/python/sdpa/fp16.py | cat -n
sed -n '840,940p' test/python/sdpa/fp16.py | cat -n
printf '\n== similar SDPA tests with explicit gating ==\n'
sed -n '150,220p' test/python/test_mhas_v2.py | cat -n
sed -n '680,860p' test/python/test_mhas_v2.py | cat -n
sed -n '1000,1045p' test/python/test_mhas_v2.py | cat -nRepository: NVIDIA/cudnn-frontend Length of output: 33998 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('test/python/sdpa/fp16.py')
text = p.read_text().splitlines()
for start, end, label in [
(1, 180, 'validate_config and top-of-file'),
(180, 260, 'mid helpers'),
(840, 940, 'exec_sdpa'),
]:
print(f'== {label} ==')
for i in range(start-1, min(end, len(text))):
print(f'{i+1:4d}: {text[i]}')
print()
PY
python3 - <<'PY'
from pathlib import Path
p = Path('test/python/test_mhas_v2.py')
text = p.read_text().splitlines()
for start, end, label in [
(150, 220, 'gated rope-related tests'),
(680, 860, 'fp8 tests with capability checks'),
(1000, 1045, 'repro driver'),
]:
print(f'== {label} ==')
for i in range(start-1, min(end, len(text))):
print(f'{i+1:4d}: {text[i]}')
print()
PYRepository: NVIDIA/cudnn-frontend Length of output: 33440 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
def show(path, start, end, label):
text = Path(path).read_text().splitlines()
print(f'== {label} ==')
for i in range(start - 1, min(end, len(text))):
print(f'{i+1:4d}: {text[i]}')
print()
show('test/python/sdpa/fp16.py', 1, 180, 'validate_config and top-of-file')
show('test/python/sdpa/fp16.py', 840, 940, 'exec_sdpa')
show('test/python/test_mhas_v2.py', 150, 220, 'gated rope-related tests')
show('test/python/test_mhas_v2.py', 680, 860, 'fp8 tests with capability checks')
PYRepository: NVIDIA/cudnn-frontend Length of output: 25788 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for path, ranges in {
'test/python/sdpa/fp16.py': [(60, 140, 'validate_config'), (840, 900, 'exec_sdpa')],
'test/python/test_mhas_v2.py': [(150, 210, 'existing skip patterns')],
}.items():
text = Path(path).read_text().splitlines()
for start, end, label in ranges:
print(f'== {path} :: {label} ==')
for i in range(start - 1, min(end, len(text))):
print(f'{i+1:4d}: {text[i]}')
print()
PYRepository: NVIDIA/cudnn-frontend Length of output: 10959 Gate these SDPA cases on backend and GPU capability. These tests always exercise BF16/FP16 paths, but 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 50377
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 505
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 255
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 6341
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 12028
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 12264
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 15272
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 5717
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 9171
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 1490
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 1824
🏁 Script executed:
Repository: NVIDIA/cudnn-frontend
Length of output: 7089
Make these cases deterministic
cfg.is_determindrives bothuse_deterministic_algorithmand the rerun bitwise check intest/python/sdpa/fp16.py, so leaving itFalsemeans these backward/dropout cases never exercise the deterministic path described here. Set it toTrue.🤖 Prompt for AI Agents