Two ways to spread a model
When one GPU isn't enough, you split something across many. There are two things you can split, and they answer different shortages:
- Data parallelism — put a full copy of the model on every GPU and feed each a different slice of the batch. The gradients are averaged across devices every step. This is the answer when the model fits but training is slow.
- Model parallelism — the model itself is too big for one GPU, so you split its weights across devices. This is the answer when you hit out-of-memory before you ever hit slow.
The Keras 3 distribution API
Keras 3 unifies both under keras.distribution. For data parallel you build a DataParallel object from your devices and call set_distribution() before you build the model — then fit() shards the batches and reduces the gradients for you, with no change to the training code. Model parallel is more deliberate: you declare a DeviceMesh, then a LayoutMap that says how each weight tensor is sharded across the mesh axes.
Reach for the simple one first
Data parallel scales close to linearly out to roughly 8 GPUs and is almost zero extra code. Model parallel is fiddly and only justified once a single replica genuinely won't fit — so measure before you reach for it.