Skip to main content
Distributed Machine Learning

SCAFFOLD and FedProx: Controlling Client Drift

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

  • Hospitals, Non-IID Data and When Vertical Partitioning Appears — covered in Lecture 1
  • Non-IID Data: Same Features Versus Mixed Features — covered in Lecture 3

A family of aggregation methods takes weights or gradients from many clients and builds one global model — the shared parameter vector that the server keeps. How those updates are mixed decides how well the combined model works.

SCAFFOLD, FedProx, and a related method named FedDSS each target a different failure mode of that mix. This note goes deep on SCAFFOLD and FedProx. Both try to stop a client from wandering too far from the pack.

The path is concrete. First we see why a plain average of local models can fail when each device sees a skewed slice of the world. Then we rebuild gradients as arrows, add SCAFFOLD’s control-variate correction, walk a full two-client round with real numbers, and only after that switch to FedProx’s rubber-band penalty. Keep the same symbols as you go: for the server model, for a client copy, and for the two control arrows, and for FedProx’s leash.

11.1 Combining Client Models When Data Is Not Shared

The server does not train on raw samples. It receives weights from client 4, client 3, client 2, and client 1, or it receives gradients. Then it must form one global model — the shared parameter vector that the server keeps. The quality of that mix is the quality of the system.

If each hospital, phone, or camera only ever sees its own slice of the world, can you still average their models and trust the result? The mix can look tidy and still point the shared model in the wrong direction.

11.1.1 Why Simple Mixing Is Not Enough

Picture four clients standing around a shared model. Client C1 may hold only cat images. Client C2 may hold only dog images. Client C3 may hold elephant images. Each local trainer becomes an expert on its own animals. That local skill is useful. It is also dangerous.

Four phones join a photo classifier round. C1 has 200 cat shots and almost no other animals. C2 has 180 dog shots. C3 has 150 elephant shots. C4 has a mixed album. After many local steps, C1’s weights are a cat specialist. C2’s weights are a dog specialist. If the server only averages finished weights, the shared model can tilt toward whichever specialist shouted loudest. The goal is not to freeze every client in place. The goal is that no client should deviate — wander far in parameter space — from the other clients and from the global model. C2, C3, and C4 should sit near one another. C1 should sit near them too.

Think of four hikers on a foggy hill, each holding a private map. A gradient (the steepest-uphill arrow a hiker feels underfoot) tells each hiker which way loss rises fastest on their own map. If C1’s map is “cats only,” that arrow is a cat arrow. Averaging the hikers’ final positions is not the same as walking a path that is fair to dogs and elephants. The analogy breaks when the “hill” is a high-dimensional weight space: you cannot see the arrows with your eyes, but the same pull-away story still holds.

Researchers split this pain into pieces and named an algorithm for each piece. SCAFFOLD handles client drift. FedProx handles another control idea built on distance. FedDSS handles yet another feature. All of them are recipes for combining local models into a global model.

11.1.2 Non-IID Data and Client Drift

Federated learning trains one model while data stays on devices. The server never sees the raw photos or hospital records. Clients are heterogeneous: they are not copies of one another. Each client trains on a different slice of the world.

The data are non-IID — not independent and identically distributed. Independent would mean one sample does not secretly dictate the next. Identically distributed would mean every client draws from the same pattern and the same label mix. You cannot expect that on every phone or hospital. One ward sees one disease mix. Another ward sees another mix.

That mismatch is what produces client drift. Drift here is not a vague vibe. It is a geometric fact: after many local steps, two clients’ weight vectors no longer point the same way. A cat-only client keeps pushing weights in a cat direction. A dog-only client keeps pushing in a dog direction. The longer each client trains alone, the farther those two arrows separate.

SCAFFOLD’s job, in one sentence, is to reduce that drift while still averaging.

Scope: Ordinary averaging works well when local datasets are close to IID, devices have similar compute, and nobody is trying to poison the mix. Those three “ideal federated” conditions are the usual baseline in textbooks. When any one of them fails, a sample-count weighted mix can still run, but the shared model can diverge from what a pooled dataset would have learned. This section is about the non-IID failure, not about attackers.

Imagine a scatter plot whose x-axis is “how cat-like the weights are” and whose y-axis is “how dog-like the weights are.” After one local epoch, the four clients are a tight cloud around the global point. After many local epochs, C1 has marched far along the cat axis and C2 far along the dog axis. The takeaway: extra local work without a leash turns specialists into outliers.

11.1.3 Ordinary Federated Averaging

Federated averaging (FedAvg) is the simple baseline. It does not try to diagnose drift. It takes whatever weights arrived and averages them, scaled by how many samples each client trained on.

Let client hold training samples and local weights . Let the total sample count be when three clients report. The verbal description is: take the number of samples a client trained on, divide by the total number of samples, and multiply by that client’s weights. For client 2 that factor is . For client 3 it is .

The mixed model for the three-client picture is

with . Here is the weight vector (or a toy scalar) on client , and is the new global model. Bounds here follow the three-client picture used in the explanation. Later work keeps the same weighted-average idea for any number of clients :

Each coefficient is a fraction in and the coefficients sum to , so this is a convex combination of the local models.

Suppose three clinics report scalar toy weights , , with sample counts , , . Then , so

Sense-check: clinic 1 has half the data, so the mix sits closer to than to . An unweighted mean would have been . Sample-count weighting is doing real work.

FedAvg is easy. It also ignores the hard part: a client that saw a weird slice of data can yank the average off course. That is why a plain average can be unsafe when labels are skewed.

A second numeric picture makes the yank visible. Keep the same but let the cat clinic’s scalar weight run to while the others stay at and . Then . The shared model followed the cat specialist even though two clinics never saw cats.

A common trap is to treat FedAvg as “just the mean of models.” If you forget the weights, a tiny clinic with 10 samples votes as hard as a hospital with 10,000. Another trap is to think a longer local run is always better. Extra local steps can grow drift. A third trap is to mix gradients and weights as if they were the same object: FedAvg as written here averages parameters , not raw mini-batch gradients.

11.1.4 Student Questions and Answers

The opening question is the whole course in one line: the server has to combine what it got, and the mix quality is the model quality.

Q: At a high level, what are SCAFFOLD, FedProx, and FedDSS doing when the server gets weights from many clients?

A: The server must combine those weights or gradients into one global model. The mix quality is the model quality. Clients may each be experts on different data, such as cats versus dogs versus elephants. The shared aim is that a client should not deviate too far from the others or from the global model. Each method attacks a different piece of that mixing problem. SCAFFOLD targets drift. FedProx targets a different control idea. FedDSS targets another feature.

11.1.5 Industry Applications and Exam Notes

On-device training for photos is the running picture. One phone may mostly shoot pets of one kind. Another phone may mostly shoot a different kind. A hospital site may see one disease mix. Another site may see another mix. Keyboard-next-word models on phones hit the same skew: one user types sports slang, another types medical terms. Weighted averaging alone does not fix that skew. Production federated stacks still start from FedAvg because it is simple, then swap in a drift-aware mix when the label mix is badly split.

This sits in the broader field as the aggregation layer of federated learning: after local training, before the next broadcast. Everything later in this lecture is a replacement rule for that one mix step.

Exam note: Be ready to write the FedAvg mix and to say in plain words why non-IID client data makes a plain average unsafe. Name the cat / dog / elephant picture as the reason the specialists can pull the global model off course.

FedAvg is the baseline we now improve. SCAFFOLD will interfere during local training instead of waiting until the weights are finished.

11.2 SCAFFOLD: Stochastic Controlled Averaging

SCAFFOLD stands for stochastic controlled averaging. It is still an averaging method: the server receives information from many clients and averages. The new idea is a control on the average so that local drift is not left free.

“Stochastic” here points at the noisy mini-batch gradients. Each pack of samples gives a slightly different arrow. “Controlled” points at the extra state that remembers the usual arrow and edits the noisy one.

FedAvg waits until local training is done, then blends finished weights. Why not grab the steering wheel during those local steps, while the client is still walking?

11.2.1 What “Controlled” Adds on Top of Averaging

Ordinary FedAvg treats every uploaded weight as a fair vote, scaled only by sample count. SCAFFOLD keeps a memory of how each client usually moves, and a memory of how the whole population usually moves.

Those memories are control variates. A control variate (an extra vector that tracks a typical gradient direction) lives in the same shape as the model weights. There is one vector on client and one vector on the server. They describe typical gradient direction. The client uses them to correct the current mini-batch gradient before it walks too far.

A useful picture: FedAvg waits until training is done, then blends finished weights. SCAFFOLD interferes during local training. Each local step is not “whatever my batch wants.” It is “what my batch wants, after I remove my usual private tilt and face the group tilt.” That is why the method can reduce drift even when every client still trains only on its own data.

There is no peer-to-peer link among clients. A client cannot see the other clients’ typical directions. So the server must ship the global control vector down with the model. The client ships back changes, not the full new vectors. Sending a difference is lighter than sending a full new model plus a full new control if you already know the old values on the server, and it matches the later server step, which averages those differences. That communication pattern is part of the method, not an implementation footnote.

Later we will see a second method, FedProx, that tries to solve the same drift pain without those extra vectors. Keep that contrast in mind: SCAFFOLD buys directional control by storing and shipping extra state.

Assumption: SCAFFOLD’s correction is honest about what the client can see. The client already stores . It does not see other clients. The global must arrive from the server. If the server sent only the model , the client could not form the group direction on its own.

Picture two arrows taped to a compass. One arrow is “how I usually walk.” The other is “how the group usually walks.” SCAFFOLD rewrites the current step by swapping the first arrow for the second. The analogy breaks because the arrows are as long as the whole model — millions of coordinates — not a pocket compass.

11.2.2 Symbols Used Throughout SCAFFOLD

In the one-number toy used later, global weights start at . That single number is a stand-in for a full weight vector. Every add and divide in later sections is the same operation you would run coordinate-wise on a real network.

Let be the global model weights on the server. In the one-number toy, starts at . Let be client ’s local copy of the weights after local training. Let be client ’s control variate: a running picture of that client’s usual gradient direction. Let be the global control variate: the average direction preferred by the clients as a group. Let be the current mini-batch gradient on client . Let be the local learning rate — the step size. Let be the number of local steps in a round. Let be the set of clients that take part in this round. Let be the total number of clients in the system, including those that sat out.

The verbal description of the control idea is: is client ’s usual local gradient. Gradients are directions in which loss rises fast. If you watch many mini-batches, that direction settles toward a typical value for that client.

The local corrected step, written once so the symbols sit together, is

Each of , , , , and has the same shape. If the model has three weights, each of these is a length-3 vector.

The standard algorithm uses the same symbols. Texts sometimes write a server step size in front of the averaged model change. In the numeric round later, that server step size is .

11.2.3 Student Questions and Answers

The correction uses three arrows: the current batch, the client habit, and the group habit. Only the server can form the third.

Q: Why must the server send the global control down to the client, not only the model ?

A: The correction uses the current batch gradient, minus the client’s own usual direction, plus the global usual direction. The client already stores . It cannot see the other clients, so it cannot form by itself. There is no peer-to-peer channel. The server must send both the model and the global .

11.2.4 Exam Notes

Do not treat as “the current mini-batch gradient.” is the current pack. is the memory of many packs. Do not treat and as the same count: is everyone in the fleet, is who joined this round. Do not skip the downlink of ; a client with only cannot run the correction.

Exam note: SCAFFOLD is stochastic controlled averaging. Name the two extra vectors: local control and global control . State that the server sends and , and that the client returns differences and .

The next section makes those arrows visible with three weights and a loss of .

11.3 Gradients as Directions: A Three-Weight Toy Model

Before the full SCAFFOLD update, we rebuild what a gradient is, using a tiny network so the vectors stay visible.

If a model has only three numbers inside it, can you still see the gradient as three stories, one per weight, instead of as a mysterious blob?

11.3.1 Loss Sensitivity for Three Weights

Assume the whole model has three parameters . In the toy, those weights sit at , , and . After a forward pass the loss — the mismatch number we want small — is . The gradient asks: if I nudge one weight a little, how does that loss move?

Write for the change in loss when moves. The verbal description is: “if I slightly change each weight, how does my loss change?”

For this toy the three partials are

so the gradient vector is

If rises by a tiny , loss rises by about times that nudge. If rises a little, loss falls (the partial is negative). If rises a little, loss rises only a bit. The first coordinate is the sharp increase. The second is the decrease. The third is a mild increase.

A gradient is the steepest-uphill arrow a hiker feels underfoot. Here the hill lives in three dimensions, one axis per weight. Walking along is like stepping up a slope of . Walking along is walking downhill. The analogy breaks when coordinates mix: a real step moves all three weights at once, so the loss change is the dot product .

Start at with loss . Nudge only the first weight by . The first-order change in loss is , so loss would move to about . Nudge only the second weight by . The change is , so loss would move to about . Negative coordinates are not a bug. They are “this weight should grow if we want loss to fall.”

11.3.2 Mini-Batch Gradients on Client 1

Client 1 does not see one gradient forever. Each mini-batch — a small pack of samples — gives a new gradient. Four packs on client 1 produced four different arrows.

The four mini-batch gradients on client 1 are

The vector changes every iteration. There is still a pattern. The first coordinate hangs around (values ). One step below is . One step above is . The second coordinate hangs around or . The third hangs around , sometimes one step up or down.

The spoken average for client 1 is . Check the four-pack mean:

which is “in and around” . That average direction is client 1’s usual gradient. Gradients are directions where loss rises fast. After many batches, the client’s gradient settles toward this typical arrow.

Plot iteration on the x-axis and the first coordinate of on the y-axis. The four points sit at . They bounce, but they bounce around , not around . The landmark is that horizontal band near . The takeaway: noise is real, and so is a stable habit.

11.3.3 Other Clients and the Server Average Direction

Client 2 holds very different data, such as dog samples. Its mini-batch gradients wander, then settle toward a different typical arrow . Client 3 settles toward . Those usual directions go to the server. The server averages them into a global direction .

The walkthrough mixed first coordinates , , and , then divided by , giving . It mixed second coordinates , , and , then divided by , giving about . It mixed third coordinates , , and , then divided by , giving .

Those three spoken coordinate-wise averages recover the missing client vectors as well as . Client 1 already occupies the first slot of each triple, so

Putting the spoken averages together,

with . This is the average direction preferred by all the clients. It is not client 1’s private habit. It is the group trend.

Shape check: each , so . Limiting check: if every client had the same usual arrow, would equal that arrow. Here the first coordinates , , and disagree hard, so the group first-coordinate is a compromise, not a copy of client 1.

Client 1’s habit and the group habit are not the same arrow. That gap is client drift in gradient space. SCAFFOLD will use both arrows in the next section.

11.3.4 Student Questions and Answers

Four different packs can still share one habit. The habit is the average, not one lucky batch.

Q: The four mini-batch gradients on client 1 are all different. Why call “the” gradient of that client?

A: Each pack is noisy. The first coordinate still stays near , not near or . The usual gradient is the average direction after many packs. That average is the client’s habit, not one lucky batch.

11.3.5 Exam Notes

Do not read a three-number gradient as one mood. Coordinate means “raising this weight raises loss.” Coordinate means “raising this weight lowers loss.” Do not treat one mini-batch as the client. Do not treat and as the same vector: is private, is the group.

Exam note: A gradient coordinate of means a small rise in that weight raises loss by about times the nudge. Negative means loss falls. Be ready to read a three-number gradient as three stories, one per weight, and to average several mini-batch arrows into a usual direction .

We now have a current arrow, a habit arrow, and a group arrow. The next section subtracts one and adds the other.

11.4 Control Variates and the SCAFFOLD Correction

Now the current batch can disagree with the client’s habit. SCAFFOLD edits that current gradient before the local step.

If this mini-batch is louder than the client’s long-run habit, should the local walk follow the loud batch, or should it be steered back toward the group?

11.4.1 Current Gradient Versus Usual Gradient

After four packs, take a fifth mini-batch on client 1. The current gradient is . The client’s usual gradient is still . The fifth pack is louder than the habit: instead of about , and instead of about . Mini-batches differ, so a single pack can yank the walk.

The verbal link is: is the current gradient for this batch. is the average of the mini-batch gradients. is the in-built bias, the habitual direction.

Think of as memory. Many batches produced many arrows. Their average is the memory of typical direction. In the three-weight toy that memory is an arrow in three-dimensional space. Each coordinate of is “how this client usually wants , , or to move.” Each coordinate of is the same question for the group.

Compare the fifth pack to the habit, coordinate by coordinate:

  • First: versus (this batch pulls harder than usual).
  • Second: versus (this batch is a milder decrease).
  • Third: versus (this batch pulls much harder).

If client 1 took a raw step along , it would follow a spike, not its own average, and not the group.

11.4.2 Remove Local Drift, Add the Global Average

The correction is: subtract the local habit and add the global habit.

In symbols,

The verbal description is: “ minus, remove the bias, and add the global context.” For the fifth pack, start from , subtract (the average in-built deviation), then add (the overall average drift). The client’s private tilt comes off. The group’s tilt goes on. The update is steered closer to what helps all clients, not only client 1’s data.

Picture the walk as turning an arrow. Client 1 wants to turn one way because this batch, and because its long-run cat habit, both pull that way. The other clients sit in a cluster. The correction rotates client 1’s step toward that cluster. It does not freeze client 1. It changes the heading.

