TensorTonic
Study Plans
Study Plan
Choose a Topology-Aware Parallel Plan
Distributed Computing
Hard

Choose data, tensor, pipeline, and context parallel degrees using the supplied memory and communication model. Let ddd, ttt, ppp, and ccc be those four positive integer degrees. Let GGG be num_gpus, BBB be global_batch_size, SSS be model_state_bytes, and AAA be activation_bytes_per_sample. A feasible plan uses every GPU:

dtpc=G.dtpc=G.dtpc=G.

The data degree must divide B, the context degree must divide sequence_length and meet min_context_parallel, and the product of tensor and context degrees must not exceed gpus_per_node. Per-GPU model-state memory MsM_sMs​ and activation memory MaM_aMa​ follow these equations, with ceiling brackets rounding up:

Ms=⌈Stp⌉.M_s=\left\lceil\frac{S}{tp}\right\rceil.Ms​=⌈tpS​⌉. Ma=⌈A(B/d)tc⌉.M_a=\left\lceil\frac{A(B/d)}{tc}\right\rceil.Ma​=⌈tcA(B/d)​⌉.

Their sum must not exceed memory_per_gpu. The model's inter-node and intra-node communication estimates, IoutI_{\mathrm{out}}Iout​ and IinI_{\mathrm{in}}Iin​, are measured in bytes:

Iout=2Msd−1d+Map−1p.I_{\mathrm{out}}=2M_s\frac{d-1}{d}+M_a\frac{p-1}{p}.Iout​=2Ms​dd−1​+Ma​pp−1​. Iin=2Ma(t−1t+c−1c).I_{\mathrm{in}}=2M_a\left(\frac{t-1}{t}+\frac{c-1}{c}\right).Iin​=2Ma​(tt−1​+cc−1​).

Choose the feasible plan with the smallest lexicographic score (Iout,Iin,p,−d,t,c)(I_{\mathrm{out}},I_{\mathrm{in}},p,-d,t,c)(Iout​,Iin​,p,−d,t,c). Return None if no plan fits; otherwise return a Python dictionary with data_parallel, tensor_parallel, pipeline_parallel, context_parallel, and estimated_memory_bytes as Python integers, plus inter_node_bytes and intra_node_bytes as Python floats.

Loading visualization...

Examples

Input: num_gpus = 4, gpus_per_node = 4, model_state_bytes = 400, activation_bytes_per_sample = 100, global_batch_size = 4, sequence_length = 8, memory_per_gpu = 300, min_context_parallel = 1

Output: {"data_parallel":1,"tensor_parallel":4,"pipeline_parallel":1,"context_parallel":1,"estimated_memory_bytes":200,"inter_node_bytes":0,"intra_node_bytes":150}

Explanation: Four-way tensor parallelism fits within one node, satisfies memory, and minimizes the ordered communication score.

Input: num_gpus = 8, gpus_per_node = 4, model_state_bytes = 800, activation_bytes_per_sample = 160, global_batch_size = 8, sequence_length = 16, memory_per_gpu = 600, min_context_parallel = 2

Output: {"data_parallel":1,"tensor_parallel":2,"pipeline_parallel":2,"context_parallel":2,"estimated_memory_bytes":520,"inter_node_bytes":160,"intra_node_bytes":640}

Input: num_gpus = 4, gpus_per_node = 2, model_state_bytes = 1000, activation_bytes_per_sample = 500, global_batch_size = 4, sequence_length = 8, memory_per_gpu = 1500, min_context_parallel = 1

Output: {"data_parallel":2,"tensor_parallel":2,"pipeline_parallel":1,"context_parallel":1,"estimated_memory_bytes":1000,"inter_node_bytes":500,"intra_node_bytes":500}

Hint 1

The % operator tests whether one integer divides another.

Hint 2

divmod gives a quotient and remainder without floating-point arithmetic.

Hint 3

Python compares tuples lexicographically.

Requirements

  • Satisfy all GPU, divisibility, context, node, and memory conditions.
  • Use the supplied model, including its pooled-byte rounding and score order.
  • Preserve the specified Python integer and float return types.

Constraints

  • num_gpus, gpus_per_node, global_batch_size, sequence_length, memory_per_gpu, and min_context_parallel are positive Python integers.
  • model_state_bytes and activation_bytes_per_sample are nonnegative Python integers.
  • gpus_per_node is at most num_gpus.
  • Hidden cases use at most 64 GPUs.
  • Communication values are returned as Python floats.
Try Similar Problems
Measure Pipeline Bubble UtilizationMediumAccount for ZeRO Memory by StageEasySynchronize Data-Parallel GradientsMediumSimulate Distributed CollectivesMediumReconstruct a Column-Parallel MLP LayerMediumCalculate Collective Effective BandwidthEasyDecode Attention with a KV CacheHardRecover an IsoFLOP Compute-Optimal FrontierHardCalculate Tensor Parallel Communication CostHardSimulate Disaggregated Prefill and Decode ServingHardImplement Expert Parallel Routing Across GPUsHardEstimate Model Memory and Minimum GPU CountEasy

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

