-
Notifications
You must be signed in to change notification settings - Fork 381
feat: Add TensorRT Edge-LLM AttentionPlugin backend support #4013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@zewenli98 please review |
| This example uses a custom TensorRT plugin shared library (``libNvInfer_edgellm_plugin.so``) | ||
| that replaces standard transformer attention operations and RoPE computations with optimized | ||
| CUDA kernels. The plugin source code is available at (internal access only): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chohk88 can you change this to external links?
| - kv_cache_start_idx: [B] starting index in KV cache (required for release version) | ||
| """ | ||
|
|
||
| @torch.library.custom_op("xqa::attn", mutates_args=()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets call the op tensorrt_edge_llm::xqa_attn
| - kv_cache_start_idx: [B] starting index in KV cache (required for release version) | ||
| """ | ||
|
|
||
| @torch.library.custom_op("xqa::attn", mutates_args=()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here: tensorrt_edge_llm::xqa_attn
| nkv: int, | ||
| d: int, | ||
| ) -> Tuple[torch.Tensor, torch.Tensor]: | ||
| batch_size = qkv.shape[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to provide a valid implementation here easily? could we lift the kernel from the .so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a P1/P2 sort of thing, but I think it would be good for the sake of completeness
Description
This PR adds TensorRT Edge-LLM AttentionPlugin backend support as an alternative to the default SDPA lowering, providing 1.7x ~ 3.3x performance improvement for LLM inference.
Supported Models: Llama 3.x (3.1 and 3.2), Qwen 2.5, Qwen 3, Qwen3.1
This is a temporary solution for the initial implementation. The fork contains Torch-TRT compatibility Python runtime support that is not yet available in the official NVIDIA TensorRT-Edge-LLM repository.
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: