vLLM 中 CPU 上 GDN 注意力的投机解码路径

该文档列出 vLLM 在 CPU 上实现 GDN 注意力的若干内部函数,涉及卷积状态缓存视图、投机与非投机 token 的混合处理,以及 AMX 与 aarch64 平台上卷积权重打包后如何取回原始权重。

## `vllm.model_executor.layers.mamba.ops.cpu.gdn_attention` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention>) 函数 : - **`[cpu_gdn_attention_core](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention.cpu_gdn_attention_core>)`** – CPU自定义操作,用于核心GDN的注意力计算. ## `_conv_buffer_view(layer)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention._conv_buffer_view>) 返回凸轮状态缓存为(num_slots, dim, state_len). ## `_spec_aware_nonspec(layer, attn_metadata_i, mixed_qkv, b, a, core_attn_out, conv_buf, ssm_state, width)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention._spec_aware_nonspec>) 非光谱预填/解码带宽凸缓冲. ## `_spec_aware_nonspec_subset(layer, attn_metadata_i, mixed_qkv, b, a, conv_buf, ssm_state, width)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention._spec_aware_nonspec_subset>) 处理与光谱序列共存的非光谱(预补)符号。 返回命令输出像 `non_spec_token_indx`. ## `_spec_forward(layer, attn_metadata_i, mixed_qkv_spec, b_spec, a_spec, conv_buf, ssm_state, width, state_len)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention._spec_forward>) 运行 GDN 核心,用于多query(光谱)符号. 返回 spec 令牌的核心注意输出, 顺序与 Spec 顺序相同 。 `mixed_qkv_spec` (即由 `spec_query_start_loc`). ## `_unpacked_conv_weight(layer)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention._unpacked_conv_weight>) 返回平原(dim,宽度)凸起的重量. 在 AMX 和 arch64+bf16 上,凸轮1d 重量在负载时间被装入,因此火炬光谱解码路径依赖于隐藏的未包装副本. `dispatch_cpu_unquantized_gemm`. ## `cpu_gdn_attention_core(mixed_qkv, b, a, core_attn_out, layer_name)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/layers/mamba/ops/cpu/gdn_attention/#vllm.model_executor.layers.mamba.ops.cpu.gdn_attention.cpu_gdn_attention_core>) CPU自定义操作,用于核心GDN的注意力计算. 11月 30, 2026 (英语).

查看原始来源