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).
Mojo struct
ContextParallelLayout
struct ContextParallelLayout[size: Int = Int(1), interleave: Int = Int(1)]
The position-to-slot map of one rank in a context-parallel group.
Parameters
- size (
Int): Number of ranks sharing each request's KV positions. - interleave (
Int): Consecutive positions a rank owns before the next rank's turn:1stripes single tokens, a page size stripes whole pages.
Fields
- rank (
Int): This rank's index in[0, size).
Implemented traits
AnyType,
Copyable,
Deinitable,
ImplicitlyCopyable,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime members
enabled
comptime enabled = (size > Int(1))
Methods
owner
owns
def owns(self, pos: Int) -> Bool
Returns whether this rank stores global position pos.
Returns:
local_slot
def local_slot(self, pos: Int) -> Int
Returns the owner's local slot for global position pos.
Returns:
global_pos
def global_pos(self, slot: Int) -> Int
Returns the global position stored in this rank's local slot.
Returns:
local_len
def local_len(self, length: Int) -> Int
Returns how many of the positions [0, length) this rank stores.
Returns:
max_local_len
static def max_local_len(length: Int) -> Int
Returns an upper bound of local_len(length) over all ranks.
Returns: