-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Description
Motivation.
This RFC is aimed to address the following issues:
-
The ViT right now is still pretty coupled with Text backbone attention. This RFC will further the effort to decouple the ViT and the text backbone attention.
-
Another pain point is that the overriding of the ViT logic is scattered all around the places. We should avoid doing ViT logic overriding in model definition classes. The platform class should define the logic of what ViT is supported and how it should be overwritten.
-
Since the introduction of
torch.compileinto the ViT, currently only starting with qwen vl model in PR [Misc][qwen2_5_vl][torch.compile] Enablesupports_torch_compileon generic nn.Module and demonstrate speedup on Qwen Vision model #23207 , the AMD ViT Code path are broken. New approach will try to accommodate this new feature.torch.compilehas brought a lot of performance improvement and we can now consider to replace triton kernels with pytorch native implementation as there are possibilities thattorch.compilecode is faster than customtriton kernelcode. -
Ensure ViT changes take into account the other model definition files
model.pyfiles, as current changes only involvesqwen_2_5_vl.pywhich potentially affecting all othermodels.pyfiles.
vllm/model_executor/models/dots_ocr.pyvllm/model_executor/models/ernie45_vl.pyvllm/model_executor/models/glm4_1v.pyvllm/model_executor/models/qwen2_vl.pyvllm/model_executor/models/siglip2navit.py
Proposed Change.
NOTE: More changes to the details will come in while I am writing up a version with all these changes.
For a first quick reorganization of the ViT Attention while retaining current use of --mm-encoder-atttention-backend interface, introduced in the PR is #27061 , and a bugfix PR #27124 .
-
First, we should shrink down the https://github.com/vllm-project/vllm/pull/27061/files#r2443909604 the
_Backendby introducing another_MHA_Backendregistry. -
Make sure that the ViT attention is a platform specific. We should determine
platforminterface. We also perform override in theplatforminterface. We should avoid doing that in themodel.pyfiles.
-
get_vit_attn_backendin theplatforminterface has to be able to access the--mm-encoder-attn-backend. -
In the
platforminterface, we should only return_MHA_Backend, we should not return the functions. The functions should only be returned throughmaybe_get_vit_flash_attn_backend. -
Honor
--mm-encoder-attn-backendso that we can write unit tests to test all different backends. AMD Instinct GPU is able to test all backends. Radeon GPUs only are able to use the TORCH_SDPA code path. -
We need to deprecate this line
https://github.com/vllm-project/vllm/blob/33a0ea5f3264b5b2f571b8a53357e10efcc94670/vllm/model_executor/models/vision.py#L96it is usingVLLM_ATTENTION_BACKENDwhich is for Text Backbone. The ViT should not use this environment variable. -
Added a
logger.info_onceso that users know which_MHA_Backendis selected in the end. -
Clean up cuda code path. Since
vllm.vllm_flash_attnis just a wrapper forflash_attnlibrary, on cuda, we always usevllm.vllm_flash_attninstead offlash_attn. -
.
Lines 120 to 125 in ba33e88
elif current_platform.is_cuda(): if attn_backend != _Backend.FLASH_ATTN and check_upstream_fa_availability( torch.get_default_dtype() ): attn_backend = _Backend.FLASH_ATTN use_upstream_fa = True
- Enable unit tests to test all different backends. Since there are large model sizes, we will check the VRAM size, if it is large enough, we run it. We provide such a unit test so that developers can run locally.
Feedback Period.
Changes
CC List.
@ywang96 @DarkLight1337 @Isotr0py
Any Other Things.
No response
Before submitting a new issue...
- Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.