﻿# ik_llama.cpp graph parallel: when multiple GPUs help

Graph parallel improved generation in one two-card test but hurt prompt processing on another system. Read the actual conditions and topology limits.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/ik-llama-graph-parallel-topology-benchmarks/
Language: en

Graph parallel in ik_llama.cpp lets several GPUs simultaneously execute portions of one language-model layer. In the developer's two-RTX-3090 test, it accelerated LLaMA 70B generation by approximately a quarter relative to layer-based placement. A different three-GPU system, however, produced the opposite result for prompt processing. Graph is therefore a useful experimental setting rather than guaranteed acceleration: model, context length, GPU communication and thermal behavior all matter.

On November 27, 2025, the developer of the llama.cpp fork ik_llama.cpp introduced an experimental implementation in [PR 1018](https://github.com/ikawrakow/ik_llama.cpp/pull/1018). It tested a CUDA idea for dense LLaMA models rather than providing a finished solution for every architecture. On December 1, the author closed it in favor of [1022](https://github.com/ikawrakow/ik_llama.cpp/pull/1022), which included the earlier branch's changes and was merged into main. Development continued: a later [PR 1080](https://github.com/ikawrakow/ik_llama.cpp/pull/1080) merged on December 24. Early results should not automatically be transferred to newer builds.

## How work is divided

With `layer` splitting, different GPUs receive different model layers. In `graph` mode, layer tensors are split by rows or columns and multiple cards can compute parts of the graph in parallel. The original PR describes two main synchronization points per layer, after attention and after the feed-forward network, where partial GPU results are added together. The layer's KV cache, retained state for attention over earlier tokens, is also divided between GPUs. Attention itself is computed in parallel. [Implementation description](https://github.com/ikawrakow/ik_llama.cpp/pull/1018).

The name concerns the ggml computation graph and should not automatically be equated with CUDA Graphs. Parallelism can keep both cards busy, but synchronization exchanges intermediate data. The more expensive communication is relative to computation, the smaller the potential benefit. Effective PCIe width and generation, device routes, direct GPU-transfer support, driver and payload size can all matter. The connector's appearance alone does not establish actual link performance.

A supporting build selects the mode through `-sm graph`, with `-sm layer` as a comparison. The `-ts` parameter sets GPU allocation proportions; the original PR also supported automatic allocation using free VRAM. Check architecture support and options in the [documentation for the selected version](https://github.com/ikawrakow/ik_llama.cpp/blob/main/docs/parameters.md). The initial experimental branch supported fewer models and had more restrictions than later versions.

## What the measurements show

The developer tested two RTX 3090 cards with Q4_0 LLaMA models. For 70B, the report describes full GPU placement and a maximum tested context near 16 thousand tokens. One `sweep-bench` row processed 1024 input tokens and generated 256 with no previously cached KV tokens. Prompt processing reached **790.38 tokens/s with graph versus 751.06 with layer**, approximately 5% higher. Generation reached **28.09 versus 22.61 tokens/s**, approximately 24% higher. [Author tables](https://github.com/ikawrakow/ik_llama.cpp/pull/1018).

These speeds answer different questions. Prompt processing, or prefill, determines how quickly the model reads input; generation, or decode, determines output pacing. The phases are explained in the [prefill and decode article](/journal/llm-prefill-decode/). Do not add their rates or treat them as one metric. With 15 360 already cached tokens in the same 70B table, graph achieved 657.19 versus 543.00 tokens/s for processing, and 25.83 versus 20.09 for generation. For 8B, the author noted that graph generally lost to layer except for long-context prompt processing. These are author tests of specific hardware and builds, rather than an independent performance guarantee.

A separate user experiment was independent of the developer. On November 27, Nexesenex described an RTX 3090 on PCIe 4.0 x16, another RTX 3090 on PCIe 4.0 x4 and an RTX A4000 on PCIe 4.0 x4. The user ran LLaMA 70B Q5_K_M with `-b 256`, `-ts 31,31,19`, a context size of 65 536 and Q8_0 for both K and V cache. According to the comment, graph prompt processing was approximately 2.5 times slower than layer at around 200 context tokens and twice as slow at 10 thousand. Generation was 5–10% faster. [PR comment](https://github.com/ikawrakow/ik_llama.cpp/pull/1018).

The user suggested the narrow x4 connections might explain poor prefill performance, but did not isolate their effect. The comment also attributed much of the generation improvement to better thermal behavior after moving away from locked overclocks. Comparing this with the developer's test does not isolate PCIe: card count and type, model quantization, cache, batch and power settings all differed. The observation establishes a regression on that configuration, rather than proving x4 caused it.

Another participant in the same PR supplied a direct GPU-transfer test. On that participant's machine, unidirectional bandwidth between different device pairs ranged from approximately 5.81 to 13.18 GB/s. These are not measurements of Nexesenex's computer, but illustrate why topology should be checked for each pair rather than judged by card count alone. [Discussion](https://github.com/ikawrakow/ik_llama.cpp/pull/1018).

In December 2025, VoidAlchemy separately [reported on Reddit](https://www.reddit.com/r/LocalLLaMA/comments/1pj9r93/now_40_faster_ik_llamacpp_sm_graph_on_2x_cuda_gpus/) approximately 40% acceleration with two CUDA GPUs and Devstral Small 2 24B Q8_0. The command uses `llama-sweep-bench`, a context of 33 280 and full GPU offload through `-ngl 99`. This is another model and experiment. The accessible post does not fully expose the result chart, compared commands and hardware configuration, so the number remains its author's claim rather than a generally expected improvement.

## Applying the result

Owners of multiple CUDA GPUs can evaluate the mode when their model and cache fit and the selected build supports them. Keep the model file and quantization, context length, batch sizes, layer/cache placement, software version and power settings equivalent. Then measure prefill and generation separately at several context lengths. Record actual PCIe connections, VRAM use, clocks and temperatures, and check answer correctness and server stability.

The distinction between a split model and independent copies is explained in the [parallelism comparison](/journal/data-parallel-vs-tensor-parallel-serving/). This experiment answers a concrete question: does concurrent GPU work save more than synchronization costs? Faster long-prompt reading matters in some workloads, while faster output matters in others; the best mode can differ.

## Sources

- [PR 1018: initial graph-parallel description, tables and tests](https://github.com/ikawrakow/ik_llama.cpp/pull/1018).
- [PR 1022: continued implementation and merge](https://github.com/ikawrakow/ik_llama.cpp/pull/1022).
- [PR 1080: later graph-parallel development](https://github.com/ikawrakow/ik_llama.cpp/pull/1080).
- [ik_llama.cpp parameter documentation](https://github.com/ikawrakow/ik_llama.cpp/blob/main/docs/parameters.md).
- [Devstral Small 2 user test on Reddit](https://www.reddit.com/r/LocalLLaMA/comments/1pj9r93/now_40_faster_ik_llamacpp_sm_graph_on_2x_cuda_gpus/).
