Skip to content

Conversation

edbeeching
Copy link
Collaborator

@edbeeching edbeeching commented Jun 4, 2025

What does this PR do?

Sets average_tokens_across_devices to true in SFTConfig, PRMConfig and RewardModelConfig.

But defautl In a multi-device setting, the training loss is not compariable even you use the same effective batch size. (world_size * per_device_train_batch_size * gradient_accumulation_steps)

Example loss curves for 8,4,2,1 nodes (green, pink, grey, peach respectively).
image

This is because in transformers.TrainingArguments average_tokens_across_devices=False by default. Setting this to true achieves parity and lower training loss in different multi-device / node. Shown in the additional blue curve below. I tested 8 vs 64 GPUs (1 vs 8 nodes) and the training curves were near identical.
image

@edbeeching edbeeching requested a review from qgallouedec June 4, 2025 18:37
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@edbeeching edbeeching requested a review from shirinyamani June 4, 2025 18:55
edbeeching and others added 7 commits June 4, 2025 21:32
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Copy link
Member

@qgallouedec qgallouedec left a comment

Choose a reason for hiding this comment

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

LGTM!

@qgallouedec qgallouedec changed the title [SFT][Bugfix] sets average_tokens_across_devices to true in SFTConfig 🎀 [SFT][Bugfix] sets average_tokens_across_devices to true in SFTConfig Jun 4, 2025
@qgallouedec qgallouedec merged commit 0333108 into main Jun 4, 2025
11 checks passed
@qgallouedec qgallouedec deleted the fix-average-tokens-across-devices branch June 4, 2025 21:20
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.

4 participants