Hot AI News

Multi-GPU diffusion inference: How one image or video is split across several GPUs

One image or video can be generated by several GPUs at once. Here is how sequence parallelism, Ulysses, ring attention and PipeFusion divide the work, and where the limits are.

Multi-GPU diffusion inference: How one image or video is split across several GPUs
Photo illustration: Aiholics

Multi-GPU diffusion inference means using several graphics cards to produce a single image or video, instead of one card per picture. The model’s work on one generation is cut into pieces, each card handles a piece, and the cards swap data so the result matches what one big card would have made.

The goal is either a faster result or a model that is too large for one card’s memory.

Why one picture can need more than one card

Picture four people assembling a large jigsaw puzzle. Giving each person a corner of the table lets them work at once. Sooner or later, though, pieces at the borders must be passed across, and that handoff costs time. Splitting a generation across GPUs follows the same pattern.

Many current image and video generators are diffusion transformers (DiTs). They start from noise and refine it over many steps, and every step runs a large transformer over the whole picture. A transformer reads its input as a long list of small chunks called tokens, here patches of the image or video. A high-resolution picture or a long clip means a very long list, and the cost of the attention step, where every token looks at every other token, grows quickly with that length.

That is why a single generation can be slow on one card, or may not fit at all.

Advertisements

Cutting the token list: Sequence parallelism

A laboratory touch display shows a wave divided into four vertical sections above four groups of colored token tiles.
Photo illustration: Aiholics

The most common answer is sequence parallelism. The list of tokens is divided so that each GPU holds only a slice. Most of the transformer works on each token separately, so the cards can work on their own slices without talking. The exception is attention, where every token needs information from all the others. Two techniques handle that step.

Ulysses swaps what is split. Before attention, the GPUs trade data in an all-to-all exchange, so that each card holds the full token list but only for some of the attention heads (parallel attention calculations inside one layer). A second exchange afterward restores the original slices. Microsoft researchers published this as DeepSpeed-Ulysses in 2023 (arXiv 2309.14509). Its limit is that the number of GPUs cannot exceed the number of heads.

Ring attention keeps the slices in place and passes data around instead. Each GPU computes attention against the keys and values it holds, while sending that block to its neighbor and receiving the next one. After a full circle, every card has seen every token. The method works with any head count, but the smaller blocks can make the attention calculation less efficient.

Combining the two, and adding more splits

Because each method has a weakness, a 2024 paper called USP (unified sequence parallelism, arXiv 2405.07719) argues they are not mutually exclusive and can be combined in a hybrid layout. For example, eight GPUs could be arranged as two Ulysses groups of four, or four groups of two, with ring passing between the groups.

xDiT, an inference engine for diffusion transformers described in a November 2024 paper by Jiarui Fang and colleagues (arXiv 2411.01738), builds on that idea. According to the paper, it treats sequence parallelism and a method called PipeFusion as ways to share the work inside one image, and CFG parallelism as a way to share work between images.

  • PipeFusion splits the image into patches and the model into stages. Each GPU holds one stage, and patches flow through them like items on an assembly line. The method was published as arXiv 2405.14430.
  • CFG parallelism relates to classifier-free guidance, a common trick that runs the model twice per step, once with the prompt and once without. Those two runs are independent, so two GPUs can take one each.

The xDiT paper’s central argument is that no single method scales well alone, so the engine combines them.

Advertisements

Where it shows up today

AMD has packaged xDiT as custom nodes for ComfyUI, the node-based image and video tool. Users choose a model and a GPU count, and a preset fills in a layout. Our report on the release, AMD’s xDiT nodes let ComfyUI split one image or video across several GPUs, covers the nodes, the hardware and the setup steps.

The preset exists because the options interact. The right mix of Ulysses degree, ring degree, pipeline stages and guidance splitting depends on the model, the GPU count and the hardware. A preset is a tested starting point, not a guaranteed optimum, and AMD says every value can be overridden.

Trade-offs and limits

Splitting work is not free. The cards must exchange data, and the speed of the links between them often decides whether adding a card helps. Doubling the GPUs rarely halves the time, and with a poor layout the gain can be small.

Each method also has its own ceiling. Ulysses is capped by the head count. Ring attention can lose efficiency in the attention kernel. Pipeline methods add some waiting while the first stages fill. Memory is a separate benefit: sharding a large model across cards lets it fit where one card could not hold it.

The speedups reported in papers come from specific models, resolutions and hardware, so they should not be assumed for another setup. Multi-GPU inference also serves a narrow audience. It needs several capable cards, and AMD’s first target is Linux with Instinct or RDNA 4 hardware.

What to watch

Three things are worth following. The first is whether presets cover more models and GPU counts, since choosing a layout is the hard part for newcomers. The second is whether the nodes reach the Comfy Registry, which would make installation simpler than the current manual route. The third is how well these methods carry over from images to long video, where token lists are longest and the pressure on memory and communication is highest.

Sign Up for the Daily AI Pulse

One email a day. All the stories that matter.

Daniel ReedAI Research, Safety & Ethics Analyst

Daniel Reed currently works as an AI Research, Safety & Ethics Analyst at Aiholics, writing about how changes in artificial intelligence are affecting and will affect scholarship,…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like