The three-dimensional arithmetic was not finished out loud in the walkthrough. Completing the vector with the from the previous section:

Sense-check: the first coordinate fell from a spiked toward the group’s , and landed at . The step is still a descent direction, but it is no longer client 1’s private spike. The one-number toy in the next section finishes the same formula with , which is the numeric form of the same subtract-then-add rule.

The same formula is the one used in the one-number toy in the next section. The three-weight picture is for seeing direction. The one-number picture is for seeing every add and divide.

Standard treatments write the local SGD step as . That is the same correction: the term is an estimate of how far this client’s usual direction sits from the group’s usual direction.

11.4.3 Why Subtract , Not Only Add

A common wrong move is to add the global direction and leave the local habit in place. Then the local drift is still inside the step. is average behavior. The current gradient sits on top of that behavior. Subtract the average behavior. What remains is the extra wiggle of this batch. Then add the global behavior so the step faces the group, not the private bias.

If one client has noisy data, or data that is not common across clients, that client can fly off in a private direction. Subtracting is the brake on that private flight.

Write the two alternatives side by side. Wrong: , which still contains the full local habit. Right: , which replaces the local habit with the group habit and keeps only this batch’s extra wiggle. If exactly (this batch matches the habit), the right rule collapses to : the client steps along the group arrow, not along its private arrow.

Scope: The correction assumes is a decent sketch of the client’s mean gradient and is a decent sketch of the population mean. Early in training those memories are rough. They still get sent and used. They improve as rounds repeat. The formula also assumes , , and share the same shape. It does not by itself stop a client from taking many local steps; it rewrites each step’s heading.

Draw three arrows from the same origin in the plane: long and cat-tilted, along the same tilt but shorter, pointing toward the group. The corrected arrow is minus plus . The landmark is the rotation toward the group, not a freeze at the origin. The takeaway: SCAFFOLD edits direction, not merely step length.

Traps: (1) Adding without subtracting leaves local drift in the step. (2) Treating as this batch’s gradient, so you subtract the current from itself and get with no batch information. (3) Mixing coordinates: you must subtract and add vector-wise, not a single scalar. (4) Thinking the client can invent from local data. It cannot.

11.4.4 Student Questions and Answers

Two questions hit the same formula from two sides: what the symbols mean, and why the minus sign is required.

Q: How are and related, and what do we do with them?

A: is the current mini-batch gradient. is the average of the mini-batch gradients, the client’s usual direction. Remove the local drift and add the global average: minus plus . That is the SCAFFOLD correction.

The minus sign is the part students retry. If you only add the group arrow, the private habit is still sitting in the gradient.

Q: Why do we need , not a plus on ? Why subtract the local control rather than only adding global ?

A: If we do not remove the local bias and we keep adding, the local drift is not removed. We would add the global trend while the local habit is still sitting in the gradient. is average behavior. Subtract that average from the current gradient. The current value was sitting on top of the habit. After the subtraction we have a cleaner gradient, then we add the global direction. If local bias is not removed, the local drift stays inside the step.

11.4.5 Exam Notes

Exam note: Write and say in words: remove local bias, add global context. A short “why subtract?” item is likely, because that is the confusion that needed a second pass. Be ready to finish the fifth-batch vector .

The three-weight picture taught heading. The next toy collapses the model to one number so every add and divide is visible.

11.5 A Full SCAFFOLD Round With Two Clients

The three-weight picture taught direction. The next toy collapses the model to one number so every add and divide is visible. The same logic extends component-wise to real vectors.

This section is a procedure, not a new definition. We send, train, recompute controls, and upload differences.

If the whole network is replaced by a single number , can you still watch SCAFFOLD’s minus-then-plus rule, the two local hops, and the two uploaded pairs without losing a digit?

11.5.1 What the Server Sends

Purpose. Run one communication round so two clients start from the same global model, correct their local steps, and return changes the server can average.

Inputs. Global weights . Global control . Client 1’s stored control . Client 2’s stored control . Local learning rate . Local steps .

Outputs. From each client , a pair with and .

Start of round: global weights . Global control . The verbal description of is the biases of various clients averaged together; early on that number may not mean much yet, but the server still sends it. Both client 1 and client 2 receive and . Client 1 already holds old local control . Client 2 holds .

Client 1 copies the model into a local weight , starting at .

11.5.2 Client 1: Corrected Steps and New Control

On a new batch, the raw gradient is . That already contains the in-built bias . Subtract the local habit and add the global trend:

The verbal description is: “I am not allowing, instead of , now I make it .” The client is not allowed to deviate as hard as the raw batch wants.

Steps on a client. (1) Copy . (2) For each local step, form and walk . (3) Recompute from how far the weights moved. (4) Upload differences, not raw new values.

Local training then runs two epochs. Weights move and then . Each drop is . If the corrected gradient stays , a learning rate gives a step , which matches those two hops:

The local model after training is .

Next, recompute the client control. The high-level mix is: old minus current global , plus a corrected-gradient term recovered from how far the weights moved. The two matching expressions used in the walkthrough are

and

The is the product of local-step count and learning rate, not a count of clients. With two local steps and ,

The general form is

Plug in client 1:

The walkthrough mixed extra words around that divisor. The arithmetic that was actually computed is , and (the fleet size) does not belong in this client-side divisor. Standard Option II of SCAFFOLD is this same formula. (Option I would recompute a full local gradient at ; the numeric round uses Option II.)

Because both local hops used the same corrected gradient ,

and then , which equals the raw gradient . In this constant-gradient toy, the new control stores the uncorrected local direction.

The client does not upload and as raw values. It uploads differences. The model change is (spoken once as “became 8,” but the difference used is , which matches ). The control change is . Client 1 sends

Sense-check: the model fell by over two steps of . The control rose by , which equals .

11.5.3 Client 2: The Same Recipe With Different Habit

Client 2 starts from the same and the same global , but its local control is . Raw gradient . Corrected gradient:

Weights move then to . Each hop of matches when :

Final local weight . New control:

Model difference: . Control difference: . Client 2 sends

In words one pass said: “You sent me a model. I changed the model by . I changed the value by .” Wait: , not . The spoken “changed the value by ” does not match . Keep both lines in view, and prefer the send pair , which is the pair that continues into the server average.

Every participating client sends and .

Time cost: each client does local gradient steps plus two vector subtractions for the deltas. Communication cost: two model-shaped payloads instead of one (the extra ). On a tiny device that extra vector is not free. The one-number toy hides that cost; a million-weight model does not.

When to use this round. Use the corrected local walk when clients are heterogeneous and you can afford extra control state. If you cannot store or ship a second model-sized vector, the next section’s FedProx leash is the alternative. Do not mix the two recipes in one round.

11.5.4 Student Questions and Answers

The server asked for the change, not the new snapshot. That is why the upload is a pair of differences.

Q: After local training, why send differences such as and , not the new weight and the new control ?

A: The server asked for the change. Client 1 received and ended at , so the model moved by . The control moved from to , so the control moved by . The server will average those changes across the clients that took part.

Exam note: Reproduce the one-dimensional round: , , , , corrected , local path , , send ; client 2 path to , send . Write .

The clients have sent their pairs. The server now has to mix them, including the case where only some of the fleet showed up.

11.6 Server Aggregation and Partial Participation

Once every chosen client has sent , the server updates and .

The clients did the walking. What exact average should the server apply, and what happens when only some of the fleet joined the round?

11.6.1 Averaging the Model Changes

Two clients took part, so the subset size is . The two model deltas are and . Their mean is

A first pass said “minus 2 by 2, which is nothing but 1.” That dropped the sign. The corrected pass is: on average the selected clients recommend decreasing the global model by . Then

The new global model is . A server learning rate can scale if we want a gentler or sharper apply:

In this numeric walkthrough the scale is , so moves from to . Standard SCAFFOLD uses this same mean of .

Sign-check: both clients lowered their local copy ( and are both below ), so the global model should fall, not rise. The value sits between and , which is where an unweighted mean of the two finished local models would sit.

11.6.2 Averaging the Control Changes, Then Scaling by Who Showed Up

The two control deltas are and . Their mean is . A naive apply would be . The method does not always add the raw mean. Only some clients participate. Here took part and clients exist in the system. Scale the control step by the participation ratio :

With the toy numbers,

The verbal line that sounded like “0.53, which is nothing but 3.5” is the same path with a slurred “0.5 times 3.” Arithmetic that matches is .

So the next broadcast is a new model and a new global direction. If the naive unscaled add had been used, that direction would have been . With partial participation it is .

Why divide by rather than by ? Global is meant to track the fleet average of the values, including clients who sat out and did not change. Adding the subset mean as if it were the whole fleet would pretend two updates were four updates. Multiplying by keeps the missing clients’ old controls in the average.

If all four clients had joined, and the scale would disappear: . Partial participation is the only reason the toy lands on .

11.6.3 Intuition of the Whole Loop

The server stores global weights and a global average drift. Each client starts from the global model, trains on local data, forms a local bias picture , and corrects the local step by subtracting that bias and adding the global control. The client sends the difference in weights and the difference in . The server averages the weight changes into a new global model and averages the changes into a new global control, scaled by how many clients joined. Repeat. Clients are pulled toward the global weights instead of toward their private skewed data. The loop converges toward those global weights rather than toward each client’s biased slice.

Draw a timeline. Round : server ships . Each chosen client walks, then ships . Server writes and . Round repeats. The landmark on the number line is and . The takeaway: two different averages, two different scalings.

Scope: The factor assumes is a fleet-wide average and that idle clients keep their old . It is not a learning-rate knob like . If , the factor is . If , there is no round. The model update does not use in the toy; only the control update does.

On a number line, mark and the two finished local points and . The mean delta lands at , between those two points. Mark and the naive add at ; the scaled update lands at , closer to the old because half the fleet stayed home. The landmark is that split: model mean versus participation-scaled control mean.

Traps: (1) Dropping the minus sign so becomes and rises to . (2) Adding the mean with no factor, landing on instead of . (3) Scaling the model update by when the walkthrough scaled only . (4) Averaging finished weights and while forgetting that the uploaded objects were deltas.

11.6.4 Student Questions and Answers

“Just averaging” is too vague. Name which vectors are averaged and which factor multiplies the control step.

Q: Once every client has sent its pair, what is the server step? Is it just averaging?

A: It is not “averaging” as a vague slogan. The server averages the received values. With and that mean is , so the global moves from to . It also updates . is the participating set. is the total number of clients. The control update uses a factor , not a blind add of the mean . Average delta to move , and update with factor over .

The short story of the whole loop is the exam-ready intuition.

Q: What is the intuition of SCAFFOLD, as a short story of server and clients?

A: The server manages global weights and a global average drift. Each client starts from the global model and trains on local data. It forms its local bias . It corrects the local walk by subtracting that bias and adding the global control. It sends the difference of its weights and of its back. The server averages the weight changes into a new global model and averages the received changes to update global . The loop keeps running so training converges toward the global weights rather than toward each client’s biased data.

11.6.5 Exam Notes

Exam note: Be able to compute from a short list of , then . Be able to apply when only a subset joins. Mention that a server learning rate may scale the step. Keep the sign: mean means decrease, not increase.

SCAFFOLD needed extra arrows. FedProx will try the same drift pain with a rubber band and no extra vectors.

11.7 FedProx: A Rubber-Band Penalty on Distance

After SCAFFOLD, the second method is FedProx. It also fights drift, but it does not keep control vectors. It penalizes distance from the global model.

If extra control arrows are too expensive to store and ship, can you still stop a client from sprinting away — using only the weights you already have?

11.7.1 Rubber-Band Picture

