How to set TensorRT-LLM to use Flash Attention 3
How does TensorRT-LLM control whether to load flash attention? I tried to install flash attention 2.6.3 (which includes the right swipe module hopper for H100) from the source code, but the FTT and throughput running on TensorRT-LLM on H100 before and after installation were basically the same, and it seems that I did not use the flash attention I installed. Please provide some ideas and suggestions, thank you very much.
They don't use external flash attention. It's all packaged into these binary kernels here https://github.com/NVIDIA/TensorRT-LLM/tree/main/cpp/tensorrt_llm/kernels/contextFusedMultiHeadAttention/cubin
Probably have to wait for nvidia to update it.
Thank you very much for your response.
May I ask again, are the files packaged into these binary kernels compiled from the official source code of Flash-attention or written by the TensorRT-LLM project itself? Also, let's call these binary kernel files internal flash-attention for now. How can we set TensorRT-LLM to enable or disable internal flash-attention?
In the config. json configuration file of the Qwen 7B model, I found the "use_flash-attn": "auto" parameter. I tried adjusting this value to True or False, but the inference result was not significantly different. So what is the use of this parameter for TensorRT-LLM?
Are the files packaged into these binary kernels compiled from the official source code of Flash-attention or written by the TensorRT-LLM project itself?
Those kernels do not use the official source code of Flash-attention.
How can we set TensorRT-LLM to enable or disable internal flash-attention?
context_fmha_type controls the attention type in the context phase. You can disable it with --context_fmha disable, then the attention will be implemented with the unfused kernels. In the Generation phase, the masked MHA kernel will be used for attentions. Please refer to the gpt-attention docs for more details: https://github.com/NVIDIA/TensorRT-LLM/blob/main/docs/source/advanced/gpt-attention.md#context-and-generation-phases
What is the use of "use_flash_attn": "auto" for TensorRT-LLM?
TensorRT-LLM don't use this parameter and only read this config when converting checkpoints.
Thank you!I finally understand it.