vLLM分布式上下文索引器的候选合并与稳定Top-k实现
vLLM的DCP索引器内核通过位域编码把候选ID与分数打包,并在各rank候选完成all-gather后原地选出全局top-k,避免额外重排拷贝,同时保证各rank与预热阶段采用一致的排序键。
## `vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl>) 函数 : - **`[dcp_topk_id_bits](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl.dcp_topk_id_bits>)`** – 持有每个候选人ID的位数(一个位于num_positions以下的职位). - **`[dcp_topk_score_bits](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl.dcp_topk_score_bits>)`** – 排名高的分数比特: BF16 logits,上传至FP32为顶级K,. - **`[stable_topk_from_gathered_candidates_cutedsl](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl.stable_topk_from_gathered_candidates_cutedsl>)`** – 选择每行的全局顶级...`topk` 从各级候选人。 ## `_dcp_merge_topk_and_interleave(vllm_config)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl._dcp_merge_topk_and_interleave>) (topk, cp_interleave ) DCP合并运行与. Kpool 索引器( GLM-5 .x) 合并池 IDs: topk 和 interleave 均以下列单位排列: `index_kpool` 标志。 ## `dcp_topk_id_bits(num_positions)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl.dcp_topk_id_bits>) 持有每个候选人ID的位数(一个位于num_positions以下的职位). ## `dcp_topk_score_bits(logits_dtype)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl.dcp_topk_score_bits>) 排名高的分数比特: BF16 logits, 上调到 FP32 为上- k, 其低半数为0 。 从配置的logits dtype中衍生出来, 所以每个 DCP 排名( 连一个没有这个步骤的对数) , 热身一致 。 ## `stable_topk_from_gathered_candidates_cutedsl(gathered, topk, out=None, score_bits=32, id_bits=32)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/model_executor/kernels/attention/dsa/dcp_indexer_cutedsl/#vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl.stable_topk_from_gathered_candidates_cutedsl>) 选择每行的全局顶级...`topk` 从各级候选人。 `gathered` 是军衔 `[world_size, rows, topk, 2]`,由dim-0 生成 各个军衔的全加法 `[rows, topk, 2]` 并被读入: dim-1 集合到 `[rows, world_size * topk, 2]` 需要重排完整的副本 。 `score_bits` 每个分数(参见 `dcp_topk_score_bits`)和低 `id_bits` 每一个编号。 12月 1, 2026 (英语).
查看原始来源