2025-06-06 21:14:34 +08:00
# Graph Mode Guide
2025-06-25 19:28:26 +08:00
```{note}
2025-06-06 21:14:34 +08:00
This feature is currently experimental. In future versions, there may be behavioral changes around configuration, coverage, performance improvement.
2025-06-25 19:28:26 +08:00
```
2025-06-06 21:14:34 +08:00
2025-10-29 11:03:39 +08:00
This guide provides instructions for using Ascend Graph Mode with vLLM Ascend. Please note that graph mode is only available on V1 Engine. And only Qwen, DeepSeek series models are well tested from 0.9.0rc1. We will make it stable and generalized in the next release.
2025-06-06 21:14:34 +08:00
## Getting Started
2025-11-08 18:48:59 +08:00
From v0.9.1rc1 with V1 Engine, vLLM Ascend will run models in graph mode by default to keep the same behavior with vLLM. If you hit any issues, please feel free to open an issue on GitHub and fallback to the eager mode temporarily by setting `enforce_eager=True` when initializing the model.
2025-06-06 21:14:34 +08:00
2025-12-08 08:27:46 +08:00
There are three kinds for graph mode supported by vLLM Ascend:
2025-11-13 15:53:58 +08:00
- **ACLGraph**: This is the default graph mode supported by vLLM Ascend. In v0.9.1rc1, Qwen and Deepseek series models are well tested.
2025-07-08 14:18:17 +08:00
- **TorchAirGraph**: This is the GE graph mode. In v0.9.1rc1, only DeepSeek series models are supported.
2025-12-08 08:27:46 +08:00
- **XliteGraph**: This is the euler xlite graph mode. In v0.11.0, only Llama and Qwen dense serise models are supported.
2025-06-06 21:14:34 +08:00
## Using ACLGraph
ACLGraph is enabled by default. Take Qwen series models as an example, just set to use V1 Engine is enough.
2025-10-29 11:03:39 +08:00
Offline example:
2025-06-06 21:14:34 +08:00
```python
import os
from vllm import LLM
2025-11-13 15:53:58 +08:00
model = LLM(model="path/to/Qwen2-7B-Instruct")
2025-06-06 21:14:34 +08:00
outputs = model.generate("Hello, how are you?")
```
2025-10-29 11:03:39 +08:00
Online example:
2025-06-06 21:14:34 +08:00
```shell
vllm serve Qwen/Qwen2-7B-Instruct
```
## Using TorchAirGraph
2025-10-29 11:03:39 +08:00
If you want to run DeepSeek series models with the graph mode, you should use [TorchAirGraph ](https://www.hiascend.com/document/detail/zh/Pytorch/700/modthirdparty/torchairuseguide/torchair_0002.html ). In this case, additional configuration is required.
2025-06-06 21:14:34 +08:00
2025-10-29 11:03:39 +08:00
Offline example:
2025-06-06 21:14:34 +08:00
```python
import os
from vllm import LLM
2025-11-13 15:53:58 +08:00
# TorchAirGraph only works without chunked-prefill now
2025-12-02 14:22:56 +08:00
model = LLM(model="path/to/DeepSeek-R1-0528", additional_config={"torchair_graph_config": {"enabled": True}})
2025-06-06 21:14:34 +08:00
outputs = model.generate("Hello, how are you?")
```
2025-10-29 11:03:39 +08:00
Online example:
2025-06-06 21:14:34 +08:00
```shell
2025-12-02 14:22:56 +08:00
vllm serve path/to/DeepSeek-R1-0528 --additional-config='{"torchair_graph_config": {"enabled": true}}'
2025-06-06 21:14:34 +08:00
```
2025-10-29 11:03:39 +08:00
You can find more details about additional configuration [here ](../configuration/additional_config.md ).
2025-06-06 21:14:34 +08:00
2025-12-08 08:27:46 +08:00
## Using XliteGraph
If you want to run Llama or Qwen dense series models with xlite graph mode, please install xlite, and set xlite_graph_config.
```bash
pip install xlite
```
Offline example:
```python
import os
from vllm import LLM
# xlite supports the decode-only mode by default, and the full mode can be enabled by setting: "full_mode": True
model = LLM(model="path/to/Qwen3-32B", tensor_parallel_size=8, additional_config={"xlite_graph_config": {"enabled": True, "full_mode": True}})
outputs = model.generate("Hello, how are you?")
```
Online example:
```shell
vllm serve path/to/Qwen3-32B --tensor-parallel-size 8 --additional-config='{"xlite_graph_config": {"enabled": true, "full_mode": true}}'
```
You can find more details abort xlite [here ](https://gitee.com/openeuler/GVirt/blob/master/xlite/README.md )
2025-10-29 11:03:39 +08:00
## Fallback to the Eager Mode
2025-06-06 21:14:34 +08:00
2025-12-08 08:27:46 +08:00
If `ACLGraph` , `TorchAirGraph` and `XliteGraph` all fail to run, you should fallback to the eager mode.
2025-06-06 21:14:34 +08:00
2025-10-29 11:03:39 +08:00
Offline example:
2025-06-06 21:14:34 +08:00
```python
import os
from vllm import LLM
model = LLM(model="someother_model_weight", enforce_eager=True)
outputs = model.generate("Hello, how are you?")
```
2025-10-29 11:03:39 +08:00
Online example:
2025-06-06 21:14:34 +08:00
```shell
2025-11-08 18:48:59 +08:00
vllm serve someother_model_weight --enforce-eager
2025-06-06 21:14:34 +08:00
```