Skip to content

Commit 4c291e4

Browse files
committed
release
1 parent 95f1271 commit 4c291e4

File tree

6 files changed

+48
-1757
lines changed

6 files changed

+48
-1757
lines changed

README.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
<p align="center">
44
| <a href="https://sites.google.com/view/
5-
medusa-llm"><b>Blog</b></a> | <a href="ROADMAP.md"><b>Roadmap</b></a> |
5+
medusa-llm"><b>Blog</b></a> | <a href="https://arxiv.org/abs/2401.10774"><b>Report</b></a> | <a href="ROADMAP.md"><b>Roadmap</b></a> |
66
</p>
77

88
---
99
*News* 🔥
10-
- [2023/09] Medusa won the [Chai Prize Grant](https://twitter.com/tianle_cai/status/1703891335147897341)🎉 The prize will be used as a development bounty for those who help us achieve milestones in our [roadmap](https://github.com/FasterDecoding/Medusa/issues/3)!
11-
- [2023/09] Medusa v0.1 is released!
10+
- [2024/1] Medusa technical report is now available on [arXiv](https://arxiv.org/abs/2401.10774). We've added multiple new features, including Medusa-2 recipe for full-model training, self-distillation for adding Medusa to any fine-tuned LLM, etc. The new results show a 2.2-3.6x speedup over the original model on a range of LLMs.
1211

1312
---
1413
## Introduction
@@ -21,7 +20,7 @@ Medusa is a simple framework that democratizes the acceleration techniques for L
2120
</picture>
2221
<br>
2322
<div align="center" width="80%">
24-
<em>Medusa on Vicuna-7b.</em>
23+
<em>Medusa-1 on Vicuna-7b.</em>
2524
</div>
2625
<br>
2726
</div>
@@ -50,19 +49,25 @@ We aim to solve the challenges associated with speculative decoding by implement
5049
- Instead of introducing a new model, we train multiple decoding heads on the *same* model.
5150
- The training is parameter-efficient so that even the "GPU-Poor" can do it. And since there is no additional model, there is no need to adjust the distributed computing setup.
5251
- Relaxing the requirement of matching the distribution of the original model makes the non-greedy generation even faster than greedy decoding.
52+
53+
In the initial release, our primary focus is on optimizing Medusa for a batch size of 1—a setting commonly utilized for local model hosting. In this configuration, Medusa delivers approximately a 2x speed increase across a range of Vicuna models. We are actively working to extend Medusa's capabilities by integrating it into additional inference frameworks, with the aim of achieving even greater performance gains and extending Medusa to broader settings.
54+
5355
<p align="center">
5456
<picture>
55-
<img src="assets/size_speedup.png" width="45%">
57+
<img src="assets/medusa_speedup_cmp.jpg" width="45%">
5658
</picture>
5759
</p>
58-
In this initial release, our primary focus is on optimizing Medusa for a batch size of 1—a setting commonly utilized for local model hosting. In this configuration, Medusa delivers approximately a 2x speed increase across a range of Vicuna models. We are actively working to extend Medusa's capabilities by integrating it into additional inference frameworks, with the aim of achieving even greater performance gains and extending Medusa to broader settings.
60+
61+
In the updated version, we add support for full-model training, called Medusa-2 (compared to Medusa-1, which only trains the new heads), which requires a special recipe that adds the speculative prediction ability while keeping the original model's performance.
62+
63+
We also add support for self-distillation, which allows us to add Medusa to any fine-tuned LLM without requiring the availability of the original training data.
5964

6065
## Contents
6166
- [Introduction](#introduction)
6267
- [Contents](#contents)
6368
- [Installation](#installation)
6469
- [Method 1: With pip](#method-1-with-pip)
65-
- [Method 2: From source](#method-2-from-source)
70+
- [Method 2: From source (recommended)](#method-2-from-source)
6671
- [Model Weights](#model-weights)
6772
- [Inference](#inference)
6873
- [Training](#training)
@@ -75,24 +80,34 @@ In this initial release, our primary focus is on optimizing Medusa for a batch s
7580
- [Acknowledgements](#acknowledgements)
7681

7782
## Installation
78-
### Method 1: With pip
83+
### Method 1: With pip (may not be the latest version)
7984
```bash
8085
pip install medusa-llm
8186
```
82-
### Method 2: From the source
87+
### Method 2: From the source (recommended)
8388
```bash
8489
git clone https://github.com/FasterDecoding/Medusa.git
8590
cd Medusa
8691
pip install -e .
8792
```
8893

8994
### Model Weights
95+
#### Medusa-1
9096
| Size | Chat Command | Hugging Face Repo |
9197
| ---- | --------------------------------------------- | --------------------------------------------------------------------- |
9298
| 7B | `python -m medusa.inference.cli --model FasterDecoding/medusa-vicuna-7b-v1.3` | [FasterDecoding/medusa-vicuna-7b-v1.3](https://huggingface.co/FasterDecoding/medusa-vicuna-7b-v1.3) |
9399
| 13B | `python -m medusa.inference.cli --model FasterDecoding/medusa-vicuna-13b-v1.3` | [FasterDecoding/medusa-vicuna-13b-v1.3](https://huggingface.co/FasterDecoding/medusa-vicuna-13b-v1.3) |
94100
| 33B | `python -m medusa.inference.cli --model FasterDecoding/medusa-vicuna-33b-v1.3` | [FasterDecoding/medusa-vicuna-33b-v1.3](https://huggingface.co/FasterDecoding/medusa-vicuna-33b-v1.3) |
95101

102+
#### Medusa-2
103+
| Size | Chat Command | Hugging Face Repo |
104+
| ---- | --------------------------------------------- | --------------------------------------------------------------------- |
105+
| Zephyr-7B-Beta | `python -m medusa.inference.cli --model FasterDecoding/medusa-1.0-zephyr-7b-beta` | [FasterDecoding/medusa-1.0-zephyr-7b-beta](https://huggingface.co/FasterDecoding/medusa-1.0-zephyr-7b-beta) |
106+
| Vicuna-7B-v1.5 | `python -m medusa.inference.cli --model FasterDecoding/medusa-1.0-vicuna-7b-v1.5` | [FasterDecoding/medusa-1.0-vicuna-7b-v1.5](https://huggingface.co/FasterDecoding/medusa-1.0-vicuna-7b-v1.5) |
107+
| Vicuna-13B-v1.5 | `python -m medusa.inference.cli --model FasterDecoding/medusa-1.0-vicuna-13b-v1.5` | [FasterDecoding/medusa-1.0-vicuna-13b-v1.5](https://huggingface.co/FasterDecoding/medusa-1.0-vicuna-13b-v1.5) |
108+
| Vicuna-33B-v1.5 | `python -m medusa.inference.cli --model FasterDecoding/medusa-1.0-vicuna-33b-v1.5` | [FasterDecoding/medusa-1.0-vicuna-33b-v1.5](https://huggingface.co/FasterDecoding/medusa-1.0-vicuna-33b-v1.5) |
109+
110+
96111
### Inference
97112
We currently support single-GPU inference with a batch size of 1, which is the most common setup for local model hosting. We are actively working to extend Medusa's capabilities by integrating it into other inference frameworks; please don't hesitate to reach out if you are interested in contributing to this effort.
98113

@@ -103,6 +118,11 @@ CUDA_VISIBLE_DEVICES=0 python -m medusa.inference.cli --model [path of medusa mo
103118
You can also pass `--load-in-8bit` or `--load-in-4bit` to load the base model in quantized format. If you download the base model elsewhere, you may override base model name or path with `--base-model [path of base model]`.
104119

105120
### Training
121+
In the updated version, we use the amazing [axolotl](https://github.com/OpenAccess-AI-Collective/axolotl) library to manage the training process. Please refer to our [fork](https://github.com/ctlllll/axolotl) for the training code. The major code modifications are in [`src/axolotl/utils/models.py`](https://github.com/ctlllll/axolotl/blob/main/src/axolotl/utils/models.py). The training configs can be found in [`examples/medusa`](https://github.com/ctlllll/axolotl/tree/main/examples/medusa).
122+
123+
The data preparation code for self-distillation can be found in [`data_generation` folder](data_generation) of the current repo.
124+
125+
### Training (legacy)
106126
For training, please install:
107127
```bash
108128
pip install -e ".[train]"
@@ -148,13 +168,11 @@ python -m medusa.hf_utils --folder [path of the model folder] --repo [name of th
148168

149169
## Citation
150170
```bibtex
151-
@misc{medusa,
152-
author = {Tianle Cai and Yuhong Li and Zhengyang Geng and Hongwu Peng and Tri Dao},
153-
title = {Medusa: Simple Framework for Accelerating LLM Generation with Multiple Decoding Heads},
154-
year = {2023},
155-
publisher = {GitHub},
156-
journal = {GitHub repository},
157-
howpublished = {\url{https://github.com/FasterDecoding/Medusa}},
171+
@article{cai2024medusa,
172+
title = {Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads},
173+
author = {Tianle Cai and Yuhong Li and Zhengyang Geng and Hongwu Peng and Jason D. Lee and Deming Chen and Tri Dao},
174+
year = {2024},
175+
journal = {arXiv preprint arXiv: 2401.10774}
158176
}
159177
```
160178

@@ -163,8 +181,16 @@ python -m medusa.hf_utils --folder [path of the model folder] --repo [name of th
163181

164182
We also provide some illustrative notebooks in `notebooks/` to help you understand the codebase.
165183

184+
## Community Adoption
185+
We are super excited to see that Medusa has been adopted by many open-source projects. Here is an (incomplete) list:
186+
- [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/medusa)
187+
- [TGI](https://github.com/huggingface/text-generation-inference/blob/main/server/text_generation_server/utils/medusa.py)
188+
We are grateful to the authors for their contributions to the community and sincerely hope that Medusa can help accelerate the development of LLMs. If you are using Medusa in your project, please let us know, and we will add your project to the list.
189+
166190
## Contributing
167191
We welcome community contributions to Medusa. If you have an idea for how to improve it, please open an issue to discuss it with us. When submitting a pull request, please ensure that your changes are well-tested. Please split each major change into a separate pull request. We also have a [Roadmap](ROADMAP.md) summarizing our future plans for Medusa. Don't hesitate to reach out if you are interested in contributing to any of the items on the roadmap.
168192

169193
## Acknowledgements
170-
This codebase is influenced by remarkable projects from the LLM community, including [FastChat](https://github.com/lm-sys/FastChat), [TinyChat](https://github.com/mit-han-lab/llm-awq/tree/main/), [vllm](https://github.com/vllm-project/vllm) and many others.
194+
This codebase is influenced by remarkable projects from the LLM community, including [FastChat](https://github.com/lm-sys/FastChat), [TinyChat](https://github.com/mit-han-lab/llm-awq/tree/main/), [vllm](https://github.com/vllm-project/vllm), [axolotl](https://github.com/OpenAccess-AI-Collective/axolotl).
195+
196+
This project is supported by [Together AI](https://together.ai/), [MyShell AI](https://myshell.ai/), [Chai AI](https://www.chai-research.com/).

ROADMAP.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Roadmap
22

33
## Functionality
4-
- [ ] Explore tree sparsity
5-
- [ ] Fine-tune Medusa heads together with LM head from scratch
6-
- [ ] Distill from any model without access to the original training data
74
- [ ] Batched inference
85
- [ ] Fine-grained KV cache management
6+
- [x] Explore tree sparsity
7+
- [x] Fine-tune Medusa heads together with LM head from scratch
8+
- [x] Distill from any model without access to the original training data
99

1010
## Integration
1111
### Local Deployment
@@ -14,9 +14,6 @@
1414
- [ ] [llama.cpp](https://github.com/ggerganov/llama.cpp)
1515
### Serving
1616
- [ ] [vllm](https://github.com/vllm-project/vllm)
17-
- [ ] [TGI](https://github.com/huggingface/text-generation-inference)
1817
- [ ] [lightllm](https://github.com/ModelTC/lightllm)
19-
20-
## Research
21-
- [x] Optimize the tree-based attention to reduce additional computation
22-
- [ ] Improve the acceptance scheme to generate more diverse sequences
18+
- [x] [TGI](https://github.com/huggingface/text-generation-inference)
19+
- [x] [TensorRT](https://github.com/NVIDIA/TensorRT-LLM)

assets/medusa_pipeline.jpg

-795 KB
Loading

assets/medusa_speedup_cmp.jpg

55.2 KB
Loading

0 commit comments

Comments
 (0)