Back to .md Directory

Enable chunking with 8 chunks (the default threshold of 8192 tokens)

title: Row-Parallel Chunking

May 2, 2026
0 downloads
0 views
ai llm
View source

title: Row-Parallel Chunking

{ #row_parallel_chunking }

Row-Parallel Chunking is an optimization method for tensor-parallel inference on Intel® Gaudi® that overlaps computation with communication in RowParallelLinear layers. In standard tensor-parallel inference, each RowParallelLinear layer performs a matrix multiplication followed by a blocking all-reduce across tensor-parallel ranks.

In a standard RowParallelLinear forward pass, the execution is sequential:

  1. Compute output = matmul(input, weight).
  2. Perform a blocking all-reduce of output across tensor-parallel ranks.

With chunking enabled, the forward pass becomes:

  1. Split the input into N chunks along the token dimension.

  2. For each chunk i:

    • Compute output_i = matmul(input_i, weight).
    • Launch all_reduce(output_i) asynchronously.
  3. Wait for all async all-reduce operations to complete.

  4. Concatenate the chunk outputs.

This pipelining allows the all-reduce of chunk i to run concurrently with the matmul of chunk i+1, reducing idle time on both the compute engine and the network interface.

Chunking Conditions

Chunking is only applied when all of the following conditions are met:

  • Chunking is configured: num_chunks > 1
  • All-reduce is required: reduce_results is enabled on the layer
  • Tensor parallelism is active: tp_size > 1
  • Input is sufficiently large: total_tokens >= chunk_threshold

When any condition is not met, the layer falls back to the standard single-shot computation.

Input Handling

The implementation handles both 2D [tokens, hidden] and 3D [batch, seq_len, hidden] inputs:

  • 3D with seq_len > 1 (prefill): Chunks along the sequence dimension
  • 3D with seq_len == 1 (decode): Chunks along the batch dimension
  • 2D: Chunks along the first token dimension

Recommended Usage

Chunking effectiveness depends on balancing communication overlap benefits against computational overhead.

We recommend this feature for:

  • Running with tensor parallelism (TP > 1)
  • Serving workloads with large batch sizes or long prefill sequences
  • Workloads where all-reduce communication is a significant fraction of the prefill time

Configuration

The feature is controlled by two environment variables:

Environment VariableConfig NameDefaultDescription
VLLM_ROW_PARALLEL_CHUNKSrow_parallel_chunks1 (disabled)The number of chunks to split the input into. Setting the variable to a value greater than 1 enables chunking.
VLLM_ROW_PARALLEL_CHUNK_THRESHOLDrow_parallel_chunk_threshold8192The minimum number of tokens required to activate chunking. Inputs below this threshold use the standard path.

The following example shows how to set these variables to enable chunking with different configurations:

# Enable chunking with 8 chunks (the default threshold of 8192 tokens)
export VLLM_ROW_PARALLEL_CHUNKS=8

# Enable chunking with 16 chunks and a lower threshold
export VLLM_ROW_PARALLEL_CHUNKS=16
export VLLM_ROW_PARALLEL_CHUNK_THRESHOLD=4096

Performance Characteristics

The speedup ratio is the baseline time divided by the chunked time, where values higher than 1.0 indicate speedup. The following tables show the speedup ratio for an isolated RowParallelLinear layer measured across different tensor parallelism sizes, chunk counts, and token counts. To interpret the values, consider the following:

  • Values greater than 1.0 indicate a speedup over the non-chunked baseline, for example, 1.5 means 50% faster.
  • Values below 1.0 indicate a slowdown due to chunking overhead exceeding the overlap benefit.

Tensor parallelism size equal to 2:

Tokens2 chunks4 chunks8 chunks16 chunks32 chunks64 chunks
10241.0890.8110.5740.3080.2070.108
20481.0761.1610.7530.4770.3340.176
40961.3221.3931.4310.8100.6560.351
81921.1581.4821.4531.2041.0670.620
163841.2391.3161.5891.4891.5141.075
327681.2461.4601.4341.6491.5631.569
655361.2461.4241.5801.4831.5551.548
1310721.2681.4421.5031.6761.5331.514

Tensor parallelism size equal to 4:

Tokens2 chunks4 chunks8 chunks16 chunks32 chunks64 chunks
10240.8920.5790.3740.1950.1040.060
20481.0350.8880.5090.3070.1420.088
40961.1561.0810.7950.4660.2450.134
81921.1711.3041.2550.7490.4850.244
163841.1621.3091.4161.2160.7800.496
327681.1181.2371.2801.4271.2010.766
655361.2181.3101.3861.5281.5531.195
1310721.1931.3871.3321.3531.5601.545

Tensor parallelism size equal to 8:

Tokens2 chunks8 chunks16 chunks32 chunks64 chunks
10240.6560.2530.1320.0750.045
20480.8280.3240.1830.0870.051
40960.9190.4950.2640.1460.078
81920.9930.7050.4700.2400.157
163840.9901.0240.6840.4020.249
327680.9721.1180.9420.7600.469
655360.9891.1641.1291.1790.758
1310721.0181.2411.2771.2971.090

Performance Insights

Optimal configuration varies with tensor parallelism size and sequence length. There is no single setting that will benefit all benchmarks, so we recommend experimenting to find which configuration works best for your specific tensor parallelism size and sequence length. A good starting point is 2 chunks with a 4096-token threshold.

Diminishing returns with too many chunks. Excessively fine chunking introduces overhead from graph breaks, kernel launch latency, and reduced per-chunk compute efficiency. The optimal chunk count depends on both tensor parallelism size and typical token count.

Recommended Settings

The following recommendations are based on isolated layer benchmarks using the Meta Llama 3.3 70B model. In end-to-end inference, the optimal configuration may differ depending on the model architecture, sequence lengths, and workload mix. We recommend benchmarking with your specific setup.

Tensor parallelism sizeRecommended chunksNotes
11 (disabled)No all-reduce needed; chunking adds overhead only
22-64Beneficial for token counts ≥ 4096
42-16Beneficial for token counts ≥ 8192
82-8Beneficial for token counts ≥ 16384

Implementation Details

This feature is implemented in vllm_gaudi/ops/hpu_row_parallel_linear.py as HPURowParallelLinear, which registers as an out-of-tree (OOT) override for vLLM's RowParallelLinear. The chunking logic is entirely self-contained in the forward method and does not modify any other part of the model or the inference pipeline.

Each chunk boundary introduces a torch._dynamo.graph_break() to ensure correct async all-reduce semantics under torch.compile. This means the compiled graph will be split at chunk boundaries, which is a necessary trade-off for enabling async communication.

Related Documents