Skip to content

Fix FP8 Rowwise Gemm Compilation with Auto-functionalize V2 #3457

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

Closed
wants to merge 1 commit into from

Conversation

jwfromm
Copy link
Contributor

@jwfromm jwfromm commented Dec 5, 2024

Summary:
X-link: https://github.com/facebookresearch/FBGEMM/pull/541

Torch recently introduced auto_functionalized_v2, which makes custom functions pickier about how they are defined. Specifically, torch no longer allows optional preallocated outputs. A custom function must either allocate a tensor and return it, or directly write to a preallocated output and return nothing.

This conflicts with our impelemtnation of f8f8bf16_rowwise and could cause confusing behaviors or errors when compiled. The only solution is to split into two functions with correct signatures. This diff adds f8f8bf16_rowwise_out, which is a very thin wrapper that allows preallocated outputs. It's a bit annoying, but this should allow both versions of the function to compile correctly.

Differential Revision: D66795225

Summary:
X-link: facebookresearch/FBGEMM#541

Torch recently introduced auto_functionalized_v2, which makes custom functions pickier about how they are defined. Specifically, torch no longer allows optional preallocated outputs. A custom function must either allocate a tensor and return it, or directly write to a preallocated output and return nothing.

This conflicts with our impelemtnation of f8f8bf16_rowwise and could cause confusing behaviors or errors when compiled. The only solution is to split into two functions with correct signatures. This diff adds `f8f8bf16_rowwise_out`, which is a very thin wrapper that allows preallocated outputs. It's a bit annoying, but this should allow both versions of the function to compile correctly.

Differential Revision: D66795225
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D66795225

Copy link

netlify bot commented Dec 5, 2024

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit a66cef8
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/6750ff2384dbd30008fc8500
😎 Deploy Preview https://deploy-preview-3457--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 03129ae.

q10 pushed a commit to q10/FBGEMM that referenced this pull request Apr 10, 2025
)

Summary:
X-link: pytorch#3457

X-link: fairinternal/moviegen#800

Pull Request resolved: facebookresearch/FBGEMM#541

Torch recently introduced auto_functionalized_v2, which makes custom functions pickier about how they are defined. Specifically, torch no longer allows optional preallocated outputs. A custom function must either allocate a tensor and return it, or directly write to a preallocated output and return nothing.

This conflicts with our impelemtnation of f8f8bf16_rowwise and could cause confusing behaviors or errors when compiled. The only solution is to split into two functions with correct signatures. This diff adds `f8f8bf16_rowwise_out`, which is a very thin wrapper that allows preallocated outputs. It's a bit annoying, but this should allow both versions of the function to compile correctly.

Reviewed By: henryhu6, henrylhtsang, jiawenliu64

Differential Revision: D66795225

fbshipit-source-id: 7874421554f65e1c4d04a814c4d8115116f402d4
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.

2 participants