Fix: Handle LowLevelZeroPlugin with use_fp8=True - #6419
Closed
Truong5724 wants to merge 3 commits into
Closed
Truong5724 wants to merge 3 commits into
Truong5724 wants to merge 3 commits into
Conversation
for more information, see https://pre-commit.ci
Collaborator
|
Thanks for looking into the TorchDynamo issue with the FP8 linear layer. Unfortunately we can't take this approach: dequantizing to the output dtype and using a regular matmul removes the FP8 compute path entirely, so every FP8 user loses the speed and memory benefit of The root cause is that newer PyTorch versions return a Tensor instead of a tuple from Closing this in favor of that fix. Thanks again for the report! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Checklist before creating the PR
[doc/gemini/tensor/...]: A concise descriptionpip install pre-commit && pre-commit install🚨 Issue number
Fixed #6387
📝 What does this PR do?
Problem
main.pyin the linked issue), execution fails during the forward/backward passes with a runtime error:The issue above comes from incompatibility between FakeTensor (used by TorchDynamo) and
torch._scaled_mm().FakeTensor only tracks metadata (shape, dtype, device) and requires all operations to be traceable without real data. However,
_scaled_mm()is a low-level kernel that depends on real tensor data and does not support FakeTensor.As a result, TorchDynamo cannot correctly trace this operation, leading to runtime errors such as shape mismatch.
Solution
To ensure compatibility with TorchDynamo (FakeTensor), this PR removes the dependency on
torch._scaled_mm()and replaces it with explicit dequantization + standard matrix multiplication (edit infp8.py).1. Forward pass
Original implementation:
Replaced with:
2. Backward pass
Original implementation:
Replaced with:
Implications
_scaled_mm(), which is not FakeTensor-safe.Verification
_scaled_mm().💥 Checklist before requesting a review
⭐️ Do you enjoy contributing to Colossal-AI?