Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions docs/causal-lm.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,13 @@ full-model training, and next-token evaluation. The [Medical application](medica
adds micro-batched flashcard training and PubMedQA subset evaluation. Optional DoRA
remains follow-up work. The [reference backend](reference-causal-lm.md) supports
sequential LM execution and comparisons against Flower.

The [repeatability checks](differential-testing.md#mode-2-determinism) compare two
attempts per backend, including per-round evidence and checkpoint tensors.
`examples/configs/finance_long_learning_check.yaml` provides a 15-round SmolLM2
learning check with four IID clients, two selected per round, effective batch 8,
ten local steps and a cosine learning-rate schedule. It uses 256 training rows
per client and a fixed 64-record holdout. The configured warning threshold is a
two-percentage-point accuracy gain from round zero; a loss reduction alone does
not satisfy that threshold. This is a scaled learning check, separate from the
full 50-client Mistral benchmark configuration.
23 changes: 23 additions & 0 deletions docs/differential-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,29 @@ nondeterminism / state leakage.
**Rule:** `|metric(run1) − metric(run2)| ≤ tolerance` (use a tiny `tolerance`, e.g. `1e-4`),
on `device: cpu`.

For causal LMs, this mode also requires matching data provenance, initialization,
selected clients and successful training-record IDs. The selected metric must
agree at round zero, every trained round and in the final summary. Generated
predictions and application-specific held-out details must match exactly. Saved
checkpoint tensor names, shapes and dtypes must match, all tensors must be finite,
and their largest absolute element difference must be within tolerance. Each
attempt must retain its own checkpoint directory. Missing evidence fails the check.

The GPU examples `finance_repeatability.yaml`, `stackoverflow_repeatability.yaml`
and `medical_repeatability.yaml` each run both reference and Flower twice with
zero tolerance. Start the two-node Ray cluster as described in
[multi-node execution](multi-node.md), then use, for example:

```bash
fltest diff examples/configs/finance_repeatability.yaml
```

These configurations test empirical repeatability on the same hardware and pinned
software. `deterministic: true` seeds FLTest's RNGs; it does not enable PyTorch's
strict deterministic-algorithm mode or guarantee bit identity on other GPUs,
software versions, model sizes or attention implementations. Timing, hostname
placement and allocator memory measurements are excluded from numerical parity.

```yaml
testing:
differential: {mode: determinism, metric: accuracy, tolerance: 0.0001}
Expand Down
47 changes: 47 additions & 0 deletions examples/configs/finance_long_learning_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Scaled SmolLM2 learning check; not the full 50-client Mistral benchmark experiment.
name: finance_long_learning_check
task: causal_lm
dataset: hf:flwrlabs/fingpt-sentiment-train
model_name: hf:HuggingFaceTB/SmolLM2-135M-Instruct
seed: 786
device: cuda
total_cpus: 8
total_gpus: 2
num_clients: 4
dataset_partitions: 4
clients_per_round: 2
num_rounds: 15
client_batch_size: 8
client_lr: 5.0e-05
optimizer: AdamW
server_batch_size: 4
max_test_data_size: 64
client_resources:
num_cpus: 2
num_gpus: 1
lm:
model_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
tokenizer_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
dataset_revision: d01aba2a91252c687bc35e4da659ab73ac70ea27
precision: fp16
quantization: 4bit
lora_r: 32
lora_alpha: 64
seq_len: 256
local_steps: 10
gradient_checkpointing: true
holdout_fraction: 0.1
max_train_samples_per_client: 256
checkpoint_dir: reports/adapters
lr_schedule:
name: cosine_over_rounds
min_lr: 1.0e-06
learning_gap:
metric: accuracy
min_improvement: 0.02
metrics:
- accuracy
- loss
runs:
- framework: flwr
name: clean
62 changes: 62 additions & 0 deletions examples/configs/finance_repeatability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Two attempts per backend; empirical repeatability on the same hardware/software.
name: finance_repeatability
task: causal_lm
dataset: hf:flwrlabs/fingpt-sentiment-train
model_name: hf:HuggingFaceTB/SmolLM2-135M-Instruct
seed: 786
device: cuda
total_cpus: 8
total_gpus: 2
num_clients: 2
dataset_partitions: 2
clients_per_round: 2
num_rounds: 2
client_batch_size: 2
client_lr: 5.0e-05
optimizer: AdamW
server_batch_size: 4
max_test_data_size: 4
client_resources:
num_cpus: 2
num_gpus: 1
lm:
model_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
tokenizer_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
dataset_revision: d01aba2a91252c687bc35e4da659ab73ac70ea27
precision: fp16
quantization: 4bit
lora_r: 32
lora_alpha: 64
seq_len: 256
local_steps: 2
gradient_checkpointing: true
holdout_fraction: 0.1
max_train_samples_per_client: 32
checkpoint_dir: reports/adapters
lr_schedule:
name: cosine_over_rounds
min_lr: 1.0e-06
learning_gap:
metric: finance_benchmark_accuracy
min_improvement: 0.02
finance_benchmarks:
max_samples_per_benchmark: 4
max_new_tokens: 16
metrics:
- accuracy
- loss
- fpb_accuracy
- fiqa_accuracy
- tfns_accuracy
- finance_benchmark_accuracy
runs:
- framework: reference
name: reference
- framework: flwr
name: flower
testing:
differential:
enabled: true
mode: determinism
metric: loss
tolerance: 0.0
56 changes: 56 additions & 0 deletions examples/configs/medical_repeatability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Two attempts per backend; empirical repeatability on the same hardware/software.
name: medical_repeatability
task: causal_lm
dataset: hf:flwrlabs/medical-meadow-medical-flashcards
model_name: hf:HuggingFaceTB/SmolLM2-135M-Instruct
seed: 786
device: cuda
total_cpus: 8
total_gpus: 2
num_clients: 2
dataset_partitions: 2
clients_per_round: 2
num_rounds: 2
client_batch_size: 4
client_lr: 5.0e-05
optimizer: AdamW
server_batch_size: 2
max_test_data_size: 8
client_resources:
num_cpus: 2
num_gpus: 1
lm:
model_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
tokenizer_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
dataset_revision: bc33733afea65239aed2149aa79ea77742d28cc2
precision: fp16
quantization: 4bit
lora_r: 32
lora_alpha: 64
seq_len: 256
local_steps: 2
gradient_checkpointing: true
holdout_fraction: 0.1
max_train_samples_per_client: 32
checkpoint_dir: reports/adapters
micro_batch_size: 1
grad_accum_steps: 4
medical:
pubmedqa_revision: 13a7d15476092370cbabb6475390e7e69b74d2f2
pubmedqa_max_samples: 8
pubmedqa_max_prompt_tokens: 1024
max_new_tokens: 32
metrics:
- pubmedqa_accuracy
- loss
runs:
- framework: reference
name: reference
- framework: flwr
name: flower
testing:
differential:
enabled: true
mode: determinism
metric: loss
tolerance: 0.0
52 changes: 52 additions & 0 deletions examples/configs/stackoverflow_repeatability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Two attempts per backend; empirical repeatability on the same hardware/software.
name: stackoverflow_repeatability
task: causal_lm
dataset: stackoverflow
data_distribution: by_user
model_name: hf:HuggingFaceTB/SmolLM2-135M-Instruct
device: cuda
total_cpus: 8
total_gpus: 2
num_clients: 4
dataset_partitions: 4
clients_per_round: 2
num_rounds: 2
client_batch_size: 2
client_lr: 0.001
optimizer: SGD
server_batch_size: 2
max_test_data_size: 16
client_resources:
num_cpus: 2
num_gpus: 1
lm:
model_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
tokenizer_revision: 12fd25f77366fa6b3b4b768ec3050bf629380bac
method: full
precision: fp16
quantization: null
seq_len: 128
local_steps: 2
gradient_checkpointing: true
max_train_samples_per_client: 32
checkpoint_dir: reports/models
stackoverflow:
train_path: data/stackoverflow/so_1k/train.parquet
heldout_path: data/stackoverflow/so_1k/heldout.parquet
partition_by: user_id
max_heldout_users: 4
metrics:
- next_token_accuracy
- perplexity
- loss
runs:
- framework: reference
name: reference
- framework: flwr
name: flower
testing:
differential:
enabled: true
mode: determinism
metric: loss
tolerance: 0.0
Loading
Loading