Skip to content

[feat] max vio in sft - #789

Merged
mikasenghaas merged 5 commits into
mainfrom
feat-max-vio
Aug 22, 2025
Merged

mikasenghaas merged 5 commits into
mainfrom
feat-max-vio

Conversation

@Jackmin801

@Jackmin801 Jackmin801 commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

This PR adds logic to log the max_vio expert balance stat. This is (tokens_per_expert.max() - tokens_per_expert.mean()) / tokens_per_expert.mean() as detailed in eq 4 of https://arxiv.org/pdf/2408.15664v1

image

GitHub Issue: #790
Linear Issue: Resolves PRIMERL-48

@Jackmin801

Copy link
Copy Markdown
Contributor Author

Moe logging
image

Doesnt break non moe logging
image

SFT
image

@mikasenghaas mikasenghaas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah nice, so we are logging an average over num layers here, right? also, how does this work? does tt keep the tokens routed to each expert as a layer attribute? or is this smth you added:)

Comment thread src/prime_rl/trainer/rl/train.py Outdated
Comment thread src/prime_rl/trainer/sft/train.py Outdated
@Jackmin801

Copy link
Copy Markdown
Contributor Author

ah nice, so we are logging an average over num layers here, right? also, how does this work? does tt keep the tokens routed to each expert as a layer attribute? or is this smth you added:)

Yup. Its average over the layers because thats the multiple of slowdown this would cause in EP.

Yep, theres a buffer that stores the num tokens per expert that is added to at each fwd. Its needed for the loss free load balancing that deepseek does. Actually that reminded me I have to reset it to 0 after logging otherwise it will just keep accumulating.

@Jackmin801

Copy link
Copy Markdown
Contributor Author
image image

@mikasenghaas mikasenghaas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cleannn, i really like it

@mikasenghaas
mikasenghaas merged commit bab8127 into main Aug 22, 2025
5 checks passed
@mikasenghaas
mikasenghaas deleted the feat-max-vio branch August 5, 2026 04:26
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