flashinfer.cake_kda_det_train_kcp.cake_kda_det_train_kcp_partition

flashinfer.cake_kda_det_train_kcp.cake_kda_det_train_kcp_partition(cu_seqlens_global_cpu: Any, world_size: int, layout: str = 'contiguous', fragments: Any | None = None, *, cut_points: Any | None = None) → Any

The context-parallel partition of one packed batch over world_size ranks.

Parameters:
  • cu_seqlens_global_cpu – int32 [num_docs + 1] document offsets of the whole batch, on the host (a tensor or a sequence).

  • world_size (int) – The number of ranks of the context-parallel group.

  • layout (str) – "contiguous" (equal token shares in order), "zigzag" or "zigzag_per_document" (the load-balanced layouts); fragments gives an explicit ragged layout instead, and cut_points (per document the 2 * world_size + 1 cut offsets) applies to layout="zigzag_per_document" only.

  • fragments (optional) – Explicit ragged layout: fragments[rank] = [(doc, off, len), ...], or a flat [(doc, off, len, rank), ...] list. doc is the document index, off its token offset within that document, len the token count, and rank the owner.

  • cut_points (optional) – Per-document 2 * world_size + 1 cut offsets for layout="zigzag_per_document".

Returns:

CakeKDADetKcpPartition: per rank its fragments (document, token range) of the batch; the input of cake_kda_det_train_kcp_build_context() on every rank.

Return type:

CakeKDADetKcpPartition