Fix flash-attn2 hub-kernel attribute names in attention dispatch (#14012)#14016
Closed
Alex-Wengg wants to merge 1 commit into
Closed
Fix flash-attn2 hub-kernel attribute names in attention dispatch (#14012)#14016Alex-Wengg wants to merge 1 commit into
Alex-Wengg wants to merge 1 commit into
Conversation
The FLASH_HUB and FLASH_VARLEN_HUB configs in _HUB_KERNELS_REGISTRY point at
flash_attn_interface._wrapped_flash_attn_{,varlen_}{forward,backward}, which do
not exist in kernels-community/flash-attn2 (it exposes the non-_wrapped_ names).
_resolve_kernel_attr therefore raises AttributeError when the flash-attn2 hub
backend is used. Use the actual attribute names, matching the FLASH_3_HUB config.
Fixes huggingface#14012
Co-authored-by: Claude <noreply@anthropic.com>
Member
|
Will be fixed in huggingface/kernels-community#976. Cc: @DN6 @drbh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #14012.
The hub-kernel registry (
_HUB_KERNELS_REGISTRYinattention_dispatch.py) points theFLASH_HUBandFLASH_VARLEN_HUBbackends (bothkernels-community/flash-attn2) at attribute paths that don't exist in that kernel:flash_attn_interface._wrapped_flash_attn_forward/_wrapped_flash_attn_backwardflash_attn_interface._wrapped_flash_attn_varlen_forward/_wrapped_flash_attn_varlen_backwardkernels-community/flash-attn2exposes these without the_wrapped_prefix (_flash_attn_forward,_flash_attn_varlen_forward, …), so_resolve_kernel_attrraisesAttributeError: ... does not define attribute path 'flash_attn_interface._wrapped_flash_attn_varlen_forward'when the flash-attn2 hub backend is used.This is corroborated by the
FLASH_3_HUBconfig directly above, which already uses the non-_wrapped_names (flash_attn_interface._flash_attn_forward/_flash_attn_backward).Fix
Use the actual (non-
_wrapped_) attribute names for theflash-attn2hub configs. Four strings; no behavior change beyond resolving the correct symbols.Verification
Introspecting the kernel (no flash-attn compile, no model download):
After the fix,
_maybe_download_kernel_for_backend(...)resolves both forward and backward forFLASH_HUBandFLASH_VARLEN_HUB(noAttributeError). Verified onkernels==0.12.3.@sayakpaul