Skip to content

Conversation

@akakakakakaa
Copy link
Contributor

@akakakakakaa akakakakakaa commented Sep 9, 2025

What does this PR do?

Fixes #3933

Fix potential hang, If any rank hits non_pad_entropies.numel() == 0, the collective call will block forever:

non_pad_entropies = entropies[mask.bool()].float()
if non_pad_entropies.numel() == 0:
    return torch.zeros_like(entropies, dtype=torch.bool)

Who can review?

@qgallouedec

@akakakakakaa akakakakakaa changed the title Fix potential hang in get_high_entropy_mask [GRPO] Fix potential hang in get_high_entropy_mask Sep 9, 2025
pad_value = -1e9

# Pad across processes so that every rank has the same tensor length
padded = self.accelerator.pad_across_processes(local, dim=0, pad_index=pad_value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very cool! Didn't know that function existed 😄

@qgallouedec qgallouedec changed the title [GRPO] Fix potential hang in get_high_entropy_mask ♨️ [GRPO] Fix potential hang in get_high_entropy_mask Sep 12, 2025
@qgallouedec qgallouedec changed the title ♨️ [GRPO] Fix potential hang in get_high_entropy_mask ♨️ [GRPO] Fix potential hang in get_high_entropy_mask Sep 12, 2025
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.

super cool! thanks!

@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.

@qgallouedec qgallouedec merged commit f4ff248 into huggingface:main Sep 12, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GRPOTrainer with top_entropy_quntile < 1 causes hang with multi gpu training

4 participants