If some weights run one way and some run another way, a plain average can hurt the global model. We want local walks to stay near the global trend. Think of a rubber band tied between the global model and the local model. The farther the local model walks away, the harder the band pulls back. The local model is not free to sprint. It stays closer to the global point.

The strength of that band is a constant (spoken “mu”). is the proximal weight: how hard we leash the local model to the global model. You choose it. It is a scalar, not a vector.

A speed limiter on a car is a cousin of this idea: the engine can still request a fast acceleration, but the limiter caps how far you go. The analogy breaks because FedProx does not cap speed with a hard wall. It adds a smooth pull that grows with distance.

11.7.2 Penalty Gradient From a Quadratic Term

The local goal is not only “fit my data.” It is “fit my data, but pay for walking away from the global weights.” Let be the local weights and the global weights. The extra term is a quadratic in the gap.

Write the penalty as

in the one-number toy, or for vectors. Differentiate with respect to . The verbal derivative is: times times ; the and the cancel, leaving

That is the penalty gradient. FedProx adds it to the data gradient . The local step becomes

Because is often negative when has already dropped below , the penalty gradient is negative and shrinks the step that would have run farther away.

If , the extra term is zero and the method collapses to federated averaging.

Shape check: and have the same shape, so matches . Domain check: is never negative, and is the usual choice. Limiting check: recovers .

11.7.3 Numeric Walkthrough With and

Global weight . Local weight starts at . Gap is , so penalty is .

First local update uses data gradient and learning rate :

The local model has begun to move away. The gap is . That is “orange, not danger”: close, but no longer glued.

Without a penalty, a second gradient of would do . FedProx says that jump from to is too far.

Now form the penalty at with working value (a first attempt used , then corrected to ):

Modified gradient:

Use instead of . From ,

Without FedProx the second stop was , distance from the global . With FedProx the stop is , distance . The band did not reverse the walk. It shortened it.

A side path applied from the original , which would give . That path uses the wrong starting point. The versus pair is the one used to compare distance, and it uses the second-step starting point .

Without FedProx the update is . With FedProx it is . Because is negative in this walk, that is the same as shrinking the gradient, spoken as “minus penalty.”

Sense-check: , so the leashed client stayed nearer . The band pulled back by of distance, not by reversing the sign of the step.

Plot local weight on the y-axis and local step index on the x-axis. Unleashed path: . Leashed path: . The landmark is the second hop. The takeaway: same first hop (gap was zero), shorter second hop (band is taut).

11.7.4 Local Objective and the Role of

Let device have local fit . FedAvg would minimize that fit alone. FedProx adds a penalty that grows with distance from the global model :

Here is the global model and is the client model. As distance grows, penalty grows, and the effective gradient shrinks, so the client does not run as far. Standard write-ups of FedProx use this same proximal term. Because the extra term is a function of , local training needs a gradient-based method to add to the data gradient.

If goes from to , the band gets stiff. A large gap is multiplied by a large , so the subtractive penalty is huge, and the local model stays closer to . A first guess was “updates become slower.” The correction is: not slower as the main story. The model becomes closer to the global . At it is ordinary FedAvg.

Procedure each round: server sends the global model; client computes a data gradient; FedProx adds the penalty; the smaller effective step keeps weights nearer the global model; then the server averages.

Scope: FedProx applies when local training is gradient-based and you can evaluate each step. It does not store control variates. A huge can freeze the client near and starve local learning. A tiny is almost FedAvg. The method also does not, by itself, fix adversarial clients; it only leashes distance.

11.7.5 Student Questions and Answers

is the one knob. Large pulls harder.

Q: Any doubt on FedProx? What does do?

A: decides the strength of the rubber band. You choose it. Large pulls harder toward the global model.

The follow-up is the trap: people hear “bigger penalty” and say “slower updates.” The intended reading is “closer to .”

Q: If rises from to , what is the impact?

A: Highest penalty. If the gap is large, you subtract a bigger number, so the effective gradient shrinks. A first reading was that updates become slower. The intended reading is that the local model becomes closer to the global model , not merely slower. If , the method is normal federated averaging.

Traps: (1) Applying the modified gradient from instead of from . (2) Leaving after the correction to . (3) Hearing large as only “slower” instead of “closer to .” (4) Forgetting that is FedAvg.

11.7.6 Industry Applications and Exam Notes

Latest aggregation papers keep finding a new failure mode and shipping a new mix rule. Thesis work can survey those mix rules and try a new one. FedProx is the distance-leash member of that family. Cross-silo hospitals that cannot store a second model-sized control vector still get a leash: one scalar on each site. Keyboard models on phones can use the same trick when uplink bytes are scarce.

This sits next to SCAFFOLD as the other standard answer to client drift: change the local objective, not the local direction memory.

Exam note: Derive the penalty gradient from . Run the versus numbers. State the FedAvg limit and the large- “stay close to ” limit. The large- story is “closer,” not merely “slower.”

Both methods fight drift. They do not fight it the same way. The next section names the disagreements one by one.

11.8 SCAFFOLD Versus FedProx

Both methods are averaging methods that fight client drift. They agree that a wild local walk can poison the global model. They disagree about what they constrain and what extra state they store. A fair comparison has to name those disagreements one by one, because an exam answer that says only “both reduce drift” is too thin.

If two tools both claim to stop drift, how do you tell them apart on an exam without a single vague sentence?

11.8.1 Control Strength

In SCAFFOLD the correction is always of the form minus plus . There is no knob that says “correct only halfway.” The size of the correction is whatever and currently are.

SCAFFOLD always uses

with no -style multiplier in front of the correction. FedProx instead uses

and is that knob. You choose how strong the rubber band is. That is the first practical difference: FedProx lets you tune the leash. SCAFFOLD’s leash is the control vectors themselves.

11.8.2 Extra Vectors Versus On-the-Fly Distance

SCAFFOLD stores two extra control vectors: local on the client and global on the server. That is extra memory. Those vectors also travel, so there is extra communication. FedProx does not keep those controls. It uses the model weights it already has. Distance is computed on the fly and used to shrink the gradient. The only extra scalar is .

