Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix, pipeline model with moe cause error when send grad #7055

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wukong1992
Copy link
Contributor

@wukong1992 wukong1992 commented Feb 19, 2025

Fix, pipeline model with moe, send and recv grad use same buffer will cause error when moe loss not in position 1. Solution, activation and grad use diff buffer. BUG DETAIL: in forward, the grad_buf will allocate hidden_states,some
tensors(required_grad is false), moe_loss;in backward,only send act grad(floating point),so only hidden_states and moe loss's grads will be send, and forward and backward use same grad_buf. This will cause send and recv grad use diff dtype, and cause numerical error。

… cause error when moe loss not in position 1
@wukong1992
Copy link
Contributor Author

@tohtana Could you review the merge requests?

@loadams
Copy link
Collaborator

loadams commented Mar 5, 2025

Hi @wukong1992 - looks like your changes are failing the formatting check - could you either run the pre-commit formatter locally or take a look at the errors? It looks like your changes mean we can remove an import and flake8 caught that.

@tohtana
Copy link
Contributor

tohtana commented Mar 7, 2025

Hi @wukong1992, Thank you for this great fix, and sorry for my late response.

I wonder if some behaviors might change with this PR other than solving the issue. _allocate_or_extend_buffers reuses the buffer when possible. Your change seems to allocate memory every time. Honestly, I'm not sure how much it affects the performance, but afraid that it can increase memory fragmentation. Can you share any thought on this?

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.

4 participants