Skip to content

Remove alibi, score_max/sum_exp, and dropout randomization from test_… - #435

Open
vedaanta wants to merge 3 commits into
NVIDIA:developfrom
vedaanta:vagarwalla/test-mhas-v2-remove-optional-features
Open

Remove alibi, score_max/sum_exp, and dropout randomization from test_…#435
vedaanta wants to merge 3 commits into
NVIDIA:developfrom
vedaanta:vagarwalla/test-mhas-v2-remove-optional-features

Conversation

@vedaanta

@vedaanta vedaanta commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

…mhas_v2

Drop is_alibi, with_score_max, with_score_sum_exp, and is_dropout from the randomized SDPA test configurations. The plumbing in the sdpa test package is kept; only the test file stops exercising these options.

Before submitting

  • I agree to license this contribution under the terms of LICENSE.txt.
  • I ran pre-commit run and committed any formatting changes.

Affected area

Summary

Why

Related issues

API and compatibility impact

Testing

Summary by CodeRabbit

  • Bug Fixes

    • Improved attention operation reliability by refining randomized test coverage across standard, ragged, paged, and specialized scenarios.
  • Tests

    • Added coverage for ALiBi masking with causal constraints.
    • Added validation for score maximum and score-sum-exponential outputs.
    • Added forward and backward coverage for dropout with float16 inputs.

…mhas_v2

Drop is_alibi, with_score_max, with_score_sum_exp, and is_dropout from
the randomized SDPA test configurations. The plumbing in the sdpa test
package is kept; only the test file stops exercising these options.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vedaanta
vedaanta requested a review from Anerudhan July 24, 2026 05:11
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e1673438-c623-4a7f-8c2d-e6e6f2c06e5c

📥 Commits

Reviewing files that changed from the base of the PR and between 81c7e37 and e9c7238.

📒 Files selected for processing (1)
  • test/python/test_sdpa_custom_features.py

📝 Walkthrough

Walkthrough

SDPA randomized tests no longer vary selected score, ALiBi, and dropout options. A new deterministic test module covers ALiBi masking, score outputs, and dropout across forward and backward execution.

Changes

SDPA test configuration

Layer / File(s) Summary
RandomizationContext option updates
test/python/test_mhas_v2.py
Randomized SDPA contexts remove score-related options, while selected unified contexts also remove ALiBi and dropout options.
Deterministic uncommon-feature tests
test/python/test_sdpa_custom_features.py
Adds a shared ExecConfig builder and parametrized forward/backward tests for ALiBi masking, score outputs, and dropout.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: mod-frontend, cat-enhancements

Suggested reviewers: anerudhan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning Required sections like Affected area, Summary, Why, Related issues, API impact, and Testing are left empty. Fill in each template section with the affected area, concise summary, rationale, related issues, compatibility impact, and exact testing performed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: removing several randomized SDPA feature knobs from tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@vedaanta

Copy link
Copy Markdown
Collaborator Author

@cudnn-ci-bot run

@cudnn-ci-bot

Copy link
Copy Markdown

🚀 Running mirror pipeline

Branch: cudnn-gh/pr-435-891f9f7
Pipeline: 59366509

@Anerudhan Anerudhan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am hesitant to remove this. New engines can return not supported. As these are tested into upstream integrations.

@vedaanta

Copy link
Copy Markdown
Collaborator Author

@Anerudhan Agreed that we have users for these, but we do already run TE and PyT tests directly.
In case something breaks for dropout/max/sum_exp/alibi, TE/PyT tests will flag it.

Given that we want to focus on important fusions, current testing surface only clobber stats for all the new kernels we are bringing up.


I will add a separate individual test for all these fusions. Separate from test_mhas.

Cover ALiBi, score_max/score_sum_exp, and dropout with a few
deterministic fwd/bwd configs in test_sdpa_unpopular_features.py, now
that test_mhas_v2.py no longer randomizes over these options.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vedaanta

