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

Lower memory usage during AttnFuncWithCP.forward #951

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

Conversation

i4never
Copy link

@i4never i4never commented Jun 21, 2024

Description

Release p2p_comm_buffers.

Fixes #952

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refractor

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@timmoon10
Copy link
Collaborator

/te-ci pytorch

@xrennvidia
Copy link
Collaborator

Hi @i4never

Thanks for submitting the PR! Have you done any E2E training test with your PR? There is some case where communication can take longer time than compute, your code seems can set p2p_comm_buffers[i]=None before the async P2P communication is done, right? Wouldn't this result in any issue?

Actually, how critical is it for you to fix the issue? The communication buffers are temp buffers per transformer layer, while the attention fwd of a transformer layer is done, those buffers will be released dynamically. Assuming mbs=1, seq=64K, head_dim=128, GQA group of 8 (i.e., num of KV heads is 8), and BF16 precision. The total P2P comm buffer size is only 65536128228=256MB. For long sequence like 64K, you may apply TP. Assuming TP8, then total P2P comm buffer size will be 8 times smaller, i.e., 256/8=32MB. Do you have a special case which the buffer size is too big?

Thanks.

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.

AttnFuncWithCP can use less memory
3 participants