flashinfer.cake_kda_nondet_train_kcp.cake_kda_nondet_train_kcp_build_context¶
- flashinfer.cake_kda_nondet_train_kcp.cake_kda_nondet_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 (CakeKDANondetKcpPartition) – From
cake_kda_nondet_train_kcp_partition(), the same object on every rank. The first KDA call of each key on the context compares a digest of the partition,conv_kernel_size,Hand the options that set the collectives across the ranks and trips a device-side assert on a mismatch (the package README, “Rank agreement”).group – The
torch.distributedprocess 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 callctx.wait_ready(stream)before that stream reads the tables (the KCP entry points callctx.wait_ready()on their current stream).
- Returns:
CakeKDANondetKcpContext: the argument every KCP entry point takes; reusable across calls of the same batch layout.- Return type:
CakeKDANondetKcpContext