You must run your code first.

Choose a Topology-Aware Parallel Plan

Distributed Computing
Hard

Choose data, tensor, pipeline, and context parallel degrees using the supplied memory and communication model. Let ddd, ttt, ppp, and ccc be those four positive integer degrees. Let GGG be num_gpus, BBB be global_batch_size, SSS be model_state_bytes, and AAA be activation_bytes_per_sample. A feasible plan uses every GPU:

dtpc=G.dtpc=G.dtpc=G.

The data degree must divide B, the context degree must divide sequence_length and meet min_context_parallel, and the product of tensor and context degrees must not exceed gpus_per_node. Per-GPU model-state memory MsM_sMs​ and activation memory MaM_aMa​ follow these equations, with ceiling brackets rounding up:

Ms=⌈Stp⌉.M_s=\left\lceil\frac{S}{tp}\right\rceil.Ms​=⌈tpS​⌉. Ma=⌈A(B/d)tc⌉.M_a=\left\lceil\frac{A(B/d)}{tc}\right\rceil.Ma​=⌈tcA(B/d)​⌉.

Their sum must not exceed memory_per_gpu. The model's inter-node and intra-node communication estimates, IoutI_{\mathrm{out}}Iout​ and IinI_{\mathrm{in}}Iin​, are measured in bytes:

Iout=2Msd−1d+Map−1p.I_{\mathrm{out}}=2M_s\frac{d-1}{d}+M_a\frac{p-1}{p}.Iout​=2Ms​dd−1​+Ma​pp−1​. Iin=2Ma(t−1t+c−1c).I_{\mathrm{in}}=2M_a\left(\frac{t-1}{t}+\frac{c-1}{c}\right).Iin​=2Ma​(tt−1​+cc−1​).

Choose the feasible plan with the smallest lexicographic score (Iout,Iin,p,−d,t,c)(I_{\mathrm{out}},I_{\mathrm{in}},p,-d,t,c)(Iout​,Iin​,p,−d,t,c). Return None if no plan fits; otherwise return a Python dictionary with data_parallel, tensor_parallel, pipeline_parallel, context_parallel, and estimated_memory_bytes as Python integers, plus inter_node_bytes and intra_node_bytes as Python floats.

Loading visualization...

Examples

Input: num_gpus = 4, gpus_per_node = 4, model_state_bytes = 400, activation_bytes_per_sample = 100, global_batch_size = 4, sequence_length = 8, memory_per_gpu = 300, min_context_parallel = 1

Output: {"data_parallel":1,"tensor_parallel":4,"pipeline_parallel":1,"context_parallel":1,"estimated_memory_bytes":200,"inter_node_bytes":0,"intra_node_bytes":150}

Explanation: Four-way tensor parallelism fits within one node, satisfies memory, and minimizes the ordered communication score.

Input: num_gpus = 8, gpus_per_node = 4, model_state_bytes = 800, activation_bytes_per_sample = 160, global_batch_size = 8, sequence_length = 16, memory_per_gpu = 600, min_context_parallel = 2

Output: {"data_parallel":1,"tensor_parallel":2,"pipeline_parallel":2,"context_parallel":2,"estimated_memory_bytes":520,"inter_node_bytes":160,"intra_node_bytes":640}

Input: num_gpus = 4, gpus_per_node = 2, model_state_bytes = 1000, activation_bytes_per_sample = 500, global_batch_size = 4, sequence_length = 8, memory_per_gpu = 1500, min_context_parallel = 1

Output: {"data_parallel":2,"tensor_parallel":2,"pipeline_parallel":1,"context_parallel":1,"estimated_memory_bytes":1000,"inter_node_bytes":500,"intra_node_bytes":500}

Hint 1

The % operator tests whether one integer divides another.

Hint 2

divmod gives a quotient and remainder without floating-point arithmetic.

Hint 3

Python compares tuples lexicographically.

Requirements

  • Satisfy all GPU, divisibility, context, node, and memory conditions.
  • Use the supplied model, including its pooled-byte rounding and score order.
  • Preserve the specified Python integer and float return types.

Constraints

  • num_gpus, gpus_per_node, global_batch_size, sequence_length, memory_per_gpu, and min_context_parallel are positive Python integers.
  • model_state_bytes and activation_bytes_per_sample are nonnegative Python integers.
  • gpus_per_node is at most num_gpus.
  • Hidden cases use at most 64 GPUs.
  • Communication values are returned as Python floats.
Try Similar Problems
Measure Pipeline Bubble UtilizationMediumAccount for ZeRO Memory by StageEasySynchronize Data-Parallel GradientsMediumSimulate Distributed CollectivesMediumReconstruct a Column-Parallel MLP LayerMediumCalculate Collective Effective BandwidthEasyDecode Attention with a KV CacheHardRecover an IsoFLOP Compute-Optimal FrontierHardCalculate Tensor Parallel Communication CostHardSimulate Disaggregated Prefill and Decode ServingHardImplement Expert Parallel Routing Across GPUsHardEstimate Model Memory and Minimum GPU CountEasy

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

Accepts: number

You must run your code first.