TransformerEngine
TransformerEngine copied to clipboard
[PyTorch] Miscellaneous fixes for FA3 attention
Description
This PR makes a few changes to the FA3 attention path.
- Adds
descale_q
,descale_k
anddescale_v
to FA3 FP8 call. This allows for custom descaling factors instead of the default 1s forq
,k
andv
. This requires FA3 PR 1210 to be in your FA3 installation. - Restricts FA3 path to
flash_attn_func
for FP8 sinceflash_attn_varlen_func
does not support FP8 yet. - Fixes the transposes in the
qkv_format=sbhd
case whenfp8_mha=true
. - Enables sliding window support for FP16/BF16 from FA3 (no FP8 support yet).
- Improves the messaging when FA3 is not installed, and when it's missing some kwargs. We provide some installation instructions, and remind users to update their installation, in those two cases. This PR targets FA 3.0.0b1, and it's rapidly developing, with more kwargs being added to the API.
- Casts FA3 output to the same type as cuDNN attention in unit tests.
Type of change
- [ ] Documentation change (change only to the documentation, either a fix or a new content)
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Infra/Build change
- [ ] Code refractor
Changes
Please list the changes introduced in this PR:
- See description above.
Checklist:
- [x] I have read and followed the contributing guidelines
- [x] The functionality is complete
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes