Skip to content

[PyTorch|common] Optimize unpadding kernel for FP8 #1866

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 8 commits into
base: main
Choose a base branch
from

Conversation

xiaoxi-wangfj
Copy link

  1. Add multi-tensor unpadding kernel
  2. Replace split+cat with unpadding kernel in Fp8Padding and Fp8Unpadding
  3. Add unpadding with padding unit tests

Description

This PR introduces a high-performance CUDA kernel implementation for tensor unpadding, replacing the previous inefficient torch.split + torch.cat approach. Key improvements include:

  • ​​2x faster unpadding kernel performance​​ (measured with microbenchmarks).
    ​​- 0.3% MFU uplift​​ in my end-to-end 1000B parameter model training.
  • Added comprehensive unit tests for edge cases (e.g., partial padding units).

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)
  • [x ] 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

  • Replace the existing torch.split + torch.cat unpadding implementation in Fp8Padding backward pass and Fp8Unpadding forward pass
  • Add unpadding inplement in common
  • Add unpadding unit test in tests
    ​​

Checklist:

  • [ x] I have read and followed the contributing guidelines
  • [ x] 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
  • [x ] 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

xiaoxi-wangfj and others added 3 commits June 11, 2025 06:29
1. Add multi-tensor unpadding kernel
2. Replace split+cat with unpadding kernel in Fp8Padding and Fp8Unpadding
3. Add unpadding with padding unit tests

Signed-off-by: xiaoxi-wangfj <690912414@qq.com>
@xiaoxi-wangfj xiaoxi-wangfj changed the title [PyTorch|common] Implement unpadding kernel for FP8 [PyTorch|common] Optimize unpadding kernel for FP8 Jun 11, 2025
xiaoxi-wangfj and others added 4 commits June 12, 2025 15:06
Signed-off-by: Xin Yao <xiny@nvidia.com>
Signed-off-by: Xin Yao <xiny@nvidia.com>
@yaox12
Copy link
Member

yaox12 commented Jun 24, 2025

/te-ci

@yaox12
Copy link
Member

yaox12 commented Jun 25, 2025

/te-ci

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