Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c21d55b
Benchmark the mcq medeical dataset
mina5rovic Apr 16, 2026
3014cf5
lint error correction
mina5rovic Apr 17, 2026
e785cf6
add val dataset path param
mina5rovic Apr 19, 2026
c93631c
add working local train
mina5rovic Apr 20, 2026
2e34a37
add model saving to disk arg and more debug lines
mina5rovic Apr 22, 2026
4c9c84c
add debug commands
mina5rovic Apr 24, 2026
23c733d
add cnahges to federated approach
mina5rovic Apr 24, 2026
096393c
change round 0 payload null handling
mina5rovic Apr 24, 2026
1ef7d85
chnage server max payload limit to higher number
mina5rovic Apr 26, 2026
417bfa5
fix memory reads and wait for all clients to begin
mina5rovic Apr 26, 2026
77ce9a9
add server debug logs to see why ws close session
mina5rovic Apr 26, 2026
7aef628
cover whole dataset and split data to clients
mina5rovic Apr 27, 2026
d65fb4a
add validation dataset loading changes
May 4, 2026
fe7c51a
change gpt config to use whole dadataset
mina5rovic May 4, 2026
0dc32aa
add arg for model saving location, cnahge save to saveLog, change lin…
mina5rovic May 5, 2026
5c03f40
add training optimizations
mina5rovic May 5, 2026
4ee6096
change onnx converter to be able to convert different context len
mina5rovic May 6, 2026
5b5f88c
aggregate inside of an epoch for llms
mina5rovic May 11, 2026
8d409b9
fix mem leak
mina5rovic May 11, 2026
144b751
change ligs
mina5rovic May 11, 2026
c046e9e
change model to 256
mina5rovic May 12, 2026
e89b9e0
back to 512
mina5rovic May 12, 2026
fbcca59
fix end of training
mina5rovic May 12, 2026
dfe388e
fix mem script and add logs
mina5rovic May 14, 2026
04a4769
debug memorization script
mina5rovic May 15, 2026
e2d2361
change benchmark
mina5rovic May 16, 2026
25fcf28
add client id on debug logs, and final aggregation wait between clients
mina5rovic May 23, 2026
3f6755c
Implement goldfish loss and make benchmark and memorizarion script ju…
mina5rovic May 28, 2026
d15da84
add def task for local finetuning
mina5rovic Jun 1, 2026
05cf239
fix bug
mina5rovic Jun 1, 2026
c0c41a1
bug fix
mina5rovic Jun 1, 2026
95197f7
add validation before and after aggreagtion
mina5rovic Jun 1, 2026
3e05567
fix eval script
mina5rovic Jun 2, 2026
6374b54
add save-checkpoints flag
mina5rovic Jun 2, 2026
7a815a9
decrease lr
mina5rovic Jun 2, 2026
718027c
decrease lr with flag
mina5rovic Jun 2, 2026
f829347
fix lr
mina5rovic Jun 4, 2026
7e16a96
set doSample true
mina5rovic Jun 4, 2026
aa5d8be
optimize eval script
mina5rovic Jun 4, 2026
240c6cd
add hellaswag-like eval for medMCQ gpt2
mina5rovic Jun 4, 2026
d2ae092
add top k in mem script and debug fed client
mina5rovic Jun 12, 2026
f37f5de
fix mem leak mean aggr and serialization
mina5rovic Jun 12, 2026
153d5aa
add mem fix debug logs
mina5rovic Jun 13, 2026
b46fd9b
fix server error
mina5rovic Jun 13, 2026
d73e5ad
fix leak in mem
mina5rovic Jun 13, 2026
95952cb
patch DP
mina5rovic Jun 13, 2026
d46614a
patch DP mem leak
mina5rovic Jun 13, 2026
b2fbd1e
fix unwanted dispose
mina5rovic Jun 13, 2026
1ed4bee
clean lint
mina5rovic Jul 6, 2026
2a4aa76
failing test fix
mina5rovic Jul 6, 2026
cddb271
trainer fix deadlock
mina5rovic Jul 6, 2026
2bec409
fix dispose
mina5rovic Jul 6, 2026
3061d94
fix debug line
mina5rovic Jul 6, 2026
9b40fb7
Merge branch 'develop' into gpt2-training
mina5rovic Jul 8, 2026
4ad761b
continue merge
mina5rovic Jul 8, 2026
6c53b6f
fix formatting
mina5rovic Jul 8, 2026
39f9689
fix lint
mina5rovic Jul 8, 2026
a9dfeef
fix formatting
mina5rovic Jul 8, 2026
3446d0d
fix formatting
mina5rovic Jul 8, 2026
34e16c8
add part
mina5rovic Jul 8, 2026
434a018
Update discojs/src/training/trainer.ts
mina5rovic Jul 19, 2026
b861f55
Update discojs/src/training/trainer.ts
mina5rovic Jul 19, 2026
f1d486b
Update discojs/src/training/trainer.ts
mina5rovic Jul 19, 2026
c34face
Update discojs/src/training/trainer.ts
mina5rovic Jul 19, 2026
4207877
clean debug logs
mina5rovic Jul 19, 2026
ff62115
add hash comment and fix refactor
mina5rovic Jul 19, 2026
3a921b9
make changes after first part of code review
mina5rovic Aug 27, 2026
757dab1
add avg aggregator change
mina5rovic Aug 27, 2026
3d205c4
fix: memory leak
JulienVig Aug 28, 2026
5fc85dc
fix: catch potential serialization errors
JulienVig Aug 28, 2026
6cc4fb9
fix: outdated command
JulienVig Aug 28, 2026
202a3f2
fix: only log when metric is defined
JulienVig Aug 28, 2026
526faec
fix: rm console.log
JulienVig Aug 31, 2026
b0aa7a5
fix: rm unreachable if
JulienVig Aug 31, 2026
fdd41de
fix: add validationMode arg to cli
JulienVig Aug 31, 2026
a883657
fix: propagate encoding error in catch
JulienVig Aug 31, 2026
248b928
fix: change console.log to debug
JulienVig Aug 31, 2026
adbc444
fix: remove debug statements
JulienVig Aug 31, 2026
5c92349
fix: throw error if validation path is set for non-text task
JulienVig Aug 31, 2026
8dbd156
fix: outdated doc
JulienVig Aug 31, 2026
4c4fe6e
test: aggregator tensor disposal
JulienVig Aug 31, 2026
66bce64
test: tensor disposal
JulienVig Aug 31, 2026
18d7eda
fix: rm debug statements
JulienVig Aug 31, 2026
403f61b
doc: roundIterations takes precedence over roundDuration
JulienVig Aug 31, 2026
99855ea
fix: throw early if model doesn't support training by iteration
JulienVig Aug 31, 2026
f0c9ee7
refactor: rename privacyrun to goldfish
JulienVig Aug 31, 2026
bf4c446
fix: don't fail silently
JulienVig Aug 31, 2026
f8ba291
doc: update README cli args
JulienVig Aug 31, 2026
07d4f87
fix: rm centralized fine-tuning
JulienVig Aug 31, 2026
f860805
merge: main
JulienVig Sep 1, 2026
9411190
fix: pin pnpm version
JulienVig Sep 1, 2026
4199dea
test: new event timeline
JulienVig Sep 2, 2026
2c81b96
doc: update cli readme
JulienVig Sep 7, 2026
0f57faa
merge: main
JulienVig Sep 7, 2026
1767652
merge: main
JulienVig Sep 8, 2026
0dfcc3c
merge: main
JulienVig Sep 8, 2026
a596257
merge: main
JulienVig Sep 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"entry": [
"src/benchmark_gpt.ts",
"src/hellaswag_gpt.ts",
"src/train_gpt.ts"
"src/train_gpt.ts",
"src/evaluate_finetuned_gpt2_full_answer.ts",
"src/evaluate_finetuned_gpt2.ts",
"src/measure_memorization_gpt2.ts"
]
},
"onnx-converter": {
Expand Down
58 changes: 54 additions & 4 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,34 @@ Non-mandatory fields will automatically use values from the task specification.
- `testID`: (mandatory) arbitrary test ID defined by the user for the test run
- `task`: (mandatory) pre-defined task (adding a new task is described in the next section)
- `numberOfUsers`: number of users participating in the learning round
- `save`: whether to save the logs of the test run
- `host`: URL of the server to connect to, defaults to `http://localhost:8080`
- `outputPath`: path to save logs and models, defaults to `./<testID>`
- `saveLogs`: whether to save the logs of the test run
- `saveModel`: whether to save the trained model to disk
- `saveCheckpoints`: whether to save each client model after every completed round/aggregation

### Dataset arguments

- `datasetPath`: path to the training dataset
- `validationDatasetPath`: path to a separate validation dataset shared by all clients, takes precedence over `validationSplit`

### Learning hyperparameters

- `epochs`: total number of training epochs
- `roundDuration`: number of epochs per round
- `roundDuration`: number of epochs per round, ignored if `roundIterations` is set.
- `roundIterations`: number of iterations per round, takes precedence over `roundDuration`
- `batchSize`: batch size
- `validationSplit`: ratio of the validation set used for evaluation
- `validationSplit`: fraction of each client's training data used for validation, ignored when `validationDatasetPath` is set; 0 disables split-based validation
- `validationFrequency`: how often to validate. Validate the first aggregation round and every N rounds after it; defaults to every round, 0 disables validation metrics
- `validationMode`: when to run the validation: `before` model aggregation (default), `after`, or `both`
- `learningRate`: override the learning rate (GPT text tasks only)

### Goldfish loss parameters (GPT text tasks only)

- `goldfishLoss`: train with the [goldfish loss](https://arxiv.org/abs/2406.10209), which drops a subset of target tokens from the loss to mitigate memorization
- `goldfishK`: drop modulus k, a target token is dropped if hash(context) mod k == 0
- `goldfishH`: localized hash context length
- `goldfishPadTokenId`: (optional) padding token id to exclude from the goldfish loss denominator

### Aggregator parameters

Expand All @@ -57,7 +77,7 @@ Non-mandatory fields will automatically use values from the task specification.

## Adding new tasks

The CLI can be used on several pre-defined tasks: titanic, lus_covid and CIFAR10. In order
The CLI can be used on several pre-defined tasks: `cifar10`, `lus_covid`, `mnist`, `simple_face`, `tinder_dog`, `titanic` and `goldfish` (GPT-2 fine-tuning). In order
to understand how to add a new task have a look at [TASK.md](../docs/TASK.md).

Once a new task has been defined in `discojs`, it can be loaded in [data.ts](./src/data.ts) as it is already implemented for current tasks. There are currently [multiple classes](../discojs-node/src/loaders) you can use to load data using Node.js and preprocess data: loadImagesInDir, loadCSV and loadText.
Expand Down Expand Up @@ -105,3 +125,33 @@ Results are printed to the console and saved to a log file: `../datasets/logFile
This allows for a direct comparison between the inference performance and accuracy of the two architectures.

The TFJS implementation is generally slower and more memory-intensive than ONNX, but offers compatibility with browser-based environments and custom training workflows. See the [Benchmarking GPT-TF.js](#benchmarking-gpt-tfjs) section for more details on performance tradeoffs.

## Training GPT-2 on Hellaswag with Goldfish loss

```bash
pnpm --filter server start

DEBUG=* pnpm --filter cli start --task goldfish \
-d ../datasets/trainAnswersPHIx10.txt \
-V ../datasets/val_medFullAnswers100.txt \
--learningRate 0.0001 \
--testID arbitrary_task_id \
--numberOfUsers 2 --goldfishLoss true --epochs 1 \
--roundIterations 15 \ # aggregate every 15 batches
--validationSplit 0 \ # 0 because we specified a val dataset path
--validationMode both \ # evaluate before and after aggreation
--saveCheckpoints true --saveLogs true --saveModel true \
-o ./logs/goldfish_training
```

### Evaluating a fine-tuned model

```bash
pnpm -F cli run eval_finetuned_gpt2 --modelPath path/to/model.json --testPath ../datasets/test_medFullAnswers.txt --maxSamples 100
```

### Measuring the memorization of a fine-tuned model

```bash
pnpm -F cli measure_memorization_gpt2 --modelPath path/to/model.json --dataPath ../datasets/PHI_filtered_final.txt
```
4 changes: 4 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"benchmark_gpt": "pnpm run build && node dist/benchmark_gpt.js",
"train_gpt": "pnpm run build && node dist/train_gpt.js",
"hellaswag_gpt": "pnpm run build && node dist/hellaswag_gpt.js",
"eval_finetuned_gpt2": "pnpm run build && node dist/evaluate_finetuned_gpt2.js",
"measure_memorization_gpt2": "pnpm run build && node dist/measure_memorization_gpt2.js",
"build": "tsc --build",
"test": ": nothing"
},
Expand All @@ -17,7 +19,9 @@
"dependencies": {
"@epfml/discojs": "workspace:",
"@epfml/discojs-node": "workspace:",
"@tensorflow/tfjs": "catalog:",
"@tensorflow/tfjs-node": "catalog:",
"debug": "catalog:",
"immutable": "catalog:",
"server": "workspace:"
},
Expand Down
Loading
Loading