SIGN IN SIGN UP

[SDPA][CUDA] Prefer cuDNN SDPA backend on sm86 and sm89 (#192799)

There's been an open TODO on `check_prefer_cudnn_attention` to prioritize the cuDNN backend for sm86/89 if warranted by benchmarking. I've run that benchmarking, and cuDNN is in fact faster on these compute capabilities. This PR extends the device capability check to include those versions and updates the associated test, `test_fused_sdp_choice`. It also changes that test to use the correct environment variable, `TORCH_CUDNN_SDPA_DEPRIORITIZED`.

### Results

| sm | mode | cuDNN median ms | cuDNN median TFLOPS | flash median ms | flash median TFLOPS |
| --- | --- | --- | --- | --- | --- |
| sm80 | fwd | 1.401 | 135.420 | 1.472 | **136.445** |
| sm80 | fwd+bwd | 13.508 | 68.812 | 13.615 | **78.608** |
| sm86 | fwd | 3.680 | **62.419** | 4.130 | 50.934 |
| sm86 | fwd+bwd | 35.955 | **24.959** | 37.335 | 23.916 |
| sm89 | fwd | 2.203 | **106.036** | 2.543 | 85.933 |
| sm89 | fwd+bwd | 25.360 | **27.530** | 34.364 | 23.748 |

### Links
[Benchmarking results spreadsheet](https://docs.google.com/spreadsheets/d/155Icw1ebD90vblFMqj7xAqFEKudhsz_H)
[Benchmarking script](https://gist.github.com/gderossi/ca4eff8cec97081e47da9c54fe22ea20)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/192799
Approved by: https://github.com/eqy
G
Grayson Derossi committed
aa1a622e4329400c1068cbbb2192a034ed854d26
Parent: 866415f
Committed by PyTorch MergeBot <pytorchmergebot@users.noreply.github.com> on 8/24/2026, 10:52:05 PM