Tensor Parallelism: Principles and Practices for Large Model Training

    This article explains how tensor parallelism works and how to apply it in large model training. It covers why single-device memory is the first hard constraint, the block-matrix math behind column and row splitting, how pairing the two keeps collective communication to a minimum per layer, why communication cost sets the performance ceiling, how sequence parallelism reduces redundant activation memory, and how tensor parallelism combines with data and pipeline parallelism. A deployment checklist for checking divisibility, controlling the parallel group scope, and monitoring communication overhead is included.

    1. Why Tensor Parallelism Is Needed

    The first hard constraint in large model training is not compute but the memory capacity of a single device. For a Transformer layer with hidden dimension h, the weights and optimizer states alone can occupy tens of gigabytes. As parameter counts grow from billions to tens of billions, a single accelerator can no longer hold a complete layer’s parameters, let alone retain activations for backpropagation. Tensor Parallelism (also called intra-layer model parallelism) addresses this constraint: it splits the weight matrices inside the same layer along one dimension and distributes them across multiple devices. Each device holds and computes only a portion, and collective communication reassembles the partial results into the complete mathematical output.

    Unlike layer-wise partitioning, which places different layers on different devices, tensor parallelism splits within a layer. It therefore requires the participating devices to exchange intermediate results frequently during every forward and backward pass. This defines its scope of applicability: it fits scenarios with multiple devices inside one machine connected by high-bandwidth interconnects.

    2. Mathematical Foundation: A Block Matrix View

    Tensor parallelism works because matrix multiplication is compatible with blocking. Let the input activation be X, the weight be W, and the output be Y = XW. If W is split by columns into [W₁, W₂], then Y = [XW₁, XW₂]. Each device computes a subset of the output columns, and concatenation yields the full result with no communication required (column splitting). If W is split by rows into [W₁; W₂], then Y = X₁W₁ + X₂W₂. Each device produces a partial sum, and a summation aggregation is required to obtain the final result (row splitting).

    This distinction is the key to all the engineering details that follow: column splitting defers communication, row splitting brings it forward, and pairing the two leaves only one collective communication per layer.

    3. Two Basic Splitting Schemes

    Column parallel: the weight is split along the output dimension, and each device produces a subset of the output columns. Because all devices receive the same input and their computations are independent, no communication is needed in the forward pass; during backpropagation, however, the upstream gradient must be split and synchronized along the output dimension.

    Row parallel: the weight is split along the input dimension, each device consumes only part of the input, and the output is a partial sum. One All-Reduce (sum) is needed to obtain the correct result, and the backward pass requires synchronizing the input gradient.

    The most common engineering practice is to chain the two: the first layer uses column splitting and the immediately following layer uses row splitting. Within such a split block, only one All-Reduce is needed in the forward pass and one in the backward pass, reducing communication to the theoretical minimum. The two linear transformations in an MLP and the query/key/value projections plus the output projection in attention are typical places where this pairing applies.

    Illustrative pseudocode (framework details omitted):

    1. # Column split: output dimension is partitioned to the current device
    2. y_local = x @ w_col_shard # no communication needed
    3. # Row split: input dimension is partitioned to the current device, result is a partial sum
    4. y = all_reduce_sum(x_local @ w_row_shard)

    4. Communication Overhead: The Decisive Variable

    The performance ceiling of tensor parallelism is determined almost entirely by communication. The data volume of an All-Reduce is proportional to the batch size, sequence length, and hidden dimension, while latency depends on the bandwidth and topology of the inter-device links. If the participating devices are spread across machines, network bandwidth is often an order of magnitude lower than intra-machine interconnects. Communication time then quickly consumes the gains from computation, producing the counterintuitive result that throughput drops as more devices are added.

    Practice therefore usually follows a few rules: keep the tensor parallel group within a single machine; choose a parallel degree that divides the hidden dimension and the number of attention heads evenly to avoid padding waste from uneven splits; prefer aggregation methods with lower collective primitive overhead; and fuse multiple small matrix multiplications at the operator level to reduce kernel launches and synchronizations.

    5. A Finer-Grained Parallel Style: Sequence Parallelism

    Even with the pairing above, parts of the layer remain unsplit: element-wise operations such as LayerNorm, Dropout, and residual addition typically operate on the full activation, so each device keeps a redundant copy of the activations and memory usage grows linearly with the parallel degree. Sequence Parallelism takes the approach of splitting the activations in these regions along the sequence dimension so that each device stores only one segment of the sequence. Before entering the parallel linear layers, one communication converts the sequence-dimension split into a hidden-dimension split, and the conversion is reversed on exit. It shares the same communication budget as tensor parallelism while significantly reducing activation memory and allowing a higher parallel degree.

    6. Combining with Other Parallel Strategies

    Tensor parallelism is rarely used alone and usually forms a multi-dimensional parallel system with data parallelism and pipeline parallelism. Data parallelism replicates the model and splits the data batch to scale throughput. Pipeline parallelism splits the model by layer to reduce per-device parameter pressure but introduces pipeline bubbles. Tensor parallelism solves the problem of a single layer not fitting on one device. The general combination principle is to use tensor parallelism inside a machine to saturate the high-bandwidth interconnect, data parallelism across machines to scale out, and pipeline parallelism when the model is too deep across nodes. In addition, general techniques such as activation recomputation, memory offloading, mixed precision, and optimizer state sharding can be layered on top of these strategies to further lower the peak memory footprint.

    7. Deployment Checklist

    1. Measure before splitting: confirm whether the bottleneck is memory or communication, and avoid raising the parallel degree blindly.
    2. Verify divisibility: the hidden dimension, number of attention heads, and vocabulary size must be divisible by the parallel degree.
    3. Control the parallel group scope: prefer intra-machine and be cautious about crossing machines.
    4. Watch numerical consistency: changes in splitting and aggregation order can introduce slight numerical differences, so fix the random seed and run alignment verification.
    5. Establish observability: use general monitoring, alerting, and logging services to collect throughput, memory usage, and communication wait time, and let data drive tuning.

    When deploying such training jobs on the container platforms and high-performance computing instances of cloud platforms such as Baidu AI Cloud, general monitoring and logging capabilities can be used to continuously observe the communication share and judge whether the parallel configuration is reasonable. Overall, the value of tensor parallelism lies not in “chopping the model into pieces” but in trading minimal communication cost for scalability in memory and compute. Understanding the pairing logic of column and row splitting is the shortest path to mastering this technique.