flashinfer.cake_kda_det_train_kcp.cake_kda_det_train_kcp_build_context

flashinfer.cake_kda_det_train_kcp.cake_kda_det_train_kcp_build_context(part: Any, group: Any, rank: int, device: Any, conv_kernel_size: int = 4, *, sm_count: int | None = None, heads: Any | None = None, stream: Any | None = None) → Any

This rank’s context of a partition: its device tables, the collectives of the state and halo exchanges and the segment plan of its fragments.

Parameters:
  • part (CakeKDADetKcpPartition) – From cake_kda_det_train_kcp_partition(), the same object on every rank.

  • group – The torch.distributed process group of the context-parallel ranks.

  • rank (int) – This process’s rank in group.

  • device – The CUDA device of this rank’s operands.

  • conv_kernel_size (int) – The width of the causal convolution whose history rows the context exchanges (4).

  • sm_count (int, optional) – The device’s SM count when it should not be queried.

  • heads (int or sequence of int, optional) – Head counts whose head plans are derived now (host work only) instead of at the first call.

  • stream (torch.cuda.Stream, optional) – The stream of the context’s one asynchronous table copy (default: the current stream of device). The host never waits for device work: a pack can be prepared while the previous one runs. A thread other than the one that runs the pack must pass the stream that will run it, or call ctx.wait_ready(stream) before that stream reads the tables (the KCP entry points call ctx.wait_ready() on their current stream).

Returns:

CakeKDADetKcpContext: the argument every KCP entry point takes; reusable across calls of the same batch layout.

Return type:

CakeKDADetKcpContext