core.tensor_parallel.gtp_parallel_layout#

Rank layouts for GTP weight sharding and replication, and sequence and batch partitioning.

Layouts are computed without initializing distributed process groups. TP is the innermost axis, followed by GTP_remat weight shards, with PP as the outermost axis. A contiguous TP x GTP_remat tile can therefore be placed within one NVLink domain by the launcher. Context parallelism may span several such tiles without enlarging weight gathers.

Module Contents#

Classes#

GTPParallelLayout

Describe two views of the same ranks, keeping actual weight shards fixed.

_RankView

Bootstrap adapter for RankGenerator’s rank-list interface.

Functions#

resolve_tensor_parallel_sequence_shards

Return sequence-shard counts including and excluding TP/SP, respectively.

get_batch_parallel_size

Return independent batch partitions: DP x GTP_remat batch shards.

API#

core.tensor_parallel.gtp_parallel_layout.resolve_tensor_parallel_sequence_shards(
tensor_model_parallel_size: int,
tensor_parallel_num_sequence_shards: Optional[int],
gtp_weight_remat_size: int,
sequence_parallel: bool,
) → tuple[int, int]#

Return sequence-shard counts including and excluding TP/SP, respectively.

core.tensor_parallel.gtp_parallel_layout.get_batch_parallel_size(args) → int#

Return independent batch partitions: DP x GTP_remat batch shards.

This replaces DP x GTP_remat when some GTP_remat ranks partition sequences. The fallback supports manually built launch args without a resolved batch size.

class core.tensor_parallel.gtp_parallel_layout.GTPParallelLayout#

Describe two views of the same ranks, keeping actual weight shards fixed.

cp is independent of GTP_remat. num_sequence_shards partitions sequences within each weight group, excluding TP/SP. weight_size excludes TP. dp is the residual independent-data axis; callers should use batch_parallel_size for batch accounting and num_weight_replicas for dense optimizer sharding.

world_size: int#

None

tp: int#

None

pp: int#

None

cp: int#

None

weight_size: int#

None

num_sequence_shards: int#

1

rank_offset: int#

0

__post_init__() → None#
property minimum_world_size: int#

Smallest world that can hold both layouts.

property dp: int#

Residual independent-data degree, excluding batch shards inside GTP_remat.

property batch_parallel_size: int#

Number of independently assigned microbatches per pipeline.

property num_weight_replicas: int#

Number of copies of each TP-local weight shard.

_groups(axes: set[str]) → list[list[int]]#
property data: core.tensor_parallel.gtp_parallel_layout._RankView#

CP x GTP_remat sequence shards split sequences; extra_data x DP assigns samples.

property weights: core.tensor_parallel.gtp_parallel_layout._RankView#

Weight layout: TP x GTP_remat shards, DP replicates those shards.

class core.tensor_parallel.gtp_parallel_layout._RankView#

Bootstrap adapter for RankGenerator’s rank-list interface.

layout: core.tensor_parallel.gtp_parallel_layout.GTPParallelLayout#

None

axes: dict[str, tuple[str, ...]]#

None

get_ranks(token: str) → list[list[int]]#

Enumerate groups in a deterministic order on every process.