liveBook · Manning

Distributed system

As explained in LLMs in Production

Distributed computing is a computing technique that divides workloads across multiple networked devices or nodes for concurrent execution.

A distributed system divides a large workload across networked devices or cluster nodes so computation can run concurrently. In deep learning, it becomes essential when models no longer fit in one GPU or when training and inference need to move faster. section 3.3 section 3.3.2

Choose a parallelism strategy according to what limits the workload:

  • Data parallelism splits the data across multiple copies of a model or pipeline; PyTorch DistributedDataParallel supports this pattern, but each model copy must fit on one GPU. section 3.3.2
  • Model parallelism divides the model across devices when replicating the whole model is not practical. section 3.3.2
  • Tensor parallelism breaks tensors across dimensions, while sequence parallelism reduces memory overhead; combining them can parallelize more of a transformer. section 3.3.2
  • Microbatching reduces the bubble created when GPUs holding model weights wait for other stages to process data. section 3.3.2

Parallelizing a slow task with Ray

A sequential loop calls slow_function ten times, each pausing for one second. Decorating slow_function_ray with @ray.remote submits the calls concurrently; ray.get collects their results. The example uses ray.init() and ray.shutdown() to manage the runtime. section 3.3.2

Listing 3.3 Example Ray parallelization task
import ray
import time

ray.init()     #1

def slow_function(x):     #2
    time.sleep(1)
    return x

@ray.remote
def slow_function_ray(x):      #3
    time.sleep(1)
    return x

results = [slow_function(i) for i in range(1, 11)]     #4

results_future = [slow_function_ray.remote(i) for i in range(1, 11)]      #5
results_ray = ray.get(results_future)

print("Results without Ray: ", results)
print("Results with Ray: ", results_ray)

ray.shutdown()

Inspect the minimal Ray listing to compare sequential function calls with remotely submitted concurrent tasks. section 3.3.2

How LLMs in Production covers it

How deep it goes
Explains data, model, tensor, and sequence parallelism plus microbatching, but does not detail cluster internals or communication mechanics.
Examples
Demonstrates a ten-call Ray task and illustrates tensor splitting, transformer parallelization, GPU bubbles, and microbatching.
What it assumes
Assumes deep-learning workloads and introduces distributed computing as a response to model size, GPU-memory limits, and runtime demands.
What you can do after
Apply it via Ray for concurrent tasks and select data, model, tensor, or sequence parallelism for deep-learning workloads.
How it connects
Connects data parallelism with PyTorch DistributedDataParallel and Ray, and connects tensor and sequence parallelism with transformers.

Also explained in

Compare how 15 books explain distributed system →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.