Skip to content

vllm.model_executor.kernels.attention.dsa.dcp_indexer_cutedsl

Functions:

_dcp_merge_topk_and_interleave(vllm_config)

(topk, cp_interleave) the DCP merge runs with.

Kpool indexers (GLM-5.x) merge pool ids: topk and the interleave are both in units of index_kpool tokens.

dcp_topk_id_bits(num_positions)

Bits that hold every candidate id (a position below num_positions).

dcp_topk_score_bits(logits_dtype)

High score bits that rank: BF16 logits, upcast to FP32 for the top-k, have a zero low half. Derived from the configured logits dtype, so every DCP rank (even one with no logits this step) and the warm-up agree.

stable_topk_from_gathered_candidates_cutedsl(gathered, topk, out=None, score_bits=32, id_bits=32)

Select each row's global top-topk from all ranks' candidates.

gathered is rank-major [world_size, rows, topk, 2], as produced by a dim-0 all-gather of each rank's [rows, topk, 2] candidates, and is read in place: a dim-1 gather into [rows, world_size * topk, 2] would cost a full reorder copy. The key ranks only the high score_bits of each score (see dcp_topk_score_bits) and the low id_bits of each id.