附加配置

附加配置#

额外配置是 vLLM 提供的一种机制,允许插件自行控制内部行为。vLLM Ascend 利用这种机制使项目更加灵活。

如何使用#

无论是在线模式还是离线模式,用户都可以使用额外的配置。以 Qwen3 为例:

在线模式

vllm serve Qwen/Qwen3-8B --additional-config='{"config_key":"config_value"}'

离线模式

from vllm import LLM

LLM(model="Qwen/Qwen3-8B", additional_config={"config_key":"config_value"})

配置选项#

下表列出了 vLLM Ascend 中可用的其他配置选项:

名称

类型

默认

描述

torchair_graph_config

dict

{}

torchair 图模式的配置选项

ascend_scheduler_config

dict

{}

ascend 调度器的配置选项

weight_prefetch_config

dict

{}

权重预取的配置选项

刷新

bool

false

是否刷新全局 Ascend 配置信息。此值通常由 RLHF 或 UT/E2E 测试用例使用。

expert_map_path

str

None

在为 MoE 模型使用专家负载均衡时,需要传入专家映射路径。

kv_cache_dtype

str

None

当使用 KV 缓存量化方法时,需要设置 KV 缓存的数据类型,目前仅支持 int8。

enable_shared_expert_dp

bool

False

当专家在 DP 中共享时,可以获得更好的性能,但会消耗更多内存。目前仅支持 DeepSeek 系列模型。

lmhead_tensor_parallel_size

int

None

LMHead 的自定义张量并行大小。

oproj_tensor_parallel_size

int

None

OProj 的自定义张量并行大小。

multistream_overlap_shared_expert

bool

False

是否启用多流共享专家功能。此选项仅对具有共享专家的 MoE 模型生效。

dynamic_eplb

bool

False

是否启用动态 EPLB。

num_iterations_eplb_update

int

400

EPLB 开始时的前向迭代次数。

gate_eplb

bool

False

是否仅启用一次 EPLB。

num_wait_worker_iterations

int

30

The forward iterations when the EPLB worker will finish CPU tasks. In our test default value 30 can cover most cases.

expert_map_record_path

str

None

动态 EPLB 完成后,将当前专家负载热图保存到指定路径。

init_redundancy_expert

int

0

初始化时指定冗余专家。

每个配置选项的详细信息如下:

torchair_graph_config

名称

类型

默认

描述

enabled

bool

False

Whether to enable torchair graph mode. Currently only DeepSeek series models and PanguProMoE are supported.

mode

str

None

When using reduce-overhead mode for torchair, it needs to be set.

enable_multistream_mla

bool

False

Whether to put vector operators of MLA to another stream. This option only takes effect on models using MLA (for example, DeepSeek).

enable_view_optimize

bool

True

Whether to enable torchair view optimization.

enable_frozen_parameter

bool

True

Whether to fix the memory address of weights during inference to reduce the input address refresh time during graph execution.

use_cached_graph

bool

False

Whether to use cached graph.

graph_batch_sizes

list[int]

[]

The batch size for torchair graph cache.

graph_batch_sizes_init

bool

False

Init graph batch size dynamically if graph_batch_sizes is empty.

enable_kv_nz

bool

False

Whether to enable KV Cache NZ layout. This option only takes effect on models using MLA (for example, DeepSeek).

enable_super_kernel

bool

False

Whether to enable super kernel to fuse operators in deepseek moe layers. This option only takes effects on moe models using dynamic w8a8 quantization.

ascend_scheduler_config

名称

类型

默认

描述

enabled

bool

False

Whether to enable ascend scheduler for V1 engine.

enable_pd_transfer

bool

False

Whether to enable P-D transfer. When it is enabled, decode is started only when prefill of all requests is done. This option only takes effect on offline inference.

decode_max_num_seqs

int

0

Whether to change max_num_seqs of decode phase when P-D transfer is enabled. This option only takes effect when enable_pd_transfer is True.

max_long_partial_prefills

Union[int, float]

float('inf')

The maximum number of prompts longer than long_prefill_token_threshold that will be prefilled concurrently.

long_prefill_token_threshold

Union[int, float]

float('inf')

a request is considered long if the prompt is longer than this number of tokens.

ascend_scheduler_config 同样支持来自 vllm 调度器配置 的选项。例如,您也可以在 ascend_scheduler_config 中添加 enable_chunked_prefill: True

weight_prefetch_config

名称

类型

默认

描述

enabled

bool

False

Whether to enable weight prefetch.

prefetch_ratio

dict

{"attn": {"qkv": 1.0, "o": 1.0}, "moe": {"gate_up": 0.8}}

Prefetch ratio of each weights.

例如#

附加配置

{
    "torchair_graph_config": {
        "enabled": True,
        "use_cached_graph": True,
        "graph_batch_sizes": [1, 2, 4, 8],
        "graph_batch_sizes_init": False,
        "enable_kv_nz": False
    },
    "ascend_scheduler_config": {
        "enabled": True,
        "enable_chunked_prefill": True,
        "max_long_partial_prefills": 1,
        "long_prefill_token_threshold": 4096,
    },
    "weight_prefetch_config": {
        "enabled": True,
        "prefetch_ratio": {
            "attn": {
                "qkv": 1.0,
                "o": 1.0,
            },
            "moe": {
                "gate_up": 0.8
            }
        },
    },
    "multistream_overlap_shared_expert": True,
    "refresh": False,
}