For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python function
merge_topk
merge_topk()
max.nn.common_layers.context_parallel.merge_topk(local_rows, local_scores, dcp)
Returns each rank’s share of the group-wide top-k as one selection.
Each rank picked the top k of its own keys (local_rows, its
physical rows, and local_scores). Any key in the group’s top k
is in its owner’s local top k, so merging the dcp * k gathered
scores is exact up to ties. The result packs each token’s owned rows,
compacted to the front, with their count in a last column: an int32
[T, k + 1] selection (see split_selection()). The packed form
lets shared indexer layers reuse it like a plain top-k.
Over an NVFP4 MLA cache local_rows is [T, 2 * k], each
selection’s value row then its scale-pool row, and the selection is
[T, 2 * k + 1]: both halves compacted the same way, then the count.