-
Notifications
You must be signed in to change notification settings - Fork 199
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
Unwanted nodes during ONNX QCDQ export #1135
Comments
Thanks for this issue. I have an intuition. Can you try modifying the last line of the forward function from: return x + y to: return (x + y).value The idea is that a QuantTensor has extra hyper-parameters (scale, zero_point, etc.) that might cause unwanted nodes in the final ONNX graph. If that is the issue, it should NOT cause any difference in terms of final results. Calling |
Thanks a lot for the reply. It seems to have fixed the issue! Just one last question. Would only returning |
I'd recommend to call If you really want to have a QuantTensor as output and avoid the extra nodes in ONNX, a kind of hacky solution is to wrap your model just before export with a simple |
I am going to close this issue but feel free to add more comments if you have further questions related to this, and feel free to reach out if you face other problems with Brevitas. |
Hello Brevitas team,
I am currently trying to dynamically generate ONNX models based on model descriptions. The models are relatively constrained as of now and only Conv2d, MaxPool, FC and Add layers are supported. If the model I pass is sequential, the export in the QCDQ format works perfectly fine. However, once I add an
Add
layer unwanted/unexpected nodes are exported as well (see attached image ). At the beginning I though it might be due to my usage of custom quantizers (I constrain the scaling to po2). Nevertheless, the problem still exists even if I use the quantizers provided by Brevitas (Int8{Weight,Act}PerTensorFloat
).Do you know what could potentially cause this issue?
I created a static description of a model that I want to export, which looks as follows:
Thank you in advance.
Best regards,
Leo
P.S. I tested it with different Torch versions but still no change
The text was updated successfully, but these errors were encountered: