Dequantize index 1 exceeded reference node's arg length 1

rucky: <p><em>I used the from quantize_fx module to quantify my own model, the code is:</em></p>
<pre><code class="lang-auto">if name == "main":
    checkpoint1 = torch.load('/mnt/vox-cpk.pth.tar')
    with open('config/vox-256.yaml') as f:
        config = yaml.safe_load(f)
    kp_detector = KPDetector(**config['model_params']['kp_detector_params'],
        **config['model_params']['common_params'])
    if torch.cuda.is_available():
        kp_detector.to(cuda_device)
    kp_detector.load_state_dict(checkpoint1['kp_detector'])
    generator = OcclusionAwareGenerator(**config['model_params']['generator_params'],
        **config['model_params']['common_params'])
    if torch.cuda.is_available():
        generator.to(cuda_device)
    generator.load_state_dict(checkpoint1['generator'])
    train_params = config['train_params']

    model_fp32 = GeneratorFullModel(kp_detector, generator, None, train_params)
    
    model_to_quantize = copy.deepcopy(model_fp32)
    model_to_quantize.eval()
    qconfig = get_default_qconfig("fbgemm")
    qconfig_dict = {"": qconfig}
    prepared_model = prepare_fx(model_to_quantize, qconfig_dict)
    # calibrate(prepared_model, data_loader)
    quantized_model = convert_fx(prepared_model)
    print(quantized_model)
</code></pre>
<p><em>the GeneratorFullModel is consist of two separate models, and the error is:</em></p>
<ul>
<li>Traceback (most recent call last):</li>
<li>File “/home/lab239-5/users/wangxin/first-order-model-master/ccc.py”, line 115, in</li>
<li>quantized_model = convert_fx(prepared_model)</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/quantize_fx.py”, line 658, in convert_fx</li>
<li>return _convert_fx(</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/quantize_fx.py”, line 563, in _convert_fx</li>
<li>quantized = convert(</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/fx/convert.py”, line 754, in convert</li>
<li>model = lower_to_fbgemm(model, qconfig_map, node_name_to_scope)</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/fx/lower_to_fbgemm.py”, line 14, in lower_to_fbgemm</li>
<li>return _lower_to_native_backend(model, qconfig_map, node_name_to_scope)</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/fx/_lower_to_native_backend.py”, line 958, in _lower_to_native_backend</li>
<li>_lower_static_weighted_ref_functional(model, qconfig_map)</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/fx/_lower_to_native_backend.py”, line 606, in _lower_static_weighted_ref_functional</li>
<li>(q_node, relu_node, func_node) = _match_static_pattern(</li>
<li>File “/home/lab239-5/users/wangxin/anaconda3/envs/pytorch1.12.1/lib/python3.10/site-packages/torch/ao/quantization/fx/_lower_to_native_backend.py”, line 450, in _match_static_pattern</li>
<li>assert i &lt; len(ref_node.args),</li>
<li>AssertionError: Dequantize index 1 exceeded reference node’s arg length 1</li>
</ul>

Vasiliy_Kuznetsov: <p>this sounds like a bug, would you have a reproducible example?</p>

rucky: <p>okay, I try to quantify the generator of the FOM model (<a href="https://github.com/AliaksandrSiarohin/first-order-model" class="inline-onebox" rel="noopener nofollow ugc">GitHub - AliaksandrSiarohin/first-order-model: This repository contains the source code for the paper First Order Motion Model for Image Animation</a>),in order to reference on the CPU, and I meet this bug.</p>

rucky: <p>I can give you my code if you need, thanks</p>

rucky: <p>I upload my code on github.The link is <a href="https://github.com/wong00/Quantization-of-FOM-model" rel="noopener nofollow ugc">https://github.com/wong00/Quantization-of-FOM-model</a></p>

Vasiliy_Kuznetsov: <p>thank you for providing the repro, let’s discuss on <a href="https://github.com/pytorch/pytorch/issues/87686" class="inline-onebox" rel="noopener nofollow ugc">AssertionError: Dequantize index 1 exceeded reference node's arg length 1 · Issue #87686 · pytorch/pytorch · GitHub</a> just so the discussion is in one place</p>