-
Notifications
You must be signed in to change notification settings - Fork 614
[PyTorch] ONNX test fix + export for FP8 attention #2598
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Greptile OverviewGreptile SummaryFixed ONNX export for FP8 attention by addressing two key issues: Critical Bug Fix: The FP8 Attention Export Support: Added ONNX export capability for FP8 attention by:
Test Changes:
The implementation correctly separates ONNX export path from the training/inference path, using the quantizer's Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant DotProductAttention
participant no_torch_dynamo
participant FP8EmulationFunc
participant Quantizer
participant ONNX
User->>DotProductAttention: forward() with FP8 recipe
DotProductAttention->>no_torch_dynamo: Check if in ONNX export mode
alt ONNX Export Mode
no_torch_dynamo->>DotProductAttention: Return original function (Dynamo enabled)
DotProductAttention->>FP8EmulationFunc: forward(Q, K, V, quantizer)
FP8EmulationFunc->>FP8EmulationFunc: Detect ONNX export mode
FP8EmulationFunc->>FP8EmulationFunc: onnx_forward()
FP8EmulationFunc->>Quantizer: onnx_quantize(tensor)
Quantizer-->>FP8EmulationFunc: FP8 tensor
FP8EmulationFunc->>Quantizer: onnx_dequantize(fp8_tensor)
Quantizer-->>FP8EmulationFunc: Dequantized tensor
FP8EmulationFunc-->>DotProductAttention: Q', K', V' (emulated FP8)
DotProductAttention->>ONNX: Export graph with ONNX-compatible ops
ONNX-->>User: Exported ONNX model
else Normal Training/Inference
no_torch_dynamo->>DotProductAttention: Return disabled function (Dynamo disabled)
DotProductAttention->>FP8EmulationFunc: forward(Q, K, V, quantizer)
FP8EmulationFunc->>FP8EmulationFunc: Regular forward path
FP8EmulationFunc->>Quantizer: quantize(tensor) via combine_and_quantize
Quantizer-->>FP8EmulationFunc: FP8 tensor
FP8EmulationFunc->>Quantizer: dequantize(fp8_tensor) via combine_and_dequantize
Quantizer-->>FP8EmulationFunc: Dequantized tensor
FP8EmulationFunc-->>DotProductAttention: Q', K', V' (emulated FP8)
DotProductAttention-->>User: Attention output
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No files reviewed, no comments
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
|
/te-ci pytorch L1 |
Description
no_torch_dynamodecorator, which results in errors for newest PyTorch. The decorator was not correctly disabled during export to onnx.Fixes #2588
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: