flashinfer.cake_gdn_det_train_kcp.cake_gdn_det_train_kcp_partition

flashinfer.cake_gdn_det_train_kcp.cake_gdn_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

Partition one packed batch of documents over the ranks of a context-parallel group.

Parameters:
  • cu_seqlens_global_cpu – The packed documents’ cu_seqlens (CPU int64 tensor or a sequence of ints; first 0).

  • world_size (int) – Ranks of the context-parallel group.

  • layout (str) – "contiguous" (near-equal token intervals), "zigzag" (2 W parts, rank r holds parts r and 2W-1-r) or "zigzag_per_document" (every document cut into 2 W pieces at cut_points, default near-equal; rank r holds pieces r and 2W-1-r of every document). No total % W requirement; cut points need not be multiples of 64; zero-length fragments are legal.

  • fragments (optional) – An explicit (ragged) table fragments[rank] = [(doc, offset_in_doc, length), ...] in local order, validated against cu_seqlens.

  • cut_points (optional) – Per document the 2 W + 1 cut offsets of "zigzag_per_document".

Returns:

CakeGDNDetKcpPartition: per rank the fragment table (doc, off, length, prev, next) in document order; reused across layers (metadata only).

Return type:

CakeGDNDetKcpPartition