Skip to content

ONNX QCDQ Export Fails for Pytorch 2.9.0+cpu and dynamo=True #1396

Description

@JP-Amboage

Trying to export a Quant model with export_onnx_qcdq and dynamo=True results in the following error when using Pytorch 2.9.0+cpu :

<class 'RuntimeError'>: Cannot access data pointer of Tensor (e.g. FakeTensor, FunctionalTensor). If you're using torch.compile/export/fx, it is likely that we are erroneously tracing into a custom kernel. To fix this, please wrap the custom kernel into an opaque custom op. Please see the following for details: https://pytorch.org/tutorials/advanced/custom_ops_landing_page.html

(Refer to the full stack trace above for more information.)

The same error is produced when dynamo is not explicitly set in the call to export_onnx_qcdq.

I provide the file needed to create the environment to reproduce the issue issue-env.yaml and a jupyter notebook issue.ipynb with the code that causes the issue and the error message visible in the output cells.

Finally here is a simple code snippet where the problem happens:

import torch
import brevitas.nn as qnn
from brevitas.export import export_onnx_qcdq

IN_CH = 3
OUT_CH = 128
BATCH_SIZE = 1

linear = qnn.QuantLinear(IN_CH, OUT_CH, bias=True)
inp = torch.randn(BATCH_SIZE, IN_CH)
path = 'quant_linear_qcdq.onnx'

exported_model = export_onnx_qcdq(linear, args=inp, export_path=path, opset_version=13)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

next releasePRs which should be merged for the next release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions