Repository navigation
refactor: inherit TRTLLMHAAttnBackend directly from AttentionBackend (#28808) - #44117
Asthenia0412 wants to merge 1 commit into
Conversation
…28808) Remove unnecessary inheritance from FlashInferAttnBackend since TRTLLM path only reuses a tiny portion of the parent __init__. Now inherits directly from base AttentionBackend, avoiding wasted allocation of FlashInfer wrappers and updaters that TRTLLM never uses. Author: yancy (Asthenia0412) Signed-off-by: Asthenia0412 <yancy@users.noreply.github.com>
|
Hey @reviewers! I've refactored TRTLLMHAAttnBackend and TRTLLMHAAttnMultiStepDraftBackend to inherit directly from AttentionBackend instead of FlashInferAttnBackend. The FlashInfer inheritance was a massive waste since TRTLLM overrides 95% of parent methods and never uses FlashInfer wrappers/updaters. Just inherited what TRTLLM actually needs (pool setup + kv_indptr buffers). Could you take a quick look? The change is localized to one file and fully backward-compatible. |
|
Hi! The CI currently shows skipped jobs because this repo requires the Could someone please add the @lm-sys @zhyncs @hnyls2002 @ispobock @BBuf @Fridge003 @kevin-mii |
|
Thanks for your interest in SGLang. This account opened 16 PRs in about eight hours, across unrelated subsystems (attention backends, speculative decoding, diffusion loading, scheduler IPC, KV-cache compression, docs), including two PRs for the same change (#44073 and #44117, both for #28808) and a fix for #43929 that is already on main. We can't review contributions at this volume, so we are closing the ones still open. If you want to pursue one, please pick a single change, verify it on a real run (a repro, a test, or numbers), and open a fresh PR. |
Problem
TRTLLMHAAttnBackend 继承自 FlashInferAttnBackend,但实际上只复用了少量 init 代码。这导致每次实例化 TRTLLMHAAttnBackend 时都会浪费大量资源:
prefill_wrapper_ragged,prefill_wrappers_paged,prefill_wrappers_verify,decode_wrappers(BatchPrefillWithPagedKVCacheWrapper, BatchDecodeWithPagedKVCacheWrapper 等)TRTLLMHAAttnMultiStepDraftBackend 继承自 FlashInferMultiStepDraftBackend,后者同样不是 AttentionBackend 子类,只是实现了 init_forward_metadata/init_cuda_graph_state 等接口方法。
Solution
TRTLLMHAAttnBackend
TRTLLMHAAttnMultiStepDraftBackend
Changes
仅修改了一个文件: python/sglang/srt/layers/attention/trtllm_mha_backend.py (+52 / -18)
Testing
Fixes: #28808
Author: yancy (Asthenia0412)
CI States
Latest PR Test (Base): ❌ Run #38461119613
Latest PR Test (Extra): ❌ Run #38461119568
Latest PR Test (AMD ROCm 10): ❌ Run #38461119645