[논문 리뷰] Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads
Medusa는 LLM 추론을 확장 헤드를 추가로 활용해 여러 토큰을 병렬로 예측하고, 트리 어텐션 메커니즘으로 후보 처리를 병렬화하며, 두 가지 미세 조정 모드(Medusa-1 고정 백본, Medusa-2 공동 학습)로 2.2x에서 3.6x의 속도 향상을 달성합니다.
Large Language Models (LLMs) employ auto-regressive decoding that requires sequential computation, with each step reliant on the previous one's output. This creates a bottleneck as each step necessitates moving the full model parameters from High-Bandwidth Memory (HBM) to the accelerator's cache. While methods such as speculative decoding have been suggested to address this issue, their implementation is impeded by the challenges associated with acquiring and maintaining a separate draft model. In this paper, we present Medusa, an efficient method that augments LLM inference by adding extra decoding heads to predict multiple subsequent tokens in parallel. Using a tree-based attention mechanism, Medusa constructs multiple candidate continuations and verifies them simultaneously in each decoding step. By leveraging parallel processing, Medusa substantially reduces the number of decoding steps required. We present two levels of fine-tuning procedures for Medusa to meet the needs of different use cases: Medusa-1: Medusa is directly fine-tuned on top of a frozen backbone LLM, enabling lossless inference acceleration. Medusa-2: Medusa is fine-tuned together with the backbone LLM, enabling better prediction accuracy of Medusa heads and higher speedup but needing a special training recipe that preserves the backbone model's capabilities. Moreover, we propose several extensions that improve or expand the utility of Medusa, including a self-distillation to handle situations where no training data is available and a typical acceptance scheme to boost the acceptance rate while maintaining generation quality. We evaluate Medusa on models of various sizes and training procedures. Our experiments demonstrate that Medusa-1 can achieve over 2.2x speedup without compromising generation quality, while Medusa-2 further improves the speedup to 2.3-3.6x.
연구 동기 및 목표
- 대규모 언어 모델의 추론 처리량을 decoding 단계 감소로 향상시키되 품질을 손상시키지 않는다.
- 백본 모델에 추가 디코딩 헤드를 활용해 draft 모델의 필요성을 제거한다.
- 다양한 리소스 및 데이터 가용성 시나리오에 맞춘 유연한 학습 절차를 제공한다.
- 데이터가 부족한 설정을 다루고 효율성을 높이기 위한 확장(일반 수용, 자기 증류 등)을 제공한다.
제안 방법
- 백본의 마지막 은닉 상태에 K개의 디코딩 헤드를 부착해 후속 토큰을 예측한다.
- 트리 구조의 어텐션 마스크를 사용해 여러 후보 연속을 병렬로 처리한다.
- 두 가지 방식으로 헤드를 미세 조정한다: Medusa-1(고정 백본) 또는 Medusa-2(백본+헤드 공동 학습).
- 일반 수용 체계를 도입해 거부 샘플링에 의지하지 않고 그럴듯한 후보를 선택한다.
- 자체 증류를 통해 학습 데이터가 없는 경우 데이터를 생성하고, 트리 구성에 대한 데이터/ 보정 방법을 논의한다.

실험 결과
연구 질문
- RQ1다양한 decoding 헤드가 백본 모델을 변경하지 않고도 여러 미래 토큰의 병렬 예측을 가능하게 할 수 있는가?
- RQ2추론 가속화를 유지하면서 백본 성능을 보존하거나 향상시키기 위한 효과적인 학습 전략(Medusa-1 대 Medusa-2)은 무엇인가?
- RQ3제시된 일반 수용 체계가 생성 품질을 유지하면서 디코딩 효율을 개선하는가?
- RQ4Medusa 헤드를 사용해 모델 크기와 학습 방식에 따라 어떤 속도 향상이 가능한가?
- RQ5데이터가 부족한 조건에서 자기 증류 및 최적화된 트리 구성 같은 확장이 성능에 어떤 영향을 미치는가?
주요 결과
- Medusa-1은 생성 품질을 손상시키지 않으면서 2.2x 이상의 속도 향상을 달성한다.
- Medusa-2는 속도 향상을 2.3x–3.6x까지 더 개선할 수 있다.
- 다양한 크기의 모델 및 학습 절차에서 이 접근 방식이 통한다(예: Vicuna 7B, 13B, 33B, Zephyr-7B).
- 두 가지 학습 모드(고정 백본 대 공동 학습)는 제한된 하드웨어에서의 유연한 배치나 전체 미세 조정이 필요한 경우에 유용하다.
- 자체 증류 및 일반 수용과 같은 확장은 데이터 부재 상황을 다루고 효율성을 높이는 데 도움을 준다.

이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.