Add model card, pipeline tag, and links to code & paper
#1
by nielsr HF Staff - opened
README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: text-generation
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# JetSpec: Parallel Tree Drafting
|
| 7 |
+
|
| 8 |
+
JetSpec is an implementation of **parallel tree drafting** for fast LLM speculative decoding inference with up to 10x acceptance length, and 1000+ TPS on coding and math tasks. This repository contains the trained speculative drafting head presented in the paper [JetSpec: Breaking the Scaling Ceiling of Speculative Decoding with Parallel Tree Drafting](https://huggingface.co/papers/2606.18394).
|
| 9 |
+
|
| 10 |
+
For more details, code, and optimized inference engine, please visit the [Official GitHub Repository](https://github.com/hao-ai-lab/JetSpec) and the [Project Webpage](https://hao-ai-lab.github.io/JetSpec).
|
| 11 |
+
|
| 12 |
+
## Method Overview
|
| 13 |
+
|
| 14 |
+
JetSpec keeps the **one-pass drafting efficiency and restores causal branch conditioning**. The draft head reads fused hidden states from the frozen target and emits per-depth logits in a single parallel pass. Tree construction spends a draft budget over high-probability branches, and the target verifies every node in one batched/tree-masked forward.
|
| 15 |
+
|
| 16 |
+
## Installation
|
| 17 |
+
|
| 18 |
+
Create an environment and install the package:
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
pip install -e '.[bench,kernel]'
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
### HF References
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
from jetspec import LLM, SamplingParams
|
| 30 |
+
|
| 31 |
+
llm = LLM("Qwen/Qwen3-8B", attn_implementation="flash_attention_2")
|
| 32 |
+
out = llm.generate(
|
| 33 |
+
"The three primary colors are",
|
| 34 |
+
SamplingParams(temperature=0.0, max_new_tokens=64),
|
| 35 |
+
)
|
| 36 |
+
print(out["text"])
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### JetSpec Inference Engine
|
| 40 |
+
|
| 41 |
+
The optimized engine uses paged KV, a Triton tree-attention backend, compiled verification, CUDA graphs, and optional session reuse.
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from jetspec import load_draft_head, DraftHeadTreeDrafter
|
| 45 |
+
from jetspec.inference_engine import JetSpecEngine, SamplingParams
|
| 46 |
+
|
| 47 |
+
engine = JetSpecEngine(
|
| 48 |
+
"Qwen/Qwen3-8B",
|
| 49 |
+
attn_backend="triton_paged_tree_compiled",
|
| 50 |
+
)
|
| 51 |
+
head = load_draft_head("JetSpec/jetspec-qwen3-8b")
|
| 52 |
+
drafter = DraftHeadTreeDrafter(
|
| 53 |
+
head,
|
| 54 |
+
target=engine.model,
|
| 55 |
+
block_size=head.block_size,
|
| 56 |
+
target_layer_ids=head.target_layer_ids,
|
| 57 |
+
)
|
| 58 |
+
out = engine.generate_tree(
|
| 59 |
+
"The three primary colors are",
|
| 60 |
+
drafter,
|
| 61 |
+
block_size=head.block_size,
|
| 62 |
+
tree_depth=20,
|
| 63 |
+
tree_width=7,
|
| 64 |
+
budget=128,
|
| 65 |
+
target_layer_ids=head.target_layer_ids,
|
| 66 |
+
sampling_params=SamplingParams(temperature=0.0, max_new_tokens=64),
|
| 67 |
+
)
|
| 68 |
+
print(out["text"])
|
| 69 |
+
print("tokens per forward:", out["tpf"])
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
## Citation
|
| 73 |
+
|
| 74 |
+
```bibtex
|
| 75 |
+
@inproceedings{jetspec2026,
|
| 76 |
+
title = {JetSpec: Breaking the Scaling Ceiling of Speculative Decoding with Parallel Tree Drafting},
|
| 77 |
+
author = {Hu, Lanxiang and Feng, Zhaoxiang and Wu, Yulun and Yuan, Haoran and Zhao, Yujie and Qian, Yu-Yang and Wang, Bojun and Zhao, Peng and Jiang, Daxin and Zhu, Yibo and Rosing, Tajana and Zhang, Hao},
|
| 78 |
+
year = {2026},
|
| 79 |
+
url = {https://arxiv.org/abs/2606.18394},
|
| 80 |
+
eprint = {2606.18394},
|
| 81 |
+
note = {Preprint}
|
| 82 |
+
}
|
| 83 |
+
```
|