vedaanta commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Added test/python/test_sdpa_custom_features.py with dedicated deterministic coverage for the features removed from the randomized configs: ALiBi, score_max/score_sum_exp, and dropout — each with a fwd and bwd case, so basic lowering for these fusions stays exercised. Verified locally on SM100 with cuDNN 9.30: 6/6 pass.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/python/test_sdpa_unpopular_features.py`:
- Around line 27-40: Update the ExecConfig construction in
test_sdpa_unpopular_features.py so cfg.is_determin is set to True, ensuring the
backward/dropout cases exercise the deterministic algorithm and bitwise rerun
check.
- Around line 61-86: Add the established cuDNN backend-version and GPU
compute-capability guards to test_sdpa_alibi, test_sdpa_score_max_sum_exp, and
test_sdpa_dropout before exec_sdpa. Reuse the same checks and skip behavior used
elsewhere in the test module, including dtype-specific support conditions, so
unsupported BF16/FP16 combinations are skipped while supported cases retain
their current coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0225b992-32ad-4534-8fe3-61a9973f4cb5

📥 Commits

Reviewing files that changed from the base of the PR and between 891f9f7 and 81c7e37.

📒 Files selected for processing (1)
  • test/python/test_sdpa_unpopular_features.py

Comment on lines +27 to +40
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,

Copy link
Copy Markdown
Contributor

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:

#!/bin/bash
set -euo pipefail

printf '\n== File outline ==\n'
ast-grep outline test/python/test_sdpa_unpopular_features.py --view expanded || true

printf '\n== Relevant symbols ==\n'
rg -n "class ExecConfig|def exec_sdpa|is_determin|determin" -S test python . || true

Repository: NVIDIA/cudnn-frontend

Length of output: 50377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
p = Path("test/python/test_sdpa_unpopular_features.py")
print("lines", sum(1 for _ in p.open()))
for i, line in enumerate(p.open(), 1):
    if 1 <= i <= 220:
        if "ExecConfig" in line or "is_determin" in line or "exec_sdpa" in line or "L0" in line:
            print(f"{i}: {line.rstrip()}")
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 505


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the relevant source slices around the referenced lines and the ExecConfig/exec_sdpa definitions.
for f in test/python/test_sdpa_unpopular_features.py $(git ls-files | rg '(^|/)(exec_sdpa|ExecConfig).*\.py$' || true); do
  [ -f "$f" ] || continue
  echo "===== $f ====="
  nl -ba "$f" | sed -n '1,240p'
done

Repository: NVIDIA/cudnn-frontend

Length of output: 255


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
paths = [Path("test/python/test_sdpa_unpopular_features.py")]
# discover the definition files referenced by rg
import subprocess, shlex
out = subprocess.check_output(rg := ["bash", "-lc", "rg -n --glob '*.py' 'class ExecConfig|def exec_sdpa|is_determin' test ."], text=True)
print(out)
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 6341


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "class ExecConfig|def exec_sdpa|is_determin" test . || true

Repository: NVIDIA/cudnn-frontend

Length of output: 12028


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Searching...\n'
rg -n "is_determin|ExecConfig|exec_sdpa" test/python test || true

Repository: NVIDIA/cudnn-frontend

Length of output: 12264


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

def show(path, start, end):
    print(f"===== {path} {start}-{end} =====")
    lines = Path(path).read_text().splitlines()
    for i in range(start, min(end, len(lines)) + 1):
        print(f"{i:4d}: {lines[i-1]}")

show("test/python/test_sdpa_unpopular_features.py", 1, 120)
show("test/python/sdpa/fp16.py", 450, 620)
show("test/python/sdpa/random_config.py", 67, 110)
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 15272


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
for path, start, end in [
    ("test/python/test_sdpa_edge_cases.py", 1, 80),
    ("test/python/test_sdpa_unpopular_features.py", 1, 95),
]:
    print(f"===== {path} {start}-{end} =====")
    lines = Path(path).read_text().splitlines()
    for i in range(start, min(end, len(lines)) + 1):
        print(f"{i:4d}: {lines[i-1]}")
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 5717


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
path = Path("test/python/sdpa/fp16.py")
lines = path.read_text().splitlines()
for start, end in [(470, 590), (840, 885)]:
    print(f"===== {path} {start}-{end} =====")
    for i in range(start, min(end, len(lines)) + 1):
        print(f"{i:4d}: {lines[i-1]}")
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 9171


🏁 Script executed:

#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("test/python/test_sdpa_unpopular_features.py")
for i, line in enumerate(p.read_text().splitlines(), 1):
    if i <= 20 or 24 <= i <= 45:
        print(f"{i:4d}: {line}")
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 1490


🏁 Script executed:

#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for path in ["test/python/test_sdpa_edge_cases.py"]:
    print(f"===== {path} =====")
    for i, line in enumerate(Path(path).read_text().splitlines(), 1):
        if i <= 55:
            print(f"{i:4d}: {line}")
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 1824


🏁 Script executed:

#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("test/python/sdpa/fp16.py")
for i, line in enumerate(p.read_text().splitlines(), 1):
    if 475 <= i <= 590:
        print(f"{i:4d}: {line}")
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 7089


Make these cases deterministic cfg.is_determin drives both use_deterministic_algorithm and the rerun bitwise check in test/python/sdpa/fp16.py, so leaving it False means these backward/dropout cases never exercise the deterministic path described here. Set it to True.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/python/test_sdpa_unpopular_features.py` around lines 27 - 40, Update the
ExecConfig construction in test_sdpa_unpopular_features.py so cfg.is_determin is
set to True, ensuring the backward/dropout cases exercise the deterministic
algorithm and bitwise rerun check.

Comment on lines +61 to +86
@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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
fi

Repository: 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 -print

Repository: 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 -n

Repository: 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()
PY

Repository: 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')
PY

Repository: 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()
PY

Repository: NVIDIA/cudnn-frontend

Length of output: 10959


Gate these SDPA cases on backend and GPU capability. These tests always exercise BF16/FP16 paths, but exec_sdpa only applies a few cuDNN-version skips and doesn’t gate architecture or dtype support here. Add the same cudnn.backend_version() and torch.cuda.get_device_capability() checks used elsewhere before calling exec_sdpa, so unsupported combos skip instead of failing CI.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/python/test_sdpa_unpopular_features.py` around lines 61 - 86, Add the
established cuDNN backend-version and GPU compute-capability guards to
test_sdpa_alibi, test_sdpa_score_max_sum_exp, and test_sdpa_dropout before
exec_sdpa. Reuse the same checks and skip behavior used elsewhere in the test
module, including dtype-specific support conditions, so unsupported BF16/FP16
combinations are skipped while supported cases retain their current coverage.

Source: Coding guidelines

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vedaanta
vedaanta requested a review from Anerudhan July 26, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants