Skip to main content
Distributed Machine Learning

Distributed Stochastic Gradient Descent

Published: 2026-09-11
Level: postgraduate
Audience: Postgraduate students in Distributed Machine Learning

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Data parallelism with synchronous replicas — covered in Lecture 1
  • Averaged gradients on split data and copied models — covered in Lecture 2
  • Asynchronous training, staleness, and decentralized neighbor models — covered in Lecture 3
  • Mini-batches in pipeline stages — covered in Lecture 1
  • Quantization of weights and gradients — covered in Lecture 6

Prior work already covered PySpark pipelines, Hadoop, and Kubernetes. This session closes the distributed gradient-descent family. The next major block is federated learning.

The goal here is to see how stochastic gradient descent (SGD) — a weight-update rule that follows the slope of the loss — behaves when data and workers live on many machines. On one box the story is a single model, a single dataset, and a single slope. On many boxes the same slope is computed in pieces, and those pieces must be mixed so that one global model (a shared set of weights that has seen every shard) can still learn.

Four variants appear, in this order: ordinary SGD on one model, synchronous distributed SGD, asynchronous SGD, decentralized SGD, then a preview of overlap SGD and quantized SGD.

The running picture is Amazon-scale retail traffic: purchases and processing happen across the world, so one zone cannot hold every record. Each zone trains on its own slice and returns a slope. The rest of the notes rebuild that slope from a one-weight toy network, then put the same update onto a server, onto a server with no waiting, and onto a neighbor graph with no server at all.

8.1 The Distributed Training Problem

A single laptop can train a model whose data sits in one file. How do you train when the records live in many cities, and no machine can hold the full set?

On a single machine the story is simple. You hold one model and one dataset. You compute a loss (a number that says how wrong the current prediction is). You compute a gradient of that loss with respect to the weights (the slope of the loss as a function of those weights). You update the weights. Distributed training breaks that picture because the dataset no longer sits in one place.

A worker node is a machine that trains on a shard of the data. A server (also called a master) is a machine that combines worker results. The dataset is split across workers because one box cannot hold every record.

Think of a worldwide checkout desk. You cannot run every purchase through one cash register. Each geographic zone keeps its own receipts, trains on those receipts, and reports a local slope. The verbal picture from class is the same: you cannot run worldwide purchase processing on a single system, so each zone trains on its own slice.

That picture is the Amazon-scale retail example that runs through the whole session. Purchases and processing happen across the world. One zone feeds one copy of the model and computes a local loss. Another zone feeds another copy and computes another loss. Each copy produces its own gradient.

The analogy maps as follows. A zone is a worker. The receipts in that zone are a data shard. The local slope is a worker gradient. The shared catalog of prices (the model) must still be one catalog, not a different catalog per city. The analogy breaks when zones have wildly different traffic mixes: averaging slopes still mixes them, but the mix is only as fair as the shards are representative.

8.1.1 Why Gradients Must Be Combined

The gradients are scattered along servers and worker machines. No single worker has seen the full dataset, so no single local slope is a complete training signal. The training loop must collect those gradients, average them, and form one global gradient — a single update direction for a shared model.

Let be the number of workers. Let be the gradient computed on worker . The verbal rule is: collect all the gradients, average them, and compute the global gradient.

The global gradient (the mean slope across workers) is

Each has the same shape as the weights. If the model stores a scalar weight , then each is a scalar. If the model stores a vector , then each and the average is taken coordinate-wise.

Averaging is the same idea already used in earlier distributed work: local results become one number the whole system can apply. After the average exists, the server (or the workers, in a peer design) applies that one direction to the shared weights.

The verbal explanation of the aim is blunt. You want a global model that represents all of the data. That means the model has learned from the complete dataset, not from one zone alone.

Standard data-parallel training writes the same mix as a sum of local gradients, then takes a step:

The lecture form averages first, then steps with learning rate :

Those two writings agree when (or when each local is already a mean over its shard and the server uses a matching scale). The exam version is the lecture average: collect, average, apply one global gradient.

Two ways to get that global model appear.

Centralized aggregation. Workers send gradients to a server. The server aggregates. After aggregation, the server's weights are treated as equal to training on all of the data. In the parameter-server writing, each round is four stages: workers pull the current weights, workers push local gradients, the server aggregates, and the server updates the stored model. That is the master-worker design used in the synchronous and asynchronous sections below.

Peer exchange. There is no centralized server. Workers exchange gradients with neighbors. Model 3 talks to model 2. Model 2 talks to model 1. Model 1 and model 3 do not need a direct link. After several rounds of exchange, every model holds a copy of the mixed information. The models converge. A little extra loss compared with a perfect central average is acceptable. The requirement is still one global model.

A ring All-Reduce is the textbook cousin of this peer picture: each worker both trains and talks to neighbors, so there is no dedicated master that only averages. Neighbor averaging in Section 8.6 is the same idea with a distance threshold instead of a fixed ring.

The rest of this session first rebuilds ordinary SGD on one weight. Then it rebuilds the same update in the distributed, asynchronous, and decentralized settings.

Scope: Averaging worker gradients yields a global model when every shard is a fair draw from the same data distribution and every worker finishes the round. If one zone holds only one product category, the mean slope is biased toward that category. If one worker never reports, a strict barrier stalls the round (the straggler problem in Section 8.5). Peer mixing needs a connected neighbor graph; an isolated worker never receives the rest of the data.

Imagine workers drawn as four dots on a map, each holding an arrow (its gradient). Centralized aggregation is a star: every arrow is mailed to a hub, the hub draws one mean arrow, and the hub mails the new weight back. Peer exchange is a path: the arrow at node 3 is blended into node 2, then into node 1. After enough blends, every node’s arrow points about the same way. The landmark on that picture is the hub: if the hub dies, the star stops; the path can still mix around a dead far node.

A common trap is to treat four worker copies as four finished models. In the centralized design the workers send slopes, not four independent catalogs. Another trap is to skip the and add raw gradients into an update that already uses . The step size then grows with the number of machines. A third trap is to assume a missing worker is “almost averaged.” A missing shard is missing data, not a zero gradient you can ignore without changing the mean.

Amazon multi-zone retail. Suppose four zones each hold one day’s purchases. Zone A (US-East) computes gradient . Zone B (EU) computes . Zone C (APAC) computes . Zone D (US-West) computes . No zone has seen the full catalog of baskets.

The server (or a later numerical round in Section 8.4) forms

One global step uses that mean, not Zone D’s steep alone and not Zone A’s mild alone. The shared model then represents all four zones. Sense-check: every local slope is negative, so the mean is negative, so the shared weight will increase — the same direction every zone asked for, with a compromise size.

The same pattern appears on multi-GPU machines: GPU 1 through GPU 4 each hold a shard and send a gradient to a server. Geography is optional. Any split of the data across devices is the same problem.

Distributed SGD exists so that one global model can learn from data that does not fit on one machine. Collect the scattered gradients, average them, and apply one update. Next, rebuild that update on a single weight so the later multi-worker arithmetic is not a black box.

Retail platforms, payment switches, and warehouse-scale GPU clusters all hit this wall: the data is large and sharded, the model must still be one model. Federated learning later adds a privacy constraint (do not ship the records, only the slopes or weights), but the mixing step is the same average.

8.1.2 Student Questions and Answers

Several students asked how this session sits on the stack that already covered pipelines and cluster tools.

Q: Where did the last session stop, and what was already covered in the distributed stack?

A: The prior work covered PySpark examples after the pipeline material, then Hadoop and Kubernetes. This session is the last distributed-gradient block. Federated learning starts next.

The next question is the distributed view of SGD itself, not the cluster tooling.

Q: In a distributed setting, what is SGD doing, and why is a distributed view needed?

A: The gradient is scattered along the servers and different machines. Collect all the gradients. Average them. Compute one global gradient. Apply that global gradient to the models.

The aim of that collection step is easy to understate.

Q: What is the ultimate aim of this multi-machine setup?

A: Get a global model that represents all the datasets. That means learning from the complete dataset, not from one shard.

8.1.3 Industry Applications

Real-world: multi-zone retail and payment traffic cannot train on one box. Each geographic zone holds a subset of Amazon-like transactions. Each zone trains locally and returns a gradient. The same pattern appears on multi-GPU machines: GPU 1 through GPU 4 each hold a shard and send a gradient to a server.

Exam note: Be ready to state the aim in one sentence. Distributed SGD exists so that one global model can learn from data that does not fit on one machine.

8.2 Stochastic Gradient Descent on a Single Weight

If the loss is a hill and the weight is where you stand, which way do you step — and how do you know the step did not walk uphill?

Before workers and servers, the update itself must be solid. The vanilla setting is one model, one weight, and one mini-batch loss. Every later distributed rule is this same minus-the-slope step, only the slope is computed on a shard or applied on a busy server.

Think of a hiker on a foggy hill. The ground under their boots is the loss. A tiny step along the weight axis is a probe. The slope they feel is the gradient. Walk opposite the uphill arrow and the loss falls. The analogy breaks on a ridge or a saddle: a one-dimensional weight has no sideways ridge, but a real network does.

8.2.1 Weight Update Rule

Let be the current weight at iteration (where you stand now). Let be the next weight. Let (eta) be the learning rate — how large a step we take. Let be the gradient of the loss with respect to the weight (the slope of as a function of ).

The verbal rule is: new weight equals old weight minus learning rate times the gradient.

The SGD update on one weight is

is a scalar here. is a small step size, often in the classroom traces. is evaluated at . The minus sign walks downhill: if the slope is positive, shrinks; if the slope is negative, grows.

Learning means the weights converge. Convergence is a sequence of these iterations. is where you are. is the next iterate. The learning rate scales the gradient of the loss. Too large an jumps over the valley. Too small an crawls.

8.2.2 A One-Weight Network and Squared Loss

Take the smallest useful network: one weight, no bias. The map is . Here the slope is the weight . The input is . The prediction is . The verbal setup is: a simple neural network with only one weight; multiplied with the weight; ignore the bias.

The weight is initialized at . The input is . The true output is . The model predicts

The ground-truth value is . The difference is the error. The model is wrong because the prediction sits away from the true value. You cannot change the input. The weight is the reason for the loss.

Use a mean squared error with a one-half factor so the later derivative is clean. Let be the loss. The verbal form is: predicted value minus ground truth, whole square, times one by two.

One-half squared loss on a single pair is

The one-half is a convenience: when you differentiate you get , not . Some texts drop the one-half and absorb the extra into . The lecture keeps the one-half.

Substitute the numbers from the initialized network:

Loss is the number you get after substitution. Loss tells how bad the prediction is. Higher loss means a worse prediction. Lower loss means a better prediction.

A true line through the origin with and would need . Starting at is too small, so undershoots . The update should raise .

8.2.3 Gradient as Slope

A gradient is a slope. School algebra already has this. If you change the denominator by a small amount, how much does the numerator change? For two points the slope is

The verbal restatement is: you sit at and move to . The change in approaches zero. The change that movement causes on the -axis is the gradient.

Here the -axis is the weight. The -axis is the loss. The gradient asks: how fast is the loss changing when you slightly change the weight? In other words, how sensitive is the loss to a tiny change in the weight?

That school-slope picture is the working analogy for the rest of the lecture. The later closed form looks different on paper. Geometrically it is the same object: in the limit of a tiny .

8.2.4 Worked Example: Finite-Difference Gradient

Keep and . Start at with loss . Nudge the weight by a tiny change of .

Finite-difference slope at .

Increase the weight to . The new prediction is input times weight:

The loss is one-half times predicted minus ground truth, whole square:

The verbal result is a loss of .

Decrease the weight to . The prediction is . The loss is

The verbal result is a loss of .

Now read the three losses as a path. At the loss is . At the loss is . At the loss is . Increasing the weight reduces the loss. So the weight should go up.

Approximate the derivative with the tiny change . Use the pair and . The change in the weight (the denominator) is

The change in the loss (the numerator) is . The numerical slope is

Round that slope and the gradient is . Using the stated two-decimal loss gives on the nose. The verbal summary is: the gradient is the numerical slope of the loss with respect to the weight. In number terms, that slope is about .

Sense-check against the closed form from Section 8.4: . The probe recovers , which is the same with a small truncation from the curved parabola.

A plot of is a parabola opening upward. The horizontal axis is . The vertical axis is . The vertex sits at , where . At you are left of the vertex, on a downward slope as grows, so the tangent is negative. The landmark is that vertex: every update should walk toward it, not away.

8.2.5 Sign of the Gradient and the Minus Sign in the Update

The sign is not decoration. It tells you which way to move.

  • If the gradient sign is negative, increasing the weight decreases the loss. You need to increase the weight.
  • If the gradient sign is positive, increasing the weight increases the loss. You need to decrease the weight.

Why is this gradient negative? Because is a smaller loss minus a larger loss. As the weight increases, the loss decreases, so the slope is negative.

Plug the negative gradient into the update. Let be the updated weight. The verbal formula is: new weight equals old weight minus eta times the gradient value.

Here (the rounded slope). Then

The minus sign in the update and the minus sign in the gradient cancel. The weight increases. That is exactly what the three-point picture asked for. If the gradient had been positive, the same minus sign would have reduced the weight.

A short rule to memorize:

  • Negative gradient: add to the weight to reduce the loss.
  • Positive gradient: subtract from the weight to reduce the loss.
  • The formula does this automatically.

Students often drop the minus in after they see a negative slope, and then they subtract again by hand. Do not double-correct. Write the formula once, plug in the signed gradient, and let the algebra move . The sign rule is a reading of that algebra, not a second update.

8.2.6 Completing the Update Step

Apply the rounded gradient to . The verbal arithmetic is: old weight minus learning rate times the gradient minus twelve, which is . The only learning rate that turns and into is :

The first demo states the new weight without speaking . The later asynchronous demo uses on the same update family. Those two classroom numbers lock together: is the step size for this lecture.

One SGD step from to .

Given , , :

The new prediction is the new weight times the fixed input:

Old prediction . New prediction . Ground truth . The weight rose by . The prediction jumped toward . The loss dropped drastically:

compared with the old loss . The input never changed. Only the weight moved. Sense-check: is still below the exact fit , so one more small step would finish the job. The step did not overshoot.

You can replay the same table by hand. Fix the input. Change the weight. Recompute prediction and loss. That is the role of the gradient: it tells you how a small weight change moves the loss, and the update uses that slope to walk toward a better weight.

slope vs previous
down as grows
still down
after the SGD step

Gradient magnitude also matters. Too much loss means a larger update, positive or negative. Near a minimum the magnitude is small, so only tiny adjustments are needed. The verbal test is: if I change the weight just a little, how much does the loss move?

Assumption: This derivation uses a scalar weight, squared loss, and a learning rate small enough that one step stays on the same side of the minimum. Scope: Mini-batch noise, stale gradients, and neighbor mixing all reuse , but they change which arrives. If is huge, with jumps far past and the loss can rise. If you edit instead of , you are no longer training; you are forging the data.

Exam note: Memorize the sign rule. Negative gradient: increase the weight. Positive gradient: decrease the weight. The minus in is what makes the rule automatic. A useful numerical is loss when , slope about , then and .

This one-weight walk is the same update a search engine uses when it nudges ranking weights from click logs, and the same update a warehouse GPU uses on a shard of images. The distributed sections only change who computes and when is allowed to move.

8.2.7 Student Questions and Answers

The sign of the slope is the most common first confusion.

Q: If the gradient is negative, should the weight increase or decrease?

A: Increase the weight. A negative slope means a larger weight gives a smaller loss. The update is old weight minus eta times a negative number, so the weight grows on its own.

A second confusion is to treat the input as a knob.

Q: Can we change the input to reduce the loss?

A: No. The input is data. You do not edit data to make the model look good. Only the weight is a trainable parameter.

8.3 Mini-Batch Gradient Descent

If a dataset has hundreds of samples and a model has billions of weights, do you update after every sample, after every full pass, or somewhere in the middle?

The same slope idea now meets a dataset with many samples. Mini-batch gradient descent splits the full dataset into smaller batches and updates from each small batch instead of from one giant pass.

Think of grading a stack of 400 exam scripts. You can recompute the class average after every single script (noisy, slow). You can wait until all 400 are marked (stable, late). Or you can mark 32, average those, adjust your marking scheme, then mark the next 32. That middle cadence is a mini-batch. The analogy breaks when scripts are not shuffled: a batch of only one question type is a biased average, just as an unshuffled shard is a biased gradient.

8.3.1 Three Ways to Use the Dataset

Suppose the dataset has samples. Three update styles exist.

  1. Sample-wise (batch size ). Loop over every sample. For each pair , predict, compute a gradient, and update at once. Immediate update. No waiting. No averaging.
  2. Full batch. Compute a gradient on the entire dataset. Average those gradients. Then update once.
  3. Mini-batch. Take a subset. Compute gradients on that subset. Average those gradients. Update from the average. Repeat on the next subset.

The thing that matters is when the weight changes. Sample-wise updates are the most frequent and the most expensive. Full-batch updates are the most stable and the slowest to show a step. Mini-batch sits in the middle.

Cadence Batch size When moves Averaging Typical feel
Sample-wise After every pair None Fastest feedback, noisiest path
Mini-batch , e.g. After each subset Mean of slopes Compromise used in practice
Full batch Once per pass Mean of all slopes Smoothest, slowest step

When to pick which: use sample-wise only on tiny models and tiny data. Use full batch when fits in memory and you want a true mean slope. Use mini-batch for almost every large model.

Textbook gradient descent (GD) is the full-batch column: sum (or average) over the whole set, then one update. SGD in the narrow sense is the sample-wise column. In this course, and in data-parallel training, “SGD” usually means the mini-batch column: a subset per step, because no worker sees the full set.

8.3.2 Why Mini-Batches for Large Models

Updating after every sample becomes too time-consuming on huge models. Real-world: transformers and large language models can contain some billion parameters. In those cases a per-sample loop is too complex. Choose the approach from the size of the model.

A compact picture uses a frozen weight such as and four inputs. Each input varies. The weight stays fixed for the batch. Each sample produces a loss and then a gradient, using the finite-difference or derivative method above. Then take the average gradient and apply one update.

Mini-batch SGD freezes for the batch, averages the per-sample slopes, then steps once:

is the mini-batch size. is the gradient from sample . The verbal sequence is: compute the gradient sample-wise on a batch, take their gradients, average, and use that average to update the new weight.

That average is the same mixing step a parameter server performs in distributed SGD. GPU 1, GPU 2, GPU 3, and GPU 4 each send a gradient. The server averages. Then one global update runs. Mini-batch on one machine and synchronous distributed SGD on four GPUs differ only in where the shards live.

Frozen weight over four inputs. Keep and . Take four pairs that sit on a simple line through the origin, :

Use the closed-form slope from Section 8.4 (same geometry as the finite-difference slope).

Average, then step:

The true fit on these four points is . One mini-batch step moved , closer to , without touching in the middle of the four forward passes. Sense-check: every is negative, so the mean is negative, so rises. Sample-wise SGD would have moved four times and the later samples would have seen a changing weight. Mini-batch refused that: the weight stayed frozen at until the mean was ready.

On a 400-sample set with you get , so after shuffling you take twelve batches of and one leftover batch of , or you drop the leftover, or you pad. Each of those batches is one average and one update. A 120-billion-parameter transformer cannot afford separate backward passes per tiny batch of text if a grouped backward is already expensive; the grouped backward is the mini-batch.

Assumption: Samples in a mini-batch are treated as a fair draw, and does not change until the batch mean is applied. Scope: If the loader always feeds the same class first, is not the dataset mean. If , mini-batch becomes full batch. If , it becomes sample-wise. Distributed shards are mini-batches that live on different devices; they need a matching average across devices, not only inside one GPU.

Draw the 400-sample set as a long tape. Sample-wise is a tick after every square. Full batch is one tick at the end of the tape. Mini-batch is a tick every squares. The landmark is the tick: that is when is allowed to move. Takeaway: the slope formula does not change; the clock that applies it does.

Do not mix cadences inside one formula. Averaging and then also dividing by a second time shrinks the step without meaning to. Do not update inside the batch loop and then average those updated weights and call it mini-batch; that is a different algorithm. For large language models, “too slow” is about wall-clock backward passes, not about the algebra of .

Sample-wise, mini-batch, and full batch all use the same slope. They differ in how often the weight moves and whether gradients are averaged. Mini-batch is the practical cadence for large models, and it is the inner step each distributed worker runs on its shard.

Multi-GPU training in a data center is mini-batch SGD with hardware shards. Each GPU holds part of the global batch. The server (or an All-Reduce) averages GPU gradients and applies one global update. Recommendation systems and speech models use the same cadence: group examples, freeze weights, average, step.

8.3.3 Student Questions and Answers

Q: What is mini-batch gradient descent, in plain language?

A: Split the whole batch into multiple small batches and run gradient descent on those. Instead of sending the whole data together, update the weights by splitting into multiple small batches.

8.3.4 Industry Applications and Exam Notes

Real-world: Multi-GPU training is mini-batch SGD with hardware shards. Each GPU holds part of the batch. The server averages GPU gradients and applies one global update.

Exam note: Know the three cadences. Sample-wise, mini-batch, and full batch all use the same slope. They differ in how often the weight moves and whether gradients are averaged.

8.4 Synchronous Distributed SGD

Four workers each hold a different pair and the same starting weight. Do they finish with four models, or with one?

Synchronous distributed SGD is mini-batch SGD with a barrier. Every worker starts from the same global weight. Every worker computes a gradient on its own data shard. The server waits until all gradients arrive. The server averages. The server applies one global update. Then it sends the new weight back. No worker starts the next round on a private model.

The finite-difference slope from Section 8.2 is slow to type on every sample. The same slope has a closed form. That algebra looks unlike , but it is geometrically the same change in loss when changes.

8.4.1 Derivative of Squared Loss

Keep

Substitute the prediction:

The verbal plan is: treat the inside as , so the loss is one-half square. Use the power rule: differentiates to . Set . Then . Differentiating with respect to produces a factor that cancels the one-half:

The chain rule also needs . The derivative is with respect to , not with respect to . The input is data. The weight is the parameter. So

and the full chain is

The per-sample gradient of one-half squared loss on is

Call this . The error in this derivation is , which is predicted minus true. Worker tables later list that error and then multiply by .

The product looks unlike . Geometrically it is the same object. It is still the change in loss when you change . The algebra is just a faster way to get that slope.

Spot-check on the Section 8.2 toy: , , :

That matches the rounded finite-difference slope . Dimensional check: is a prediction error (same units as ); multiplying by turns that error into a slope on the -axis.

A common slip is to differentiate with respect to the input. Then and you would write , which is the wrong parameter and the wrong table.

8.4.2 Worked Example: Four Workers, One Global Weight

For brevity the global weight is a scalar . In a real net this would be a whole set of weights. In the first round every worker receives .

Each worker has its own data shard. The spoken pairs and later “closer to 3, 5, 7, 9” line up with four points . Worker 1 is spoken as and worker 4 as gradient . The inner two pairs follow from those gradients and from the spoken targets and :

Solving for on workers 2 and 3 with the consistent closed form recovers and . These four points lie on the line . The toy model has no bias, so it cannot fit that line exactly; the best scalar is a compromise near . One synchronous step should raise toward that compromise, not away from it.

Four workers, global weight , closed-form gradients.

Worker 1. Data . Prediction . Error . Gradient

Worker 1 says: increase the weight slightly. The gradient is .

Worker 2. Data . Prediction . Gradient

Increase the weight, more than worker 1.

Worker 3. Data . Prediction . Gradient

Increase the weight more strongly. The spoken list stresses a “medium” third sample and then “very high ” for the fourth. The consistent closed form for is ; that is the value that belongs in the average.

Worker 4. Data . Prediction . Gradient

Increase the weight very high. The spoken fourth gradient is .

All four workers used the same starting weight. The gradients still differ because the inputs differ.

The server averages:

The overall gradient is negative, so increasing the weight decreases the loss. The algorithm increases the weight automatically. Using the same as the later async numbers,

Spoken new-weight values include , , and . The exact step with and mean gradient is . The classroom roundings and sit on either side of that exact value; is a nearby slip of the same step. Predictions below use the spoken , which is to one decimal.

After the update, predictions move toward the four targets. With they are , , , and , closer to , , , and .

Mean one-half squared error at :

At :

The spoken loss path “2.2.6 to 0.2” is a garbled reading of this drop: about down to about . The reconstructed means then are the exact one-half squared errors. Sense-check: (and the spoken ) still lie below the no-bias least-squares fit , so the step moved the right way and did not overshoot the valley.

Worker error
1
2
3
4
mean

8.4.3 One Global Model, Not Four Local Models

A common wrong picture is: worker 1 updates model 1, worker 2 updates model 2, and so on, leaving four final models. That is not this algorithm.

Workers do not create four different final models. They send gradients. Worker 1 computes . Worker 2 computes . Worker 3 computes . Worker 4 computes . The master node receives all four. The master performs one global update. Then the new weight is shared with every worker.

Synchronous distributed SGD, as a procedure:

  1. Server sends the current global weight (first time: ).
  2. Each worker computes a gradient on its local shard.
  3. Workers send gradients to the server.
  4. Server averages and updates one global weight.
  5. Server sends the new weight for the next epoch.
  6. Repeat.

Each epoch uses the latest global weight. Workers never keep a private finished model in this synchronous design.

That loop is the parameter-server four-stage cycle (pull weights, push gradients, aggregate, update) with a barrier on stage 3: the server does not update until every worker has pushed. An All-Reduce implements the same barrier without a dedicated master: workers average among themselves, then each applies the same . The lecture exam picture is the master: one global update.

Inputs: a shared , shards, learning rate . Outputs: one new , identical on every worker after the broadcast. Time cost: one local backward per worker plus a wait for the slowest worker plus one average. Space cost: one model replica per worker plus the server copy.

When to use / alternatives: Use synchronous averaging when you want a single global model and you can tolerate waiting for stragglers. Switch to asynchronous SGD (Section 8.5) when a slow worker would idle the rest. Switch to decentralized SGD (Section 8.6) when a master is a single point of failure or a long hop. Do not “fix” sync SGD by letting each worker apply locally and then shipping four finished models; that is a different algorithm.

8.4.4 Aggregation Beyond Simple Averaging

The average used above is FedAvg-style: a simple mean of worker gradients (or of worker models). It is fine for teaching. It is not the end of the research story. Aggregation is not as simple as a plain mean. A large literature studies better mixing rules.

Standard federated averaging (FedAvg) weights each model by how many local samples it trained on:

If every shard has the same , this collapses to the lecture mean. Federated SGD (FedSGD) is the gradient analog: average gradients instead of weights. The classroom four-worker step is FedSGD with equal shard sizes. Unequal zones (a huge US-East log and a tiny APAC log) need the weights, or the tiny zone punches above its data.

FedAvg is the ideal case: shards look like the same distribution (IID), workers have similar speed, and no worker is adversarial. Real federated systems break those conditions, which is why later aggregators exist (median-based mixers, proximal terms, personalization). For this lecture, keep the simple mean, and remember that it is a baseline.

Real-world: a paper from IIT Bombay on federated asynchronous simultaneous training is flagged as the next reading. The spoken short name sits in the FedAvg / Fed-async family (the audio sounds like “fed asked”). The matching published title is FedAST: Federated Asynchronous Simultaneous Training — a buffered asynchronous aggregator for training several models at once on a shared client pool, so a slow client on a large model does not stall every task. Keep the lecture’s reading pointer; treat FedAST as the standard short name for that method.

Scope: Equal-weight averaging assumes equal shard sizes and a completed barrier. Assumption: every worker used the same . If one worker trained on an older , you are no longer in synchronous SGD; that is staleness (Section 8.5). If you average models that each took many local steps, you are closer to FedAvg than to one-step FedSGD. Both are valid, but they are not the same numerical object as above.

Exam note: If a short numerical is asked, show the table: weight, prediction, error , gradient , then the average, then . Do not draw four final models. The master applies one global update.

Synchronous averaging is how a four-GPU image trainer stays on one ResNet, and how a payment-fraud model stays on one weight vector while card logs stay in regional warehouses. The next design removes the wait.

8.4.5 Student Questions and Answers

The highlighted gradient column still looks like a new object to some students.

Q: On the demo, what does the highlighted gradient term convey internally? Is it something other than a slope?

A: Internally it is still over . You are computing a derivative, and a derivative is a slope. Do not assume the formula is a different geometric object. Geometrically it represents the same change in loss when changes.

The chain-rule target is the other high-frequency slip.

Q: When differentiating , is the derivative taken with respect to the input ?

A: No. Take the derivative with respect to the weight , not with respect to . The input is not a trainable parameter. After the chain rule you still multiply by , because and . Students who differentiate the loss with respect to the input get and the worker table no longer matches the finite-difference slope.

8.5 Asynchronous SGD and Stale Gradients

If one GPU is late, should the other three sit idle, or should the server take each arriving slope as soon as it lands?

Asynchronous SGD still has a server. The change is the barrier. Workers do not wait for each other. Whenever a worker finishes a gradient, it sends that gradient at once. The server updates the global weight at once. Faster workers do not sit idle because a slow worker (a straggler) is late.

8.5.1 Synchronous Versus Asynchronous Updates

Purpose. Asynchronous SGD exists to hide stragglers. In the synchronous case already studied, all workers start from the same global point. They compute gradients. They send those gradients. The server takes the average. The server updates the weights. Then workers wait for the next version. Slow workers hold everyone.

In the asynchronous case, there is still a server, but there is no all-reduce barrier. The update is still

where is the gradient from whichever worker just finished. The server overwrites its weight using that one gradient. It does not wait to average a full set.

Inputs: current server weight , learning rate , a stream of worker gradients that may have been computed on older copies of . Outputs: a sequence of server weights, one per arrival, not one per full round.

Synchronous SGD Asynchronous SGD
Server Yes Yes
Barrier Wait for all gradients No wait
Update per arrival
Extra loss source Straggler idle time Stale gradients
When to pick You need a clean mean and similar worker speeds Worker speeds differ a lot

When to pick which: if GPUs are twins on one fabric, stay synchronous. If one zone’s network is a second slower, go asynchronous and watch staleness.

Federated learning uses the same fork. Synchronous FL waits for a chosen set of agents before aggregating. Asynchronous FL lets trusted agents upload whenever they finish, and the aggregator may close a round on a count, a timer, or a quorum such as or .

8.5.2 Worked Example: Immediate Server Updates

Start with a normal SGD picture. Current weight, updated weight, learning rate, gradient. If the gradient is negative, the weight increases. If the gradient is positive, the weight decreases. Now add asynchrony.

Async trace from with . Worker 4 is slow and does not finish in this trace. Three workers finish in order with gradients , , and . Every worker began with the same copy .

Worker 1 finishes first. Gradient . The server still holds . The server applies the gradient at once:

The server now holds .

Worker 2 finishes next. Worker 2 computed its gradient using the old weight . That gradient is . The server is already at . The server still applies on top of the new copy:

The server now holds .

Worker 3 finishes last. Worker 3 also computed its gradient using . That gradient is . The server is already at . The spoken arithmetic is “ minus into minus , which is ”. Treating “” as would give , which is not the stated result. The stated result matches :

Treat the spoken as a slip; keep with the rest of the lecture.

Final server weight in this trace is . Worker 2 and worker 3 used gradients computed on an older version of the model. Those gradients are late.

Sense-check: each arriving is negative, so each overwrite raises . The path is three downhill steps with growing magnitude, not an average of (that mean would be and a single sync step would have been ). Async walked farther because it applied three full steps instead of one mean step.

8.5.3 Stale Gradients

A stale gradient is a gradient computed using old model parameters but applied to a newer model. Staleness is the gap between the weight used to compute and the weight that receives .

Walk the server-side clock:

  1. Time 0. All workers copy and start computing.
  2. Time 1. Worker 1 updates the server. Server becomes . Fresh update.
  3. Time 2. Worker 2 updates the server. Server becomes . Worker 2's gradient was computed at , so it is already slightly stale relative to .
  4. Time 3. Worker 3 finally sends a gradient computed from . The server currently has . The gradient belongs to old but is applied to . That is a stale gradient.

Worker 3 is the loud case. Compute at . Apply at . The gap is in weight space.

Staleness is not always fatal. If the learning rate is small and the gradients are not too noisy, the system can still converge. Large steps plus very old gradients are the dangerous mix.

Assumption: Workers pull a copy of , compute, and push without being interrupted. Scope: A delay of one server step (worker 2) is a mild stale apply. A delay of many steps with a large can point into a region the model has already left, like steering with a map from last week. Bounded-staleness and buffered async methods (FedBuff, FedAST) collect several arrivals before applying, which is a middle ground between this vanilla overwrite and a full barrier.

Draw a timeline. Horizontal axis: server time. Vertical axis: . The server staircase jumps at each arrival: , , , . Horizontal dashed lines mark the weight each worker used to compute ( for all three in this trace). The landmark is the gap between a dashed line and the staircase at apply time. Takeaway: the gradient is honest about an old hill, then it is spent on a new hill.

8.5.4 When Workers Receive New Weights

A natural hope is: after worker 1 updates the server to , the server immediately broadcasts to everyone else, and those workers restart. In basic asynchronous SGD that broadcast does not happen.

  • The server does not wait for all workers.
  • The server does not force remaining workers to restart with the newest model after every update.
  • Workers keep running. A worker may still be computing a gradient on an older copy.
  • No forced broadcast hits worker 2 and worker 3 while they are busy. The server does not interrupt them.

Worker 1 is not left out of the “remaining workers” story. After worker 1 sends its gradient and the server moves to , worker 1 may pull the latest and start the next mini-batch. The pull happens because this batch is done. The server does not interrupt a worker in the middle of a gradient.

Typical pull points (implementation dependent):

  • When a worker asks for the next task.
  • When a new mini-batch starts.
  • When a new epoch starts.
  • After some fraction of workers have reported, such as or , in variants that wait for a quorum before shipping new weights.

The principle: while a worker is running a gradient, it is not stopped. Once it starts a new batch or a new epoch, it may read the cache of new weights. Slow workers may still send gradients computed from old weights. Those gradients may be stale.

8.5.5 Server Load Compared With Synchronous Averaging

Synchronous SGD: workers send gradients, the server averages once, the server updates once. Asynchronous SGD: each finished worker triggers its own weight update. Backpropagation on the workers still happens locally. The extra question is whether the server becomes busier because it applies many single-worker updates instead of one mean.

The steps are similar: a gradient arrives, a weight is written. The count of server writes is higher in the async path, because each arrival is an update rather than one averaged update. Whether that is a heavy difference is something to check in code. It seems more operations happen on the server in the async case.

Complexity: for workers and local steps, sync SGD does about averages and writes. Vanilla async SGD does about writes. The worker-side backward pass count is the same family of work; the server-side apply count is what grows. Network traffic also shifts from one bundled round to many small messages, which can help or hurt depending on latency versus bandwidth.

Do not name every late gradient a failure. Staleness is a delay, not an automatic diverge. Do not force a restart mid-backward and call that “async SGD”; interrupting in-flight work is a different, more aggressive protocol. Do not assume the server is idle in sync SGD and overloaded in async SGD without counting writes: sync waits, async writes. The dangerous mix is a large with a very old .

A stale gradient is computed on old weights and applied to newer weights. Small and quiet gradients can still converge. New weights are pulled at batch or epoch boundaries, not by interrupting a worker mid-gradient. Next, drop the server entirely and mix with neighbors.

Parameter-server clusters for huge embedding tables often run this way: many workers stream gradients, the server applies them as they land, and a slow crawler does not freeze the ads model. The cost is the stale apply you just traced from onto .

8.5.6 Student Questions and Answers

Several questions clustered on one confusion: when the new goes back, and whether anyone is forced to restart.

Q: When a worker sends a gradient, what does the server update, and when do new weights go back to the workers?

A: The server updates its own weights with the formula as soon as a gradient arrives. It does not wait for other processes. A worker gets a fresh copy when it asks for the next task or starts a new mini-batch, not by being interrupted mid-compute.

The restart hope is the same confusion asked the other way.

Q: After worker 1 updates the server to , does the server immediately send that new weight to the remaining workers and force a restart?

A: No. In asynchronous SGD the server does not wait and does not force all remaining workers to restart with the newest model after every update. Worker 2 and worker 3 keep computing with their old copies.

Worker 1’s next batch is a third wording of the pull rule.

Q: If remaining workers are not forced to restart, when does worker 1 get the new weights? Must it wait, or can it start the next batch on its old weights?

A: Worker 1 may pull the latest and start the next mini-batch once its current batch is done. It is not forced to idle. It also does not interrupt the others. New weights are read at batch or epoch boundaries, not while a gradient is mid-flight.

A separate confusion is server load, not staleness.

Q: Synchronous updates average all workers, then do one heavy update. Does asynchronous SGD pile more backpropagation onto the server and make the server much busier?

A: The worry is valid. From the server's view, vanilla synchronous SGD averages incoming gradients and updates once. Async SGD applies a new weight after each arrival. The number of server-side updates can be higher. The worker-side backward pass still happens on the workers. Check with code. It seems more operations run in the async design.

8.6 Decentralized SGD

If the master is a single point of failure, can workers still mix their models by talking only to nearby machines?

Decentralized SGD removes the central parameter server. Each worker keeps its own model. Workers periodically exchange parameters with neighbors in a local vicinity. “Vicinity” here means models whose distance is less than or equal to a threshold. Those nearby machines share parameters.

This is not asynchronous SGD with the server unplugged. Asynchronous SGD still has a server and stale gradients. Decentralized SGD is the neighbor-exchange design.

8.6.1 Neighbor Exchange Instead of a Master

Purpose. Neighbor exchange reduces the single point of failure of a central parameter server. It also cuts communication overhead. In the master design, every machine sends to the master and later gets a response. Neighbor exchange is a shorter hop.

Inputs: each worker’s local weights , a neighbor graph (or a distance threshold ), and a mixing rule. Outputs: updated local weights that have mixed information from the graph. After enough rounds, every model is a close copy of one global model, perhaps with a little extra loss compared with a perfect central average.

The topology matches the peer picture from the opening. Model 3 need not talk to model 1 if both talk to model 2. After several exchanges, information mixes through the graph.

Steps. When neighbors and mix, a simple average of their weights is

The verbal rule is: exchange parameters with neighbors and average. Models converge, perhaps with a little extra loss.

A local SGD step still happens on each worker, , on that worker’s shard. Mixing and stepping can alternate: train locally, then average with whoever is currently inside the distance threshold.

The student wrap-up sometimes labels this neighbor average as “asynchronous.” That label is wrong. Asynchronous SGD still has a server and stale gradients. Decentralized SGD is the neighbor-exchange design. Workers update locally. When workers come closer (distance at most the threshold), they exchange weights, often by averaging.

A ring All-Reduce is the data-center cousin: every node is a worker, there is no dedicated parameter server, and the mix is a fixed ring instead of a distance threshold. Blockchain-style swarm mixing is a further cousin used in some federated settings; the lecture exam object is the threshold neighbor average.

Three workers on a path, distance threshold . Place models on a line at positions , , and . Neighbors are pairs whose distance is at most : and . Model 1 and model 3 do not share a direct link.

Suppose after local steps the weights are , , .

Round 1, mix with :

Now the vector is . Mix with :

Now the vector is . Round 2, mix with again:

The three weights were and are now . The mean of the original three is . Information from model 3 has already moved one hop into model 2 and is entering model 1. Sense-check: no master stored a global ; each mix was a two-party average; the values are walking toward each other, not away.

Complexity: each mix ships one weight vector across a short link. With a central master, every worker ships to the same hub (fan-in) and the hub ships back (fan-out), so the hub bandwidth shrinks as . Neighbor mix costs grow with the number of edges, not with a single hot spot. The trade-off is mixing time: a long path needs several rounds before the far worker’s data arrives.

8.6.2 When Decentralized Training Helps

Use decentralized SGD when communication costs are high.

Real-world: edge computing on low-end devices. A small device cannot talk to a master all the time. Exchanging with a neighbor is a different cost from sending to a master. Federated learning is another setting where a central controller may be impractical. You may not be able to deploy a machine that acts as master controller.

Failure handling is local. Updates live on each machine. You can exchange only with neighbors inside distance threshold. A dead far-away node does not freeze the whole ring the way a dead parameter server can.

When to use / alternatives: Pick decentralized SGD on edge radios, on a shop floor of sensors, or whenever standing up a trusted aggregator is politically or operationally hard. Pick a parameter server when you want a single consistent snapshot and you can afford the hub. Pick async SGD when you still want a hub but not a barrier. Decentralized mix is slower to reach a perfect global mean; that extra loss is acceptable when the alternative is no training at all.

Picture three phones in a corridor. Each trains on its own photos. Every few minutes a phone pairs with whoever is within a few metres and they average weights. The corridor is the distance threshold. The landmark is the missing cloud server: if the building’s uplink dies, mixing can continue indoors.

Calling neighbor averaging “asynchronous SGD” hides the missing server and will cost marks. Averaging with is not the same as applying a stale on a master. Another trap: mixing only once and declaring the models global; one hop does not carry a far shard. A third trap: using a disconnected graph. If model 4 never has a neighbor, its data never enters the rest.

Decentralized SGD has no master. Each worker keeps a model and averages with neighbors whose distance is under the threshold. That is a different design from asynchronous SGD, which still has a server. Next, write the three data loops in code form and name overlap SGD and quantized SGD for the follow-up session.