If a device is tiny, extra vectors the size of the model are not free. If the uplink is tiny, sending beside is not free. FedProx’s extra cost is mostly the extra math of the penalty, not extra payloads.

Side-by-side on the dimensions that actually differ:

Dimension SCAFFOLD FedProx
What is constrained Gradient direction Distance from global weights
Strength knob None; always Scalar
Extra state Local and global None besides
Extra communication with No extra vector
Global needed on the client Yes No
limit Not a method Recovers FedAvg
Local change Rewrite the gradient Add a proximal penalty to the objective

When to pick which: pick SCAFFOLD when you can store and ship control vectors and you care about aligning headings. Pick FedProx when you want one scalar leash and no extra model-sized payloads.

11.8.3 Gradient Direction Versus Distance

FedProx says: do not move too far from the global model. That is distance based (proximal regularization). SCAFFOLD says: gradients should move in the same direction. That is gradient based. SCAFFOLD subtracts the client’s usual direction and adds the global usual direction, so the arrow itself is rewritten. FedProx leaves the data gradient’s story in place and adds a penalty that limits how far weights may travel.

SCAFFOLD’s client also depends on the global . FedProx’s client does not receive a global control vector. Its leash is the received global weights (or ) plus . In that sense FedProx is “completely local” once has arrived: the client never asks “what is the group’s usual gradient?” It only asks “how far am I from the global weights?”

A short pair of slogans helps:

  • FedProx: limit movement.
  • SCAFFOLD: correct direction.

Limiting movement can still leave a biased heading, just a shorter step along that heading. Correcting direction can still take a long step, but the heading is the group heading. Those are not the same fix.

11.8.4 Objective Change Versus Gradient Rewrite

FedProx changes the objective: local loss plus a proximal penalty. SCAFFOLD changes the gradient by bias correction. One is a penalty on position. The other is a correction of direction. Which one wins on a given dataset is not something to claim from the toy numbers alone. That needs larger data runs. Until those runs exist, treat the two as different tools for the same family of drift problems, not as ranked winners.

Scope: The toy numbers show how each method edits a step. They do not rank test accuracy. Heterogeneous photo clients, hospital sites, and keyboard models can prefer different mix rules. A thesis that ships a new aggregator should name the failure mode first, then pick a constraint (direction versus distance), then measure on large data.

11.8.5 Student Questions and Answers

The comparison question is one bundle: similar goal, different constraint, different state.

Q: What is similar, and what is different, between SCAFFOLD and FedProx?

A: Both are averaging methods that try to limit harmful local walks. A major difference: SCAFFOLD has no -style knob on correction strength; it always subtracts and adds global . FedProx uses to set how hard to pull back. SCAFFOLD must store two extra vectors, local and global. FedProx operates on the existing weights plus . FedProx is distance based: do not move too far from the global model. SCAFFOLD is gradient based: make directions agree, with extra controls. SCAFFOLD needs extra memory and extra communication. FedProx computes the gap on the fly. FedProx modifies the objective with a proximal penalty. SCAFFOLD modifies the gradient with bias correction. Do not claim a winner until you run large data.

11.8.6 Exam Notes

Traps: (1) Stopping at “both reduce drift.” (2) Giving FedProx a control vector it does not have. (3) Giving SCAFFOLD a knob it does not have. (4) Ranking the two from the one-number toys.

Exam note: A comparison table is high value: knob versus no knob; extra controls versus none; extra memory and communication versus none; direction correction versus distance penalty; global needed versus not needed. Also: recovers FedAvg.

Exam Guidance Summary

Expect questions that mix a short numeric toy with a “why” sentence.

  • Write FedAvg as a sample-count weighted mix of client weights. Say why non-IID client data (cats versus dogs versus elephants) makes that mix unsafe.
  • Define SCAFFOLD as stochastic controlled averaging. Name as client memory of typical gradient direction and as the group’s typical direction.
  • Write and explain subtract-then-add. A “why not only add ?” probe is likely.
  • Reproduce the one-dimensional round: , , , , corrected , local path , , send ; client 2 path to , send ; , ; control scale with giving rather than a blind .
  • FedProx: rubber-band story, penalty , numbers , versus , distances versus .
  • Limits: is FedAvg; large keeps close to . The large- story is “closer,” not merely “slower.”
  • Comparison: SCAFFOLD corrects direction with extra controls; FedProx limits distance with and no extra vectors. A table on knob, memory, communication, and heading versus distance is high value.
  • Thesis path: survey latest aggregation methods and try a new mix rule for a new failure mode.

Exam note: Numeric toys will be small enough to finish by hand. Show every sign. Name the method’s extra state (controls versus ) in the same answer as the arithmetic.

Key Industry Applications

On-device photo clients that each see one animal class are the teaching stand-in for any phone fleet whose label mix is skewed. A cat-heavy camera roll and a dog-heavy camera roll are the same non-IID pattern as a sports-slang keyboard versus a medical-term keyboard.

Cross-site medical or phone data that is non-IID is the setting where FedAvg’s plain weighted mix is not enough. One hospital’s disease mix is not another hospital’s mix, and the raw records stay on site.

Production federated systems must pick a mix rule. FedAvg is the simple default. SCAFFOLD adds control variates and extra communication to align gradient directions when devices can store and ship a second model-sized vector. FedProx adds a proximal leash when you want a single scalar and no extra vectors — useful on tight uplinks and tiny memory.

Research and thesis work still mint new aggregators (FedDSS was named as another member of that family) because each paper isolates one failure mode and writes a method for it. The industry move is the same as the research move: name the failure, pick a constraint, then measure on real client skew rather than on the one-number toy alone.

DML Lecture 11 notes · SCAFFOLD and FedProx: Controlling Client Drift

Distributed Machine Learning· postgraduate· 2026-09-11

Sections Breakdown

