Skip to content

docs: collaborative training architecture design document - #1298

Open
ale18V wants to merge 29 commits into
mainfrom
docs/collaborative-training-architecture
Open

ale18V wants to merge 29 commits into
mainfrom
docs/collaborative-training-architecture

Conversation

@ale18V

@ale18V ale18V commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

Disco currently models collaborative learning variations primarily through a single aggregationStrategy axis while embedding algorithm-specific state and update clipping directly inside Trainer. This coupling prevents composing client-side optimization strategies (such as FedProx or learning rate schedules) with robust or private aggregators (ByzantineRobustAggregator, SecureAggregator) and forces Trainer and Model subclasses (TFJS, GPT) to accumulate ad-hoc branches or custom training loops for every new algorithm.
This PR introduces a design document detailing these architectural limitations and proposing a modular, hook-driven target architecture.

Todo

  • Implement Phase 1 (TrainingHook pipeline, installOptimizerLossHooks via autograd, and unified Trainer.#executeRound).
  • Implement Phase 2 (decouple trainingStrategy from aggregationStrategy in TrainingInformation, cli, and webapp).
  • Implement Phase 3 (decouple client-side update clipping from ByzantineRobustAggregator and restrict DP noise to trainable parameters).

@ale18V

ale18V commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@JulienVig I think we need to refactor a bit the architecture of disco. The goal would be to decouple some components a bit more and make it easier to implement different algorithms in the future.

PR #1289 already does some refactoring in this direction, but still there are some smells, like algorithm-specific parameters being thrown in the trainer.

I will use this PR to come up with a design doc for a new architecture which we can review together before moving forward with it (if you agree)

@JulienVig

Copy link
Copy Markdown
Collaborator

Yes, refactoring the architecture makes a lot of sense. Let me know when the document is ready for review.

@ale18V
ale18V force-pushed the docs/collaborative-training-architecture branch from 7c58547 to 222de30 Compare November 20, 2026 12:42
@ale18V
ale18V force-pushed the docs/collaborative-training-architecture branch from 222de30 to 5dedee3 Compare November 20, 2026 13:42
@ale18V
ale18V requested review from JulienVig and removed request for JulienVig November 23, 2026 09:43

@JulienVig JulienVig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alessandro. The idea themselves look interesting but the proposal document looks really messy and too wordy. It mixes up design ideas, current technical bugs, and implementation details which makes understanding the proposal quite hard without getting lost in the details.

What's useful to include in a design proposal:

  • the current limitations at a conceptual level
  • the description of the conceptual refactoring idea
  • the expected limitations of the refactoring
  • You include conceptual diagrams if you have a clear point to make and your written text should reference the specific part of the diagram you're talking about.

What's not useful to include:

  • Code
  • Current bugs (you can create separate issues for these)
  • References to precise lines or specific files
  • Technical implementation details
  • Math formulas

If you're unsure you can use collapsable sections to hide potentially interesting details.

Note that the design document shouldn't be specific to Tensorflow.js.

@ale18V
ale18V force-pushed the docs/collaborative-training-architecture branch from 269c827 to 3203fbc Compare November 23, 2026 11:26
@ale18V

ale18V commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

@JulienVig Hi sorry, I had miscklicked and tagged you as reviewer, tried to undo that but I guess you got the notification anyways. I am still making some changes, will tag you once I am done

@ale18V
ale18V requested a review from JulienVig November 25, 2026 16:58

@JulienVig JulienVig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, I like the 3 axis design and make Trainer less bloated. I mainly wonder how to handle algorithms that don't fall cleanly into one axis.
For TFJS let's go with Option 2, it aligns well with the rust transition

2. **training:** Intra-round local client optimization strategies plus composable options like `lr`, `learningRateSchedule`, `goldfishLoss`, composable with any `aggregation.strategy`.
3. **communication transforms** Post-round client update transformations executed in a canonical mathematical order before communication such as _differential privacy_, or model compression.

**Pro**: This removes the problems mentioned in 2.1, it dedicates a place in the config for training-only options, without cluttering aggregation configs. So for example, `FedProx`, being only a training strategy, would be composable with byzantine aggregators. It also adds space for other pre-communication strategy different than privacy, such as compression, or client-side clipping and so on, without having to put them under a specific aggregator.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The byzantine algorithm works in two parts:

  1. aggregation: the server aggregates weights with momentum and clipping
  2. communication transform: clients clip their weight before sending. This interacts with DP to clip to the minimum between the DP and the byzantine radius.

How would this design handle:

  • an algorithm that is spread over multiple axes? (byzantine = aggregation + communication transform)
  • an algorithm that interacts with another? (byzantine and DP clipping)

@ale18V ale18V Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for the specific case you're mentioning, clipping would happen both client-side (for DP) and server side (as in the reference paper) and this would be the correct execution. Client side clipping with byzantine aggregation is an artifact of the previous coupled implementation, it should not be like that, due to byzantine nodes not necessarily following client side rules.

But in general, if I understand correctly you're saying:

Suppose we have an algorithm "Foo" that mandates a certain aggregation function + a pre-communication transform. The user would have to explicitly configure both of them.

I see the option of having a top-level field such as algorithm: "Foo" that would then compile to a set of known communication + aggregation hooks (i.e you parse Foo so you know you have to instantiate those hooks). Or you assume the user knows how the algorithm works, and let them write the config accordingly.
The idea is that we give the modular pieces.

an algorithm that interacts with another? (byzantine and DP clipping)

That's a fair point and I also mentioned in the config. This should be not too common, and the few conflicts could be resovled ad-hoc. In any case there's a trade-off about config complexity and capability/consistency, there's only so much you can do with a JSON config without going through a DSL route.

@JulienVig JulienVig Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Algorithm presets

I see the option of having a top-level field such as algorithm: "Foo" that would then compile to a set of known communication + aggregation hooks (i.e you parse Foo so you know you have to instantiate those hooks)

Yes I think we should do that. Allow either setting a high-level algorithm which is a preset defined over the three axes or alternatively pick each of the three axes manually.

As you mentioned yourself in section 4 FedNova spans the 3 axes and imply data communication: axis 1: count the number of local steps performed (τ_i), axis 2: normalize the local update per step and send the local step count to the server, axis 3: weighted average of the contributions and rescaled by the effective step count parameter (τ_eff)

So implementing FedNova would imply implementing a FedNovaTrainingHook + a FedNovaAggregator. Instead of manually picking two settings in different places let's allow setting "fednova" in a single place so a user creating a task doesn't need an understanding of the internals of DISCO to correctly setup an algorithm.

| { name: "fedprox", params: { mu: ... } },
lr?: ...,
learningRateSchedule?: ...,
goldfishLoss?: ...,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guess goldfishLoss would fall in training strategies

Comment on lines +20 to +27
1. **Intra-Round Local Training Strategy (Client Optimization):** How each client optimizes its local model over its local dataset during a round:
- Standard Empirical Risk Minimization (FedAvg)
- Proximal regularization towards the round's initial weights: $\min_w F_k(w) + \frac{\mu}{2}\|w - w^{(t)}\|^2$ (FedProx)
- Round- or epoch-level learning rate schedules and warmups
2. **Post-Round Client Update Transformation & Privacy (Pre-Communication):** How a client transforms its local weight progress $\Delta w_i^{(t)} = w_i^{(t, K)} - w^{(t)}$ after completing local epochs/iterations and before transmitting weights to the server or peers:
- Explicit global or per-layer update norm clipping
- Adaptive layer-wise Frobenius norm clipping + Gaussian noise injection (ALDP-FL Differential Privacy)
3. **Inter-Client Weight Aggregation & Protocol (Server / Peer Combination):** How updates from multiple participants are combined across the network (e.g mean, byzantine, ...)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the same axis order and names as in the next sections?


### 3.2. Unified `TrainingHook` Lifecycle

Even after having a dedicated place for training settings in the config, we still need to make `Trainer` scalable and independent of the specific strategies, so we don't have to change it every time we add a new strategy. Instead of adding algorithm-specific fields to `Trainer` or algorithm-specific methods (`attachRegularizer`, `adaptLearningRate`, etc.) to `Model`, **every client-side training algorithm is expressed as a TrainingHook**. This is similar to other frameworks suchas **Flower's `Strategy`** and \*\*PyTorch Lightning / Keras `Callback`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to my comment above:
"every client-side training algorithm is expressed as a TraningHook" -> what about algorithms that aren't client-side only?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one. What is a specific scenario that you're thinking of? If training depends on some global state that could be shared by the server, we need to make the communication protocol richer, to send more data than just the model, as it is highlighted in the Future extensions.

So once we do that, any training hook can use onAfterCommunication to catch relevant parameters that need to be bound to the training.

Aggregators are the server-side part and they're handled by the aggregation configs.

@JulienVig JulienVig Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client-server data exchange

I was thinking of algorithms like FedNova that spans the 3 axes

If training depends on some global state that could be shared by the server, we need to make the communication protocol richer, to send more data than just the model, as it is highlighted in the Future extensions.

I also think we should directly implement the possibility to exchange data between client and server (both directions, not just server -> client) described in section 4. For algorithms like FedNova and I was also thinking of adding support to weighted-averaging soon

Comment thread docs/TRAINING_ARCHITECTURE.md Resolved
Comment thread docs/TFJS_TRAINING_HOOKS.md Resolved
Comment on lines +170 to +188
interface TrainingHook<D extends DataType = DataType>
extends Partial<Disposable> {
onRoundBegin?(ctx: HookContext<D>): Promise<void> | void;
onBeforeCommunication?(
weights: WeightsContainer,
ctx: HookContext<D>,
): Promise<WeightsContainer> | WeightsContainer;
onAfterAggregation?(
aggregatedWeights: WeightsContainer,
ctx: HookContext<D>,
): Promise<void> | void;
onRoundEnd?(ctx: HookContext<D>): Promise<void> | void;

onEpochBegin?(ctx: HookContext<D>): Promise<void> | void;
onEpochEnd?(logs: EpochLogs, ctx: HookContext<D>): Promise<void> | void;
onBatchBegin?(ctx: HookContext<D>): Promise<void> | void;
onBatchEnd?(logs: BatchLogs, ctx: HookContext<D>): Promise<void> | void;
computeLoss?(baseLoss: tf.Scalar, ctx: HookContext<D>): tf.Scalar;
}

@JulienVig JulienVig Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting TrainingHook in two

(I'm adding titles to make it easier for me to navigate the different discussions)

Shouldn't the TrainingHook interface be split in two? It seems to cover both axes 1 and 2 which could make it awkward to independently change only one of the 2.

We could split TrainingHook into two interfaces:

  • TrainingHook: round begin/end, epoch and batch callbacks and computeLoss
  • something like CommunicationTransform: onBeforeCommunication, onAfterAggregation and could handle client-server data exchanges

Then an algorithm can be specified as a preset combination { trainingHooks, communicationTransforms, aggregator }

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants