图模式#

备注

此功能目前处于实验性阶段。在未来的版本中,配置方式、模型覆盖率以及性能优化方面的行为可能会有所变化。

本指南提供了在 vLLM Ascend 上使用 Ascend 图模式的说明。请注意,图模式仅在 V1 引擎上可用。自 0.9.0rc1 版本起,目前仅 Qwen 和 DeepSeek 系列模型经过了充分测试。我们将在下一个版本中提升其稳定性和通用性。

快速入门#

从 v0.9.1rc1 版本起,搭配 V1 引擎使用时,vLLM Ascend 默认将以图模式运行模型,以保持与 vLLM 官方行为一致。如果您遇到任何问题,欢迎在 GitHub 上提交 Issue,并在初始化模型时通过设置 enforce_eager=True 临时回退到 Eager 模式。

vLLM Ascend 支持两种图模式:

  • ACLGraph:这是 vLLM Ascend 支持的默认图模式。在 v0.9.1rc1 版本中,Qwen 和 DeepSeek 系列模型已得到充分测试。

  • XliteGraph:这是 openEuler 的 Xlite 图模式。在 v0.11.0 版本中,仅支持 Llama、Qwen 全量(dense)系列模型以及 Qwen3-vl。

使用 ACLGraph#

ACLGraph 默认启用。以 Qwen 系列模型为例,只需确保使用 V1 引擎即可。

离线推理示例:

import os

from vllm import LLM

model = LLM(model="path/to/Qwen2-7B-Instruct")
outputs = model.generate("Hello, how are you?")

在线服务示例:

vllm serve Qwen/Qwen2-7B-Instruct

使用 XliteGraph#

如果您希望在 Xlite 图模式下运行 Llama、Qwen dense 系列或 Qwen3-vl 模型,请安装 xlite 并设置 xlite_graph_config

pip install xlite

离线推理示例:

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?")

在线服务示例:

vllm serve path/to/Qwen3-32B --tensor-parallel-size 8 --additional-config='{"xlite_graph_config": {"enabled": true, "full_mode": true}}'

您可以在此处找到更多关于 Xlite 的详细信息。

回退到 Eager 模式#

如果 ACLGraphXliteGraph 均无法运行,您应当回退到 Eager 模式。

离线推理示例:

import os
from vllm import LLM

model = LLM(model="someother_model_weight", enforce_eager=True)
outputs = model.generate("Hello, how are you?")

在线服务示例:

vllm serve someother_model_weight --enforce-eager