Skip to content

Conversation

@casinca
Copy link
Contributor

@casinca casinca commented Dec 13, 2025

What does this PR do?

Fixes #4697

This PR aims to implement the Off-policy sequence masking from the DeepSeek V3.2 paper

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Changes

  • added an helper _get_off_policy_mask staticmethod to compute the off-policy mask
  • added logic in _compute_loss to inject the off-policy mask into the loss mask
  • added logic in _compute_loss to inject the off-policy mask only to the surrogate loss
  • added __post_init__ checks and some tests (including not allowing with Lieger loss atm)
  • added docs

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@casinca casinca marked this pull request as ready for review December 15, 2025 17:57
@casinca
Copy link
Contributor Author

casinca commented Dec 15, 2025

  • @qgallouedec 👋 I'd like to get your atttention on this commit: 861b490

    Initially I had made a mistake by injecting the off-policy mask into the loss mask early. So I had changed the loss mask to be computed upstream, once.
    Even if now, with the correct logic, I'm not touching the loss mask, I wanted to understand why is the loss mask recomputed multiple times? I don't see it being modified/overwritten anywhere downstream. In any case I can revert this specific commit, it won't change my implementation.

  • Additionally if the PR is good, I could add a metric to log for users, something like a off policy sequence drop ratio, so that they aren't blind and also get a better feel to adjust the delta/off_policy_treshold hparam

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.

feat GRPOTrainer: Off-policy sequence masking from DeepSeek V3.2

1 participant