fix(megatron): gather embedding evaluation metrics across DP ranks - #10091
Open
MrCapricornLiu wants to merge 2 commits into
Open
fix(megatron): gather embedding evaluation metrics across DP ranks#10091MrCapricornLiu wants to merge 2 commits into
MrCapricornLiu wants to merge 2 commits into
Conversation
Signed-off-by: Chenghao Liu <chliu@stu.pku.edu.cn>
Signed-off-by: Chenghao Liu <chliu@stu.pku.edu.cn>
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.
PR type
PR information
Megatron embedding evaluation accumulates predictions and labels locally, so each data-parallel rank computes different metrics over its own shard. Pearson/Spearman correlations cannot be recovered by averaging these local correlations. InfoNCE evaluation also misses other DP ranks' in-batch candidates.
Give the embedding metric the trainer's data-parallel group and gather predictions together with their labels before computing the existing metrics. Gathering the accumulated lists supports unequal shard sizes and a rank with no local updates. The accumulated state stays local, so repeated computation does not duplicate samples. The default/Hugging Face entry remains local.
This complements #10088, which handles reranker query metrics. Embedding correlations and cross-query InfoNCE candidates require the complete predictions rather than a reduction of per-query scores. This change does not modify the reranker implementation.
Experiment results
The GPU check exercises metric collection and process groups, not a full pretrained-model evaluation. Gathering embeddings adds communication and per-rank memory proportional to the evaluation data; full-model performance, pipeline parallel evaluation, and multi-node execution were not tested.