Skip to content

Draft: GPT2 training on MCQ med data - #1111

Open
mina5rovic wants to merge 68 commits into
mainfrom
gpt2-training
Open

Draft: GPT2 training on MCQ med data#1111
mina5rovic wants to merge 68 commits into
mainfrom
gpt2-training

Conversation

@mina5rovic

Copy link
Copy Markdown
Collaborator

No description provided.

@mina5rovic
mina5rovic requested a review from JulienVig April 16, 2026 11:51
@mina5rovic mina5rovic changed the title GPT2 training on MCQ med data Draft: GPT2 training on MCQ med data Apr 16, 2026
@mina5rovic
mina5rovic requested a review from JulienVig July 6, 2026 22:55

@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.

1st part of my review, I'll finish at a different time, feel free to start addressing these comments

Comment thread datasets/.gitignore Outdated
Comment thread cli/src/args.ts
Comment thread discojs/src/training/trainer.ts Outdated
Comment thread discojs/src/client/federated/federated_client.ts Outdated
id: NodeID;
waitForMoreParticipants: boolean;
payload: serialization.Encoded;
payload?: serialization.Encoded | null;

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.

why allow null?

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.

Because payload is null only at round 0, when no global weights exist yet. The server sets it to undefined, but MessagePack decodes undefined as null, so the interface must allow null. It was one of the silent error, took some time to catch.

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.

Shouldn't the first payload sent be the base model that the clients use to train on their local data? I saw that your PR changed this to send null on the first round but I don't see why

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.

The client already downloads model via super.connect() before opening the federated WebSocket (before round 0). On develop, the same weights are then sent again in NewFederatedNodeInfo, so my change avoids that duplicate transfer, which is costly for GPT-2. I can put it back but I'm not sure it is optimal.

Comment thread discojs/src/training/trainer.ts Outdated
Comment thread discojs/src/training/trainer.ts Outdated
Comment thread discojs/src/training/trainer.ts Outdated
Comment thread discojs/src/models/gpt/model.ts
Comment on lines +302 to +305
const model = this.model as unknown as IterationTrainableTextModel;
if (typeof model.trainNextBatches !== "function")
throw new Error("model does not support iteration-based training");

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 find this part really inconvenient because it's not generic, it only addresses on particular case. Here's an idea to work around this, let me know what you think

  1. Implement a new dataset method that splits the dataset after a specified number of steps and returns 1) one dataset with only the next specified number of batches and 2) the remainder of the dataset after these batches. e.g., const [nextBatches, datasetRemainder] = dataset.subset(maxBatchCount)
  2. From runIterationRounds, I think this allows you to do reuse the existing #runRound, e.g. this.#runRound(nextBatches, roundValidationDataset)
  3. With this method I don't think you need to deal with all the iterators

Let me know what you think and whether this is feasible

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 agree that the GPT-specific cast and trainNextBatches are not ideal, and moving this logic out of the model would make it more generic.

My only concern with dataset.subset(maxBatchCount) is that Dataset is currently immutable and can be iterated multiple times, while returning a remainder would make it stateful. Using take and drop could also become expensive because we would keep iterating over the already consumed batches.

Maybe we can keep the iterator in the trainer, wrap the next batches in a temporary dataset, and pass it to the existing model.train(...). This would remove the GPT-specific method without changing the current Dataset behavior. We would still need to be careful when reusing #runRoundByEpoch, since it trains for roundDuration full passes while the iteration-based version should consume each batch only once.

mina5rovic and others added 6 commits July 19, 2026 13:28
Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com>
Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com>
Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com>
Co-authored-by: Julien Vignoud <33122365+JulienVig@users.noreply.github.com>
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