Text Generation
Transformers
Safetensors
qwen3
feature-extraction
dflash
speculative-decoding
diffusion
efficiency
flash-decoding
qwen
kimi
diffusion-language-model
custom_code
text-generation-inference
Instructions to use z-lab/Kimi-K2.5-DFlash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use z-lab/Kimi-K2.5-DFlash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="z-lab/Kimi-K2.5-DFlash", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("z-lab/Kimi-K2.5-DFlash", trust_remote_code=True) model = AutoModel.from_pretrained("z-lab/Kimi-K2.5-DFlash", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use z-lab/Kimi-K2.5-DFlash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "z-lab/Kimi-K2.5-DFlash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "z-lab/Kimi-K2.5-DFlash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/z-lab/Kimi-K2.5-DFlash
- SGLang
How to use z-lab/Kimi-K2.5-DFlash with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "z-lab/Kimi-K2.5-DFlash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "z-lab/Kimi-K2.5-DFlash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "z-lab/Kimi-K2.5-DFlash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "z-lab/Kimi-K2.5-DFlash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use z-lab/Kimi-K2.5-DFlash with Docker Model Runner:
docker model run hf.co/z-lab/Kimi-K2.5-DFlash
Update README.md
Browse files
README.md
CHANGED
|
@@ -20,7 +20,7 @@ tags:
|
|
| 20 |
|
| 21 |
**DFlash** is a novel speculative decoding method that utilizes a lightweight **block diffusion** model for drafting. It enables efficient, high-quality parallel drafting that pushes the limits of inference speed.
|
| 22 |
|
| 23 |
-
This model is the **drafter** component. It must be used in conjunction with the target model `moonshotai/Kimi-K2.5`.
|
| 24 |
|
| 25 |
<div align="center">
|
| 26 |
<img src="assets/dflash_system.png" alt="DFlash Architecture" width="100%">
|
|
@@ -36,6 +36,8 @@ uv pip install vllm
|
|
| 36 |
uv pip install -U vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly
|
| 37 |
```
|
| 38 |
|
|
|
|
|
|
|
| 39 |
SGLang:
|
| 40 |
```bash
|
| 41 |
uv pip install "git+https://github.com/sgl-project/sglang.git@refs/pull/20547/head#subdirectory=python"
|
|
@@ -46,8 +48,8 @@ uv pip install "git+https://github.com/sgl-project/sglang.git@refs/pull/20547/he
|
|
| 46 |
vLLM:
|
| 47 |
```bash
|
| 48 |
vllm serve moonshotai/Kimi-K2.5 \
|
| 49 |
-
--speculative-config '{"method": "dflash", "model": "z-lab/Kimi-K2.5-DFlash", "num_speculative_tokens":
|
| 50 |
-
--attention-backend
|
| 51 |
--max-num-batched-tokens 32768
|
| 52 |
```
|
| 53 |
|
|
@@ -62,10 +64,12 @@ python -m sglang.launch_server \
|
|
| 62 |
--model-path moonshotai/Kimi-K2.5 \
|
| 63 |
--speculative-algorithm DFLASH \
|
| 64 |
--speculative-draft-model-path z-lab/Kimi-K2.5-DFlash \
|
| 65 |
-
--speculative-num-draft-tokens
|
| 66 |
--tp-size 8 \
|
| 67 |
-
--attention-backend
|
|
|
|
| 68 |
--mem-fraction-static 0.9 \
|
|
|
|
| 69 |
--trust-remote-code
|
| 70 |
```
|
| 71 |
> **Tip:** For long-context or agentic workloads, add `--speculative-dflash-draft-window-size WINDOW_SIZE` to enable sliding-window attention for the drafter.
|
|
@@ -88,9 +92,8 @@ print(response.choices[0].message.content)
|
|
| 88 |
## Early Results
|
| 89 |
- Thinking: enabled
|
| 90 |
- Max new tokens: 4096
|
| 91 |
-
- Block size:
|
| 92 |
- SGLang results. vLLM results might be different.
|
| 93 |
-
- Epoch 1.8
|
| 94 |
| Dataset | Accept Length |
|
| 95 |
|-----------|---------------|
|
| 96 |
| GSM8K | 5.8 |
|
|
|
|
| 20 |
|
| 21 |
**DFlash** is a novel speculative decoding method that utilizes a lightweight **block diffusion** model for drafting. It enables efficient, high-quality parallel drafting that pushes the limits of inference speed.
|
| 22 |
|
| 23 |
+
This model is the **drafter** component. It must be used in conjunction with the target model `moonshotai/Kimi-K2.5`.
|
| 24 |
|
| 25 |
<div align="center">
|
| 26 |
<img src="assets/dflash_system.png" alt="DFlash Architecture" width="100%">
|
|
|
|
| 36 |
uv pip install -U vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly
|
| 37 |
```
|
| 38 |
|
| 39 |
+
Please refer to [PR39930](https://github.com/vllm-project/vllm/pull/39930) to see how to use DFlash on vLLM.
|
| 40 |
+
|
| 41 |
SGLang:
|
| 42 |
```bash
|
| 43 |
uv pip install "git+https://github.com/sgl-project/sglang.git@refs/pull/20547/head#subdirectory=python"
|
|
|
|
| 48 |
vLLM:
|
| 49 |
```bash
|
| 50 |
vllm serve moonshotai/Kimi-K2.5 \
|
| 51 |
+
--speculative-config '{"method": "dflash", "model": "z-lab/Kimi-K2.5-DFlash", "num_speculative_tokens": 7}' \
|
| 52 |
+
--attention-backend flashinfer \
|
| 53 |
--max-num-batched-tokens 32768
|
| 54 |
```
|
| 55 |
|
|
|
|
| 64 |
--model-path moonshotai/Kimi-K2.5 \
|
| 65 |
--speculative-algorithm DFLASH \
|
| 66 |
--speculative-draft-model-path z-lab/Kimi-K2.5-DFlash \
|
| 67 |
+
--speculative-num-draft-tokens 8 \
|
| 68 |
--tp-size 8 \
|
| 69 |
+
--attention-backend trtllm_mla \
|
| 70 |
+
--speculative-draft-attention-backend fa4 \
|
| 71 |
--mem-fraction-static 0.9 \
|
| 72 |
+
--speculative-dflash-draft-window-size 4096 \
|
| 73 |
--trust-remote-code
|
| 74 |
```
|
| 75 |
> **Tip:** For long-context or agentic workloads, add `--speculative-dflash-draft-window-size WINDOW_SIZE` to enable sliding-window attention for the drafter.
|
|
|
|
| 92 |
## Early Results
|
| 93 |
- Thinking: enabled
|
| 94 |
- Max new tokens: 4096
|
| 95 |
+
- Block size: 8
|
| 96 |
- SGLang results. vLLM results might be different.
|
|
|
|
| 97 |
| Dataset | Accept Length |
|
| 98 |
|-----------|---------------|
|
| 99 |
| GSM8K | 5.8 |
|