[On Policy Distillation] resolve log prob dimension mismatch in on-policy distillation with CP > 1#1135
Open
Yuchen-Cao wants to merge 3 commits intoTHUDM:mainfrom
Open
[On Policy Distillation] resolve log prob dimension mismatch in on-policy distillation with CP > 1#1135Yuchen-Cao wants to merge 3 commits intoTHUDM:mainfrom
Yuchen-Cao wants to merge 3 commits intoTHUDM:mainfrom
Conversation
yitianlian
reviewed
Dec 17, 2025
| advantages = [ | ||
| teacher_log_prob - student_log_prob | ||
| for teacher_log_prob, student_log_prob in zip(teacher_log_probs, student_log_probs, strict=False) | ||
| t_log_prob[-response_length:] - s_log_prob[-response_length:] |
Collaborator
There was a problem hiding this comment.
I think we shouldn't slice logp with response_length because the current logp is CP sliced?
Author
There was a problem hiding this comment.
Oh yes!
Just some previous attempts when i tried to match the size between them. will change this line back.
yitianlian
approved these changes
Dec 24, 2025
Collaborator
yitianlian
left a comment
There was a problem hiding this comment.
LGTM! Sorry for the late reply :(.
Collaborator
|
Maybe you should run the pre-commit to fix the format error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses a dimension mismatch issue in on_policy_distillation when Context Parallel (CP) is enabled (cp_size > 1).
Problem:
Previously, the implementation did not support slicing the teacher's log prob according to the Context Parallel rank. While the student's log prob adhered to CP slicing, the teacher's log prob remained unsliced. This inconsistency caused a shape mismatch error between the student and teacher tensors during loss computation.
Solution:
I have updated the logic to apply CP slicing to the teacher's log prob, ensuring they align with the student's log prob. This fixes the dimension error and enables proper support for on-policy distillation with Context Parallelism.