图模式指南#

注意

此功能目前处于实验阶段。在未来的版本中,配置、覆盖率和性能改进等方面可能会有行为变更。

本指南提供了使用 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:这是 euler xlite 的图模式。在 v0.11.0 版本中,仅支持 Llama 和 Qwen dense 系列模型。

使用 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 系列模型,请安装 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