aimet icon indicating copy to clipboard operation
aimet copied to clipboard

when i quant yolov11 with aimet_torch,i get an error in aimet_torch/meta/connectedgraph.py,it is KeyError: '1'

Open 742671920 opened this issue 1 year ago • 4 comments

When the activation function layer is not relu, there is a problem with the dictionary parsed by connectedgraph. At this time, a KeyError: '1' will be reported. I have modified the source code as follows. I don't know if such modifications will affect quantization. Can the official pay attention to this issue

if not (input_name in node_name_to_module.keys()): op_type = inputs[0].type() if "activation" in str(op_type): # in "torch.torch.nn.modules.activation.___torch_mangle_380.SiLU" node_name_to_module[input_name] = residing_module.act

742671920 avatar Aug 26 '25 07:08 742671920

@742671920 Thanks for reporting this issue! Could you please share the complete error trace and let us know which version of aimet-torch you are using? From your description, it seems that the graph parsing logic in aimet-torch is failing to correctly identify the SiLU activation layer.

quic-hitameht avatar Aug 26 '25 22:08 quic-hitameht

@742671920 Thanks for reporting this issue! Could you please share the complete error trace and let us know which version of aimet-torch you are using? From your description, it seems that the graph parsing logic in aimet-torch is failing to correctly identify the SiLU activation layer.

my aimet-torch==2.12.0 and torch==2.8.0

742671920 avatar Aug 27 '25 03:08 742671920

Also, I could not find an implementation of torch.cat in the file aimet_torch/v2/nn/base.py, which caused another problem, the network layer inherited from torch.cat could not be quantified, and the error type was: Aimet_torch. V2. Nn. Base. UnknownModuleError, whether I can be in accordance with nn. ReLu method to define the above two methods to solve I met error: UnknownModuleError, or prepare_model maybe solve the problem?

742671920 avatar Aug 27 '25 05:08 742671920

We no longer recommend using prepare_model, as it relies on torch.fx under the hood, which has several limitations when parsing PyTorch graphs. Instead, we recommend switching to aimet-onnx.

Could you please share minimal script to repro above issue? We will we fix for aimet-torch In the meantime, could you please try aimet-onnx instead?

You can install it via:

pip install aimet-onnx

You'll need to export your model to ONNX format, but the rest of the workflow remains the same.

quic-hitameht avatar Aug 27 '25 17:08 quic-hitameht