Scaling PDLP to Multiple GPUs
PDLP-type solvers (cuPDLP.jl, cuPDLP-C, cuPDLPx) solve linear programs with only sparse matrix–vector multiplications (SpMV) and element-wise updates, which suits GPUs well. D-PDLP distributes the complete PDLP solver across multiple GPUs. This post covers the three ideas behind it, two-dimensional partitioning, load balancing, and a cost model for choosing the processor grid, mostly through interactive figures.
Paper: arXiv:2601.07628 · Code: GitHub
Why distribute PDHG
A PDHG iteration computes with the matrix but communicates only vectors. Its two SpMVs stream every nonzero of $A$, 24 bytes each. If $A$ is split across $N$ GPUs, each GPU streams only its share, and all the GPUs need to exchange are partial results: vectors with about $m$ or $n$ entries, 8 bytes per entry.
Communication is the slower path. Throughout this post we take the NVIDIA H100 as the example: it reads its own memory at 3.35 TB/s, while NVLink between GPUs moves 450 GB/s per direction, 7.4 times less, and every collective adds a fixed latency of about 10 µs. But a large sparse LP has many more nonzeros than vector entries, so once the problem is big enough to absorb the latency, the computation saved outweighs the communication added.
The break-even sits at two to three million nonzeros, almost independent of density, because latency sets it. Below it, as for the small MIPLIB instances, extra GPUs only add overhead. Above it, splitting pays, and the more nonzeros per row and column, the larger the margin.
Two-dimensional partitioning
The GPUs form an $|R| \times |C|$ processor grid. Device $(i, j)$ stores the matrix block $A_{[i,j]}$, the primal block $x_{[j]}$, replicated down column $j$, and the dual block $y_{[i]}$, replicated across row $i$. Both SpMVs are then computed locally, and an iteration needs only two AllReduce collectives: one sums partial results down each column of the grid, the other across each row.
In exact arithmetic the distributed iteration is the same as the single-GPU one, and in our tests the iteration counts matched on 1, 4, and 8 GPUs.
Load balancing
Real LPs have dense rows, dense columns, and staircase blocks, so equal-sized blocks can hold very different numbers of nonzeros, and every iteration waits for the busiest GPU. A fully random permutation evens out the load but scatters neighbouring nonzeros, which slows the local SpMV. D-PDLP uses block-wise random permutation: it permutes contiguous blocks of 256 rows or columns, keeping each block intact, and then applies nonzero-aware partitioning, which cuts each grid axis into slices with equal numbers of nonzeros.
On zib03 with eight GPUs, the two steps together cut the solve time from 7,369 s (no permutation, uniform partitioning) to 245 s.
The cost model
Which grid, and how many GPUs? D-PDLP predicts the per-iteration time from the data each step moves:
$$ \begin{aligned} T_{\mathrm{step}} ={} & \underbrace{\frac{\mathcal{C}_{\mathrm{spmv}}\,\mathrm{nnz}}{B_{\mathrm{mem}}\, N}}_{\text{SpMV I/O}} + \underbrace{\frac{\mathcal{C}_{\mathrm{vec}}\,\varphi}{B_{\mathrm{mem}}}}_{\text{vector I/O}} + \underbrace{\frac{\mathcal{C}_{\mathrm{net}}}{B_{\mathrm{net}}}\Big(\varphi - \frac{m+n}{N}\Big)}_{\text{network payload}} + \underbrace{n_{\mathrm{hop}}\,\beta_{\mathrm{sync}}\, k}_{\text{topology latency}}, \end{aligned} $$where $\varphi = n/|C| + m/|R|$ is the total length of the vector blocks on each GPU, and $k \in \{0, 1, 2\}$ is the number of grid axes with more than one GPU.
- SpMV I/O falls as $1/N$: each nonzero costs $\mathcal{C}_{\mathrm{spmv}} = 24$ bytes.
- Vector I/O grows with $\varphi$, the vector length per GPU.
- Network payload is what the two ring AllReduces send.
- Topology latency is a fixed cost per collective.
The model needs only $m$, $n$, and $\mathrm{nnz}$, so it runs before the solve. For the H100 we use $B_{\mathrm{mem}} = 3350$ GB/s, $B_{\mathrm{net}} = 450$ GB/s, $\beta_{\mathrm{sync}} = 10\,\mu\mathrm{s}$, and $n_{\mathrm{hop}} = 1$.
Assumptions and derivation of the four terms
The model assumes that every kernel is memory-bandwidth-bound, that each device holds $\mathrm{nnz}/N$ nonzeros (after load balancing, the maximum-to-median ratio is at most 1.0031 on the grids we measured), that computation and communication do not overlap, and that the periodic KKT evaluations and restart checks are amortized. Here $N = N_{\mathrm{device}} = |R|\,|C|$.
SpMV I/O. D-PDLP keeps CSR and CSC copies of each block, so each iteration streams every local nonzero twice, as an FP64 value and an INT32 index: $\mathcal{C}_{\mathrm{spmv}} = 2(8 + 4) = 24$ bytes.
Vector I/O. Row and column pointers, the vector reads inside SpMV, and the element-wise primal, dual, and Halpern updates act on chunks of length $n/|C|$ and $m/|R|$. Their traffic is aggregated into $\mathcal{C}_{\mathrm{vec}} = 90$ bytes per entry, an effective value rather than an exact count.
Network payload. A ring AllReduce of $L$ elements over $K$ devices sends $2L(K-1)/K$ elements per device, in a reduce-scatter and an all-gather phase. The primal collective has $L = n/|C|$ and $K = |R|$, the dual collective $L = m/|R|$ and $K = |C|$. With FP64 elements, $\mathcal{C}_{\mathrm{net}} = 16$ bytes, and
$$ \frac{n}{|C|}\cdot\frac{|R|-1}{|R|} + \frac{m}{|R|}\cdot\frac{|C|-1}{|C|} = \frac{n|R| + m|C| - (m+n)}{N} = \varphi - \frac{m+n}{N}. $$Topology latency. Each collective along an axis with more than one device adds $n_{\mathrm{hop}}\beta_{\mathrm{sync}}$, so $k = \mathbb{I}(|R| > 1) + \mathbb{I}(|C| > 1)$.
Choosing the grid
Apart from the small latency term, the grid shape enters $T_{\mathrm{step}}$ only through $\varphi$, which the paper calls the workload proxy, and
$$ \min_{|R|\,|C| = N} \varphi = 2\sqrt{\frac{mn}{N}} \qquad \text{at} \qquad \frac{|R|}{|C|} = \frac{m}{n}. $$The best grid has the same aspect ratio as the matrix. A matrix with far more columns than rows wants a $1 \times N$ grid: for mcf_2500_100_500, with 83 times as many columns as rows, $1 \times 8$ runs at 1.40 ms per iteration and $8 \times 1$ at 8.83 ms. Click through the grids in Figure 4 to see which term dominates.
Why matching the aspect ratio is optimal
For fixed $N$, the SpMV I/O and the $-(m+n)/N$ part of the network payload do not depend on the grid, so the best grid minimizes $\varphi = n|R|/N + m/|R|$, up to the latency term. With $|R|^\star = \sqrt{Nm/n}$ and $t = |R|/|R|^\star$,
$$ \varphi = 2\sqrt{\frac{mn}{N}}\,\cosh(\ln t), \qquad |\ln t| = \tfrac{1}{2}\Big|\log\frac{|R|}{|C|} - \log\frac{m}{n}\Big|, $$so minimizing $\varphi$ over integer grids is the same as matching the matrix’s aspect ratio on a log scale, which is D-PDLP’s grid topology selection. When $N < n/m$, the constraint $|R| \ge 1$ is active and the best grid is $1 \times N$, with $\varphi^\star = n/N + m$.
When more GPUs pay off
SpMV I/O shrinks as $1/N$, but vector I/O shrinks only as $1/\sqrt N$ on a matched grid. Dropping the nonnegative network and latency terms makes this precise:
$$ S(N) \;\le\; \frac{1}{\rho/N + (1 - \rho)\,\varphi^\star/(m+n)}, $$where $\rho$ is the share of SpMV I/O in the single-GPU time. The speedup is close to linear when $\rho$ is large or the matrix is highly elongated, grows only like $\sqrt N$ when vector I/O dominates, and drops below 1 for small problems, where latency outweighs the work.
The model is rough in absolute terms, since it uses peak bandwidths and ignores caches, but it ranks grids well: on eight H100s it picked the fastest grid for two of three instances, and one within 5.4% for the third.
Results
On the largest instances, eight GPUs turn hours into minutes:
Over fifteen huge-scale instances, SGM10 (the shifted geometric mean of the solve time) falls from 186.6 s on one GPU to 77.7 s on eight. Small MIPLIB instances get slower on eight GPUs, as Figure 1 predicts. Letting the AUTO scheduler choose the GPU count for each instance gives the best aggregate time on both MIPLIB and Mittelmann’s LP benchmark.
Where the time goes
On eight GPUs, SpMV runs 5.2× faster than on one, but the whole iteration only 2.3× faster: NCCL takes 41% of the time. Overlapping communication with computation is the obvious next step. Across nodes the approach still scales: on a Hygon cluster with InfiniBand, the per-iteration time of mcf_2500_100_500 drops about 30× from 1 to 128 GPUs.
Using D-PDLP
The code and documentation are on GitHub. Quick start:
git clone https://github.com/Lhongpei/D-PDLP.git
cd D-PDLP
cmake -B build && cmake --build build --clean-first
mpirun -n 8 ./build/cupdlpx-dist problem.mps.gz results/
Building on this framework, PDHCG and CARDAL now run on multiple GPUs for QP and SDP, respectively; PDHCG also supports conic QPs. Questions are welcome at ishongpeili@gmail.com or as GitHub issues.