vLLM 中 Param2MoE 模型的注意力与专家路由实现

vLLM 的 param2moe 模块提供 Param2MoE 因果语言模型的本地实现,采用分组查询注意力,并在前若干层使用稠密 SwiGLU 前馈,之后切换为带 Sigmoid 打分和分组 top-k 路由的混合专家层。

## `vllm.model_executor.models.param2moe` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe>) 类 : - **`[Param2MoEAttention](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEAttention>)`** – 分组查询注意(GQA),用于Param2MoE. - **`[Param2MoEDecoderLayer](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEDecoderLayer>)`** – 单变压器解码器块. - **`[Param2MoEForCausalLM](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEForCausalLM>)`** – vLLM - 原产地的Param2MoE CausalLM. - **`[Param2MoEMLP](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMLP>)`** – 用于稠密层的SwiGLU进气区块. - **`[Param2MoEMixtureOfExperts](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMixtureOfExperts>)`** – 为 Param2MoE 执行 vLLM MixtureOfExperts 协议. - **`[Param2MoEMoEBlock](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMoEBlock>)`** – 用于 Param2MoE 的 Mixture-of-Experts 块 . ## `Param2MoEAttention` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEAttention>) 基础 : `[Module](<https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module>)` 分组查询注意(GQA),用于Param2MoE. 与香草 GQA 层的显著差异 - 检查站把Q、K、V 装成单人 `query_key_value` 重量。 vLLM 接收它已经重新命名为 `qkv_proj` 由重量名翻译器直接加载; `QKVParallelLinear` 拆分引信 `[Q|K|V]` - 内侧的热量 - Q和K上可选的人均RMS规范(`use_qk_norm=True`). ## `Param2MoEDecoderLayer` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEDecoderLayer>) 基础 : `[Module](<https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module>)` 单变压器解码器块. 第一次很紧张 `first_k_dense_replace` 层; MoE 之后。 ## `Param2MoEForCausalLM` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEForCausalLM>) 基础 : `[Module](<https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module>)`, `[SupportsPP](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/interfaces/#vllm.model_executor.models.interfaces.SupportsPP>)`, `[SupportsLoRA](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/interfaces/#vllm.model_executor.models.interfaces.SupportsLoRA>)`, `[Param2MoEMixtureOfExperts](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMixtureOfExperts>)` vLLM - 原产地的Param2MoE CausalLM. 使用分组-查询注意(GQA),使用Sigmoid计分,分组-topk Mixture-of-Experts MLP. ## `Param2MoEMLP` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMLP>) 基础 : `[Module](<https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module>)` 用于稠密层的SwiGLU进气区块. ## `Param2MoEMixtureOfExperts` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMixtureOfExperts>) 基础 : `[MixtureOfExperts](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/interfaces/#vllm.model_executor.models.interfaces.MixtureOfExperts>)` 为 Param2MoE 执行 vLLM MixtureOfExperts 协议. ## `Param2MoEMoEBlock` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe.Param2MoEMoEBlock>) 基础 : `[Module](<https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module>)` 用于 Param2MoE 的 Mixture-of-Experts 块 . 运行 - Sigmoid 评分( config.score_函数 = "sigmoid") - 组装上k( n_group, topk_group) - 专家偏差(门. expert_bias – e_score_correction_bias ) - routed_scaling_factor 正常化 在顶部增加了一组共享(始终活跃的)专家. ## `_is_expert_bias_name(name)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe._is_expert_bias_name>) 当重量是MoE路由器的每位专家得分偏差时是真实的. ## `_normalize_expert_bias(weights)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/models/param2moe/#vllm.model_executor.models.param2moe._normalize_expert_bias>) 0指MoE路由器对负载平衡的每专家分数偏差. 重命名为 `e_score_correction_bias` 是由映射器完成的;只有拉伸调整才住在这里,因为一个WeightsMapper不能转换数据. 11月 30, 2026 (英语).

查看原始来源