通过逐令牌预路由与融合内核优化,让动态适配器推理快2.4倍以上。
AdaFuse: Accelerating Dynamic Adapter Inference via Token-Level Pre-Gating and Fused Kernel Optimization
- 先全局决策每个令牌的适配器路径,避免重复调度
- 单次内核操作合并所有选中LoRA参数,减少计算开销
- 适合追求高推理效率的动态适配器应用
将动态稀疏结构(如MoE)与参数高效适配器(如LoRA)结合是提升大语言模型能力的有效方法。然而,这种架构虽仅小幅增加计算量,却导致推理延迟飙升,解码速度下降超2.5倍。通过细粒度分析,我们发现瓶颈并非计算本身,而是传统动态路由带来的碎片化、串行CUDA内核启动开销。为此,我们提出AdaFuse框架,通过算法与硬件系统的协同设计,实现高效动态适配器执行。不同于传统的层或块级路由,AdaFuse采用逐令牌预路由策略,在处理前对所有适配器层做出一次全局路由决策,实现‘一次决定,全层应用’,静态化每个令牌的执行路径,为整体优化创造条件。我们进一步开发了定制化CUDA内核,实现融合切换操作,单次遍历完成所有选中LoRA参数的合并。在多个主流开源LLM上的实验表明,AdaFuse在保持与最先进动态适配器相当精度的同时,将解码延迟降低超过2.4倍,有效弥合了模型能力与推理效率之间的差距。
原文摘要 · Abstract (English)
The integration of dynamic, sparse structures like Mixture-of-Experts (MoE) with parameter-efficient adapters (e.g., LoRA) is a powerful technique for enhancing Large Language Models (LLMs). However, this architectural enhancement comes at a steep cost: despite minimal increases in computational load, the inference latency often skyrockets, leading to decoding speeds slowing by over 2.5 times. Through a fine-grained performance analysis, we pinpoint the primary bottleneck not in the computation itself, but in the severe overhead from fragmented, sequential CUDA kernel launches required for conventional dynamic routing. To address this challenge, we introduce AdaFuse, a framework built on a tight co-design between the algorithm and the underlying hardware system to enable efficient dynamic adapter execution. Departing from conventional layer-wise or block-wise routing, AdaFuse employs a token-level pre-gating strategy, which makes a single, global routing decision for all adapter layers before a token is processed. This "decide-once, apply-everywhere" approach effectively staticizes the execution path for each token, creating an opportunity for holistic optimization. We capitalize on this by developing a custom CUDA kernel that performs a fused switching operation, merging the parameters of all selected LoRA adapters into the backbone model in a single, efficient pass. Experimental results on popular open-source LLMs show that AdaFuse achieves accuracy on par with state-of-the-art dynamic adapters while drastically cutting decoding latency by a factor of over 2.4x, thereby bridging the gap between model capability and inference efficiency.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。