Skip to content

Support Context Parallel for Multi Latent Attention (MLA) #1729

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

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

Conversation

yuzhongw-nvidia
Copy link

@yuzhongw-nvidia yuzhongw-nvidia commented Apr 29, 2025

Description

#1561 has already fixed the issue that the function AttnFuncWithCPAndKVP2P does not support MLA (Multi-latent attention). Specifically, #1561 pad tensor v to head_dim_qk and convert MLA to normal attention. This PR improves #1561 by removing the padding and using MLA kernels to reduce the communication and computation overhead.

Many thanks to SuperCB from xiaohongshu and RandMist from wechat team for their contributions.

Fixes # (issue)

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 refactoring

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

@yuzhongw-nvidia yuzhongw-nvidia changed the title Draft: [WIP] Support Context Parallel for Multi Latent Attention (MLA) Support Context Parallel for Multi Latent Attention (MLA) May 7, 2025
@yuzhongw-nvidia yuzhongw-nvidia marked this pull request as ready for review May 7, 2025 06:18
@yuzhongw-nvidia yuzhongw-nvidia force-pushed the mla_cp branch 6 times, most recently from 091edf3 to f290c61 Compare May 8, 2025 05:52
Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com>
Signed-off-by: Yuzhong Wang <yuzhongw@nvidia.com>
@yaox12 yaox12 requested a review from xrennvidia May 9, 2025 01:32
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.

2 participants