IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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: 1 stripes 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​

def owner(self, pos: Int) -> Int

Returns the rank that stores global position pos.

Returns:

Int

owns​

def owns(self, pos: Int) -> Bool

Returns whether this rank stores global position pos.

Returns:

Bool

local_slot​

def local_slot(self, pos: Int) -> Int

Returns the owner's local slot for global position pos.

Returns:

Int

global_pos​

def global_pos(self, slot: Int) -> Int

Returns the global position stored in this rank's local slot.

Returns:

Int

local_len​

def local_len(self, length: Int) -> Int

Returns how many of the positions [0, length) this rank stores.

Returns:

Int

max_local_len​

static def max_local_len(length: Int) -> Int

Returns an upper bound of local_len(length) over all ranks.

Returns:

Int

Was this page helpful?