-
Notifications
You must be signed in to change notification settings - Fork 535
[OMNIML-5613] Quantize ResNet residual adds in torch ONNX example #2024
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?
Changes from 6 commits
664a7a3
28b2912
c15755c
d2a78de
77f2433
7cf4bf5
9cbcbbd
552ac54
edc43d4
7f3a6d7
4959049
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,13 +172,17 @@ def _quantize_conv_weights_to_fp8(graph: gs.Graph) -> int: | |
| 2. Quantize weights to FP8E4M3FN | ||
| 3. Insert a DequantizeLinear(fp8_weights, scale) before the Conv weight input | ||
|
|
||
| An RGB Conv that directly consumes an unquantized graph input is treated as a | ||
| filtered input stem and left entirely in high precision. | ||
|
|
||
| Args: | ||
| graph: The onnx-graphsurgeon graph to modify in-place. | ||
|
|
||
| Returns: | ||
| Number of Conv weight DQ nodes inserted. | ||
| """ | ||
| count = 0 | ||
| graph_inputs = {tensor.name for tensor in graph.inputs} | ||
|
|
||
| for node in list(graph.nodes): | ||
| if node.op != "Conv": | ||
|
|
@@ -189,7 +193,8 @@ def _quantize_conv_weights_to_fp8(graph: gs.Graph) -> int: | |
| weight_input = node.inputs[1] | ||
| if not isinstance(weight_input, gs.Constant): | ||
| continue | ||
|
|
||
| if node.inputs[0].name in graph_inputs and weight_input.values.shape[1] == 3: | ||
| continue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Keep the input-stem skip ResNet-specific. This skips FP8 weight DQ for any direct RGB Conv, while the Torch-side exclusion only applies to 🤖 Prompt for AI Agents |
||
| # Skip if weight already has a DQ producer | ||
| if any(out.op == "DequantizeLinear" for out in weight_input.outputs): | ||
| continue | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.