ModelTC / MQBench

Model Quantization Benchmark
Apache License 2.0
760 stars 137 forks source link

AttributeError: 'NoneType' object has no attribute 'detach' #264

Closed shenxiaozheng closed 7 months ago

shenxiaozheng commented 1 year ago

16, 16, kernel_size=(1, 3), stride=(1, 2), padding=(0, 1), groups=16, bias=False (weight_fake_quant): TqtFakeQuan... File "/home/test/anaconda3/envs/python3.9_torch1.10_mqbench/lib/python3.9/site-packages/torch-1.10.0-py3.9-linux-x86_64.egg/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) │ │ └ {} │ └ (None,) └ <bound method TqtFakeQuantize.forward of TqtFakeQuantize( fake_quant_enabled=tensor([0], dtype=torch.uint8), observer_enabl... File "/home/test/anaconda3/envs/python3.9_torch1.10_mqbench/lib/python3.9/site-packages/MQBench-0.0.6-py3.9.egg/mqbench/fake_quantize/tqt.py", line 29, in forward self.activation_post_process(X.detach()) │ └ None └ TqtFakeQuantize( fake_quant_enabled=tensor([0], dtype=torch.uint8), observerenabled=tensor([1], dtype=torch.uint8), quant...

AttributeError: 'NoneType' object has no attribute 'detach'

一直报这个错误,我使用的是ptq方法,代码没有问题,求指点

BrotherHappy commented 1 year ago

这个仓库是不是被放弃了?

shenxiaozheng commented 1 year ago

应该是放弃了,很多年没有人维护了。

ThistleInTheSun commented 1 year ago

@shenxiaozheng 求教,这个问题您后来是怎么解决的?

shenxiaozheng commented 1 year ago

@ThistleInTheSun 你也遇到了这个问题吗?这个问题就是mqbench内部的bug,有些计算图没法跟踪,造成了出现none的问题。

ThistleInTheSun commented 1 year ago

@shenxiaozheng 我现在打听到的方法是,用参数配置来控制,让这些不支持的操作不要插入伪节点。 (这里有参数配置说明:https://mqbench.readthedocs.io/en/latest/get_started/quick_start_academic.html

shenxiaozheng commented 1 year ago

@ThistleInTheSun 你给的文档我打不开,但是之前的经验是修改leaf节点,或者模型各层debug。

ThistleInTheSun commented 12 months ago

@shenxiaozheng 事实证明,我上面说的参数配置方法也没有效果。 最终的解决方法是,在 model 经过了 prepare_by_platform(插入伪节点) 之后,打印出 model.code(这里面是插入伪节点之后的 forward 函数代码),然后阅读这段打印出来的代码,找到报错的部分,修改报错位置对应的原始模型的代码。

github-actions[bot] commented 8 months ago

This issue has not received any updates in 120 days. Please reply to this issue if this still unresolved!