Phone-to-phone model mixing in a weak-signal warehouse, and peer mixing among hospital sites that will not stand up a shared aggregator, are the same pattern: train locally, average with whoever is close enough, accept a little extra loss.

8.6.3 Student Questions and Answers

The label mix-up is the one confusion to keep.

Q: After covering synchronous and asynchronous SGD, is the third type the one where each worker updates its own weights and, when workers come closer, they exchange weights by taking an average? Is that still asynchronous SGD?

A: The neighbor-exchange picture is decentralized SGD, not asynchronous SGD. Asynchronous SGD still has a server. The server applies each arriving gradient and workers pull new weights when they start a new batch. Decentralized SGD has no master. Each worker keeps a model and averages with neighbors whose distance is under the threshold.

8.7 Batch Loops, Overlap SGD, and Quantized SGD

The same one-weight update is three different for loops in code. What changes is not the slope formula, but when is allowed to move — and how expensive the message that carries the slope is.

The same one-weight update appears in code as three data loops. Two further distributed variants are named for later study: overlap SGD and quantized SGD.

8.7.1 Sample-Wise, Mini-Batch, and Full-Batch Loops

These three loops are the concrete form of Section 8.3. They are also the inner step that each distributed worker runs on its shard.

Three loops on a five-sample shard. Let the shard be five pairs, , and start at some .

Sample-wise loop (batch size ). Walk the entire dataset. For each sample , compute a prediction, compute a gradient, compute a new weight. Immediate update. No waiting. No averaging. Five samples means five updates. The verbal loop is: take a sample of comma , predict, compute the gradient, compute the new weight.

After sample 1, has already moved, so sample 2 sees a different model. That is the point: fastest clock, no mean.

Mini-batch loop. Keep the weight frozen for the batch. Collect gradients. Replace them by their mean. Plug that mean into the update formula. Then move the weight.

For a batch of the first two samples:

Then freeze again for samples 3–4, and handle sample 5 as a leftover batch of size . Two or three updates, not five.

Full-batch loop. Same averaging idea, but the “batch” is the entire dataset. One mean. One update per pass.

Sense-check: the algebra of is the same object in all three loops. Only the grouping changes. Distributed synchronous SGD is the mini-batch (or full-shard) loop plus a barrier across machines. Distributed async SGD is closer to applying each finished shard’s the way the sample-wise loop applies each sample’s , except the “samples” now live on different workers and may be stale.

Purpose of the three loops. They turn the same update into a training program. Inputs: a dataset (or shard), , a batch size . Outputs: a sequence of weights whose length is (sample-wise), about (mini-batch), or per epoch (full batch).

8.7.2 Overlap SGD and Quantized SGD

Overlap SGD is named as the next distributed variant after async and decentralized. The details are deferred so that code and demos can be inspected together.

The idea, in one paragraph, is to hide network wait inside math that must happen anyway. In a naive synchronous round you finish the whole backward pass, then you all-reduce the gradient, then you step. Overlap SGD starts shipping the first ready gradient buckets while later layers are still computing backward. The communication and the remaining compute sit on the same timeline instead of end-to-end. Frameworks such as multi-GPU data-parallel trainers do this by grouping parameters into buckets and launching an asynchronous reduce as soon as a bucket is ready. The lecture will treat the implementation as a follow-up, not as an exam derivation.

Quantized SGD compresses what workers send. Quantized means: lower the bit size of the data. Gradients (or weights) travel in fewer bits. That is a communication trick, not a new loss. It belongs with overlap SGD in the follow-up session, before the move into federated learning.

A standard integer often uses bits. If a value only needs the range , bits suffice. Mixed-precision training goes further: store some tensors in -bit floating point instead of . The transform is lossy: and may collapse to the same code. Models usually still converge, sometimes to a slightly worse minimum. For distributed SGD the payoff is smaller messages on the wire, which is the industrial reason to quantize shipped gradients.

Scope: Overlap SGD does not change the mathematical average; it changes when bytes leave the GPU. Quantized SGD does change the numerical payload: fewer bits, some rounding. Assumption: the follow-up session will inspect code for both. Do not invent a new loss function named “quantized loss.” The loss stays ; only the message encoding changes.

Federated learning is the next large topic: how to aggregate, how to fill missing features, horizontal federated learning, and vertical federated learning. Horizontal (sample-based) federated learning is the Gboard-style case: the same features, different users. Vertical (feature-based) federated learning is the bank-plus-shop case: the same people, different columns. Distributed SGD is the bridge. Close these variants first.

Three distributed designs sit on the table: synchronous (wait, average, one update), asynchronous (update per finish, pull on the next batch), decentralized (no master, neighbor average). Overlap SGD hides communication behind compute. Quantized SGD lowers bit size. Federated learning comes next.

Shipping FP16 or INT8 gradients between GPU racks is why quantized SGD shows up in production trainers. Overlapping the reduce with backward is why a well-tuned data-parallel job is not twice as slow as a math-only profile would suggest.

8.7.3 Student Questions and Answers

Q: What does quantized mean in quantized SGD?

A: Lower the bit size of the data. Send cheaper messages. The rest of the method waits for the next session.

The closing request is a recap of the three main distributed methods.

Q: Can someone summarize the distributed gradient methods in two or three points?

A: Three types sit on the table. First, synchronous distributed SGD: every worker computes a gradient, the server waits for all of them, aggregates, updates the weights, and distributes the new weights to all workers. Second, asynchronous SGD: each time a worker finishes, the server updates the weights; workers take the new weights when they start a new batch; nobody waits for every worker. Third, decentralized SGD: workers update locally and, when they come close enough, exchange weights by averaging. The main async rule is that new weights are taken when you start passing a new batch.

Exam Guidance Summary

This session did not publish a mark table. The study signal is still sharp.

  1. Close the distributed SGD family before federated learning. Know synchronous distributed SGD, asynchronous SGD, and decentralized SGD as three different designs, not three names for one idea.
  2. Expect numerical traces like the classroom demos. One-weight finite-difference slope (loss when ). Four-worker mean gradient from shards. Async chain with stale gradients.
  3. Memorize the sign rule. Positive gradient: decrease the weight. Negative gradient: increase the weight. The minus in is what makes the rule automatic.
  4. Do not confuse sending gradients with training four final models. In synchronous distributed SGD the master applies one global update.
  5. Name staleness correctly. A stale gradient is computed on old weights and applied to newer weights. Small and quiet gradients can still converge.
  6. Federated learning is flagged as the next high-value block. Aggregation, missing features, horizontal federated learning, and vertical federated learning are the coming topics. Overlap SGD and quantized SGD (lower bit size) are the remaining distributed details to finish first.

Exam note: If a short numerical is asked, show the table: weight, prediction, error , gradient , then the average, then . Close synchronous, asynchronous, and decentralized SGD before federated learning.

Key Industry Applications

  1. Amazon-scale multi-zone data. Worldwide purchase and transaction streams do not fit on one trainer. Each zone trains on a subset and returns a gradient so one global model can represent all zones.
  2. Multi-GPU mini-batch training. GPU 1 through GPU 4 compute gradients on shards. A server averages and performs one global update. This is synchronous distributed SGD on accelerators.
  3. Large language models and transformers. Models with some billion parameters make per-sample updates too heavy. Mini-batch (and sharded mini-batch) is the practical cadence.
  4. Edge computing and low-end devices. Always-on links to a master are expensive. Decentralized SGD exchanges parameters with neighbors inside a distance threshold.
  5. Federated learning. Central coordination may be impractical. FedAvg-style means are the teaching baseline. Richer aggregation, including federated asynchronous simultaneous training (IIT Bombay), is active research. Horizontal and vertical federated learning come next.
  6. Quantized communication. Lowering bit size of shipped gradients is the industrial reason for quantized SGD: less network cost between workers and servers.

DML Lecture 8 notes · Distributed Stochastic Gradient Descent

Distributed Machine Learning· postgraduate· 2026-09-11

Sections Breakdown

1The Distributed Training Problem

When data is sharded across workers, local gradients must be averaged into one global gradient so a shared model can learn from the complete dataset.

2Stochastic Gradient Descent on a Single Weight

SGD updates a weight by stepping opposite the slope of the loss. A one-weight squared-loss demo moves w from 2 to 3.2 and the prediction from 6 to 9.6.

3Mini-Batch Gradient Descent

Mini-batch SGD splits the dataset, freezes the weight for a subset, averages those gradients, and steps once. It is the practical cadence for large models and the inner loop of distributed SGD.

4Synchronous Distributed SGD

Every worker starts from the same weight, sends a closed-form gradient (wx-y)x, and the master averages once. Four workers at 1.5 yield mean gradient -6.25 and new weight 2.125.

5Asynchronous SGD and Stale Gradients

The server applies each arriving worker gradient at once, so stragglers do not idle the rest. Gradients computed on old weights and applied to newer weights are stale.

6Decentralized SGD

With no parameter server, workers keep local models and average weights with neighbors inside a distance threshold, avoiding a single point of failure.

7Batch Loops, Overlap SGD, and Quantized SGD

Sample-wise, mini-batch, and full-batch loops apply the same update on different clocks. Overlap SGD hides communication behind compute; quantized SGD lowers the bit size of shipped values.

8Exam Guidance Summary

Know the three distributed SGD designs, the sign rule, the classroom numerical traces, and the definition of a stale gradient before federated learning.

9Key Industry Applications

Distributed SGD shows up in multi-zone retail, multi-GPU trainers, large language models, edge devices, federated learning, and quantized communication.

Postgraduate students in Distributed Machine Learning

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

The Distributed Training Problem

Must-know: Distributed SGD exists so one global model can learn from data that does not fit on one machine.

⚠️ Top pitfall: Treating four worker copies as four finished models instead of sending gradients for one global update.

Self-check: If four workers send gradients -1.5, -4, -7.5, and -12, what is the global gradient?

Connects to: 8.4 Synchronous Distributed SGD, 8.6 Decentralized SGD

Stochastic Gradient Descent on a Single Weight

Must-know: Negative gradient: increase the weight. Positive gradient: decrease the weight. The minus in w - eta nabla L does this automatically.

⚠️ Top pitfall: Dropping the minus after seeing a negative slope, or editing the input x instead of the weight.

Self-check: With w=2, eta=0.1, and gradient -12, what is the new weight and the new prediction at x=3?

Connects to: 8.3 Mini-Batch Gradient Descent, 8.4 Synchronous Distributed SGD

Mini-Batch Gradient Descent

Must-know: Sample-wise, mini-batch, and full batch use the same slope; they differ in how often the weight moves and whether gradients are averaged.

⚠️ Top pitfall: Updating w inside the batch and still calling the result a mini-batch mean, or dividing by B twice.

Self-check: With frozen w=1.5 and four gradients -0.5, -2, -4.5, -8, what is the mini-batch update at eta=0.1?

Connects to: 8.2 Stochastic Gradient Descent on a Single Weight, 8.4 Synchronous Distributed SGD, 8.7 Batch Loops, Overlap SGD, and Quantized SGD

Synchronous Distributed SGD

Must-know: Workers send gradients; the master performs one global update. Closed-form (wx-y)x is the same slope as a finite difference.

⚠️ Top pitfall: Differentiating with respect to x, or drawing four final models instead of one master update.

Self-check: Fill the four-worker table at w=1.5 and compute w - 0.1 * mean(g).

Connects to: 8.2 Stochastic Gradient Descent on a Single Weight, 8.5 Asynchronous SGD and Stale Gradients, 8.6 Decentralized SGD

Asynchronous SGD and Stale Gradients

Must-know: A stale gradient is computed on old weights and applied to newer weights. The server does not force remaining workers to restart after every update.

⚠️ Top pitfall: Assuming the server broadcasts and forces a restart after worker 1 finishes, or treating every stale gradient as fatal.

Self-check: Trace w = 2.0, eta = 0.1, gradients -2, -6, -10 arriving in order. What is the server weight after three applies?

Connects to: 8.4 Synchronous Distributed SGD, 8.6 Decentralized SGD

Decentralized SGD

Must-know: Neighbor-exchange averaging is decentralized SGD, not asynchronous SGD. Asynchronous SGD still has a server.

⚠️ Top pitfall: Labeling neighbor averaging as asynchronous SGD, or mixing once and calling the models global.

Self-check: On a path of three weights 2, 4, 6, what happens after one mix of the first pair and then the second pair?

Connects to: 8.1 The Distributed Training Problem, 8.5 Asynchronous SGD and Stale Gradients, 8.7 Batch Loops, Overlap SGD, and Quantized SGD

Batch Loops, Overlap SGD, and Quantized SGD

Must-know: Synchronous waits for all workers; asynchronous updates per finish; decentralized averages neighbors. Quantized means lower bit size.

⚠️ Top pitfall: Treating quantized SGD as a new loss, or mixing overlap SGD with async SGD.

Self-check: In one sentence each, define synchronous, asynchronous, and decentralized SGD, and say what quantized means.

Connects to: 8.3 Mini-Batch Gradient Descent, 8.4 Synchronous Distributed SGD, 8.5 Asynchronous SGD and Stale Gradients, 8.6 Decentralized SGD

Exam Guidance Summary

Must-know: Close synchronous, asynchronous, and decentralized SGD before federated learning. Show the worker table then one global update.

⚠️ Top pitfall: Confusing the three designs, or sending gradients but drawing four final models.

Self-check: List the six study signals for this session.

Connects to: 8.2 Stochastic Gradient Descent on a Single Weight, 8.4 Synchronous Distributed SGD, 8.5 Asynchronous SGD and Stale Gradients

Key Industry Applications

Must-know: Amazon-scale zones, multi-GPU averaging, 120-billion-parameter mini-batches, edge neighbor exchange, FedAvg, and quantized messages are the named industry settings.

⚠️ Top pitfall: Treating federated learning as already fully covered rather than the next block.

Self-check: Name three industry settings from this lecture and which SGD variant each uses.

Connects to: 8.1 The Distributed Training Problem, 8.3 Mini-Batch Gradient Descent, 8.6 Decentralized SGD, 8.7 Batch Loops, Overlap SGD, and Quantized SGD

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.