1Combining Client Models When Data Is Not Shared

The server mixes client weights into one global model. Non-IID slices (cats, dogs, elephants) create client drift, so FedAvg's sample-count weighted average can pull the shared model off course.

2SCAFFOLD: Stochastic Controlled Averaging

SCAFFOLD is stochastic controlled averaging: extra control variates remember each client's usual gradient and the group's usual gradient so local steps can be corrected during training, not only after averaging.

3Gradients as Directions: A Three-Weight Toy Model

A three-weight toy turns the gradient into three loss-sensitivity stories. Client 1's mini-batch packs average near (5, -2, 1); the server mixes client habits into global c = (1, 2/3, 2/3).

4Control Variates and the SCAFFOLD Correction

SCAFFOLD rewrites the current mini-batch gradient as g_i minus local c_i plus global c, so a spiked fifth batch is rotated toward the other clients instead of following private drift.

5A Full SCAFFOLD Round With Two Clients

A one-number round traces client 1 from x=10 to y=8.8 with corrected gradient 6 and send pair (-1.2, 4), and client 2 to 9.2 with send pair (-0.8, 2).

6Server Aggregation and Partial Participation

The server averages model deltas to move x from 10 to 9, then scales the mean control delta by |S|/N = 2/4 so c moves from 2 to 3.5 rather than a blind 5.

7FedProx: A Rubber-Band Penalty on Distance

FedProx leashes local training with a proximal penalty whose gradient is mu times (y minus x). With mu=2 the second step lands at 8.38 instead of 8.2; large mu means closer to the global model, not merely slower.

8SCAFFOLD Versus FedProx

Both methods fight client drift by averaging, but SCAFFOLD rewrites gradient direction with extra control vectors and no mu knob, while FedProx limits distance with a proximal penalty and no extra vectors.

9Exam Guidance Summary

Exam items mix a short numeric toy with a why sentence: FedAvg weights, SCAFFOLD correction and one-dimensional round, FedProx rubber-band numbers, and a comparison table.

10Key Industry Applications

Photo, keyboard, and hospital fleets with skewed labels need a mix rule beyond FedAvg: SCAFFOLD when extra controls are affordable, FedProx when only a mu leash fits the device.

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.

Combining Client Models When Data Is Not Shared

Must-know: FedAvg mixes client weights as a sample-count weighted average; non-IID client data can make that mix unsafe.

⚠️ Top pitfall: Treating FedAvg as an unweighted mean, or assuming extra local steps always help.

Self-check: Three clients with n=(100,50,50) and w=(1,3,5): what is the FedAvg mix?

Connects to: SCAFFOLD: Stochastic Controlled Averaging, FedProx: A Rubber-Band Penalty on Distance

SCAFFOLD: Stochastic Controlled Averaging

Must-know: SCAFFOLD sends both x and c to the client and gets back Delta y_i and Delta c_i; there is no peer-to-peer channel.

⚠️ Top pitfall: Sending only the model x, or confusing the current gradient g_i with the stored control c_i.

Self-check: Why can a client not compute global c from local data alone?

Connects to: Gradients as Directions: A Three-Weight Toy Model, Control Variates and the SCAFFOLD Correction

Gradients as Directions: A Three-Weight Toy Model

Must-know: A gradient coordinate is how loss moves when that weight is nudged; a client's usual gradient is the average over noisy mini-batches.

⚠️ Top pitfall: Calling one noisy mini-batch 'the' client gradient, or mixing up local c_1 with global c.

Self-check: Average the four client-1 packs. How close is the mean to (5, -2, 1)?

Connects to: Control Variates and the SCAFFOLD Correction

Control Variates and the SCAFFOLD Correction

Must-know: Corrected gradient is current g minus local habit c_i plus global habit c; skipping the minus leaves local drift in the step.

⚠️ Top pitfall: Adding global c without subtracting local c_i.

Self-check: Why is g_i + c the wrong correction?

Connects to: Gradients as Directions: A Three-Weight Toy Model, A Full SCAFFOLD Round With Two Clients

A Full SCAFFOLD Round With Two Clients

Must-know: Local control updates as c_i minus c plus (x minus y_i) over K eta; clients upload differences, not raw new weights.

⚠️ Top pitfall: Uploading y_i and c_i^{+} instead of deltas, or putting fleet size N in the 0.2 client-side divisor.

Self-check: Client 1: 9 - 5 + 2 equals what, and what pair is sent?

Connects to: Control Variates and the SCAFFOLD Correction, Server Aggregation and Partial Participation

Server Aggregation and Partial Participation

Must-know: x uses the mean model delta; c uses that mean times |S|/N when participation is partial.

⚠️ Top pitfall: Dropping the minus sign of Delta x, or adding the raw mean Delta c as if the whole fleet had joined.

Self-check: If |S|=2, N=4, mean Delta c=3, and c=2, what is c^+?

Connects to: A Full SCAFFOLD Round With Two Clients, FedProx: A Rubber-Band Penalty on Distance

FedProx: A Rubber-Band Penalty on Distance

Must-know: Penalty gradient is mu(y-x); mu=0 is FedAvg; large mu keeps w close to w^t rather than merely slowing updates.

⚠️ Top pitfall: Reading large mu as slower rather than closer, or applying the modified gradient from the wrong starting y.

Self-check: From y=9.1, x=10, mu=2, g=9, eta=0.1, what is the next y?

Connects to: Combining Client Models When Data Is Not Shared, SCAFFOLD Versus FedProx

SCAFFOLD Versus FedProx

Must-know: SCAFFOLD is gradient-based direction correction with extra controls; FedProx is distance-based with a mu knob and no extra vectors.

⚠️ Top pitfall: Saying only that both reduce drift, or ranking the two from the toy numbers.

Self-check: Which method needs global c on the client, and which recovers FedAvg at mu=0?

Connects to: Control Variates and the SCAFFOLD Correction, FedProx: A Rubber-Band Penalty on Distance

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.