microsoft / nni

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
https://nni.readthedocs.io
MIT License
13.99k stars 1.81k forks source link

assert len(set(num_channels_list)) == 1 #4160

Open jxncyym opened 3 years ago

jxncyym commented 3 years ago

Describe the issue: I compress the model: https://github.com/chenjun2hao/DDRNet.pytorch

when add this code "pruner._unwrap_model()", meet the error

Traceback (most recent call last): File "/algdata02/yiming.yu/DDRNet.pytorch_pruner/tools/pruner_nni_L1filter.py", line 142, in main() File "/algdata02/yiming.yu/DDRNet.pytorch_pruner/tools/pruner_nni_L1filter.py", line 130, in main m_speedup.speedup_model() File "/algdata02/yiming.yu/DDRNet.pytorch_pruner/envp_3/lib/python3.6/site-packages/nni/compression/pytorch/speedup/compressor.py", line 500, in speedup_model fix_mask_conflict(self.masks, self.bound_model, self.dummy_input) File "/algdata02/yiming.yu/DDRNet.pytorch_pruner/envp_3/lib/python3.6/site-packages/nni/compression/pytorch/utils/mask_conflict.py", line 50, in fix_mask_conflict masks = fix_channel_mask.fix_mask() File "/algdata02/yiming.yu/DDRNet.pytorch_pruner/envp_3/lib/python3.6/site-packages/nni/compression/pytorch/utils/mask_conflict.py", line 259, in fix_mask assert len(set(num_channels_list)) == 1 AssertionError

Environment:

Configuration:

Log message:

How to reproduce it?:

flyingmrwang commented 3 years ago

the same for speedup pruned ghostnet, and the num channels are 16 and 1

J-shang commented 3 years ago

Hi @jxncyym @flyingmrwang , If possible, could you provide the model and pruning code for our reproduction?

jxncyym commented 3 years ago

@J-shang the latest code refer to :https://pan.baidu.com/s/19xoJOC9yaD3E6-RkZkOf9Q,g4og

J-shang commented 3 years ago

This dependency set leads to error, but from the model structure, it seems that they should not be in the same group.

{'spp.scale2.3': 128, 'spp.scale4.3': 128, 'spp.scale0.2': 128, 'layer5.0.conv3': 512, 'spp.process1.2': 128, 'layer5.0.downsample.0': 512, 'spp.process2.2': 128, 'spp.scale1.3': 128, 'spp.scale3.3': 128, 'spp.process3.2': 128}

line 174 in ddrnet_23_slim.py out = self.compression(torch.cat(x_list, 1)) + self.shortcut(x)

Seems the dependency is related to this line.

@zheng-ningxin please help to look into this issue.

jxncyym commented 3 years ago

Is there any progress @zheng-ningxin @J-shang

zheng-ningxin commented 3 years ago

The size operation on the graph misleads the model topology analysis. image

jxncyym commented 3 years ago

then how to solve this problem?@zheng-ningxin

zheng-ningxin commented 3 years ago

I'll submit a PR to fix this ASAP. I'll let you know when this pr merged. Thanks!

vinhtq115 commented 2 years ago

I'll submit a PR to fix this ASAP. I'll let you know when this pr merged. Thanks!

Have you been able to fix this? I have the same issue with YOLOv5-Face yolov5n-0.5 model.

HappyPeanuts commented 2 years ago

I have meet the same problem:'assert len(set(num_channels_list)) == 1' when i try to prune my model DLASeg, i want to know how to resove it~ thanks a lot

HappyPeanuts commented 2 years ago

I'll submit a PR to fix this ASAP. I'll let you know when this pr merged. Thanks!

Hi, have you resolved this problem? I have meet the same error and I guess it was caused by the use of DCNv2. I want to now how to resolve this problem. Thanks ~

zheng-ningxin commented 2 years ago

@HappyPeanuts Sincerely sorry for the late PR, already working on this pr and need some time. Thanks~

HappyPeanuts commented 2 years ago

thank you for your reply,I will try other methods,if convenient ,please notice me when you resolved this problem 

发自我的iPhone

------------------ Original ------------------ From: Ningxin Zheng @.> Date: Mon,Feb 28,2022 4:49 PM To: microsoft/nni @.> Cc: 杨志伟 @.>, Mention @.> Subject: Re: [microsoft/nni] assert len(set(num_channels_list)) == 1 (#4160)

@HappyPeanuts Sincerely sorry for the late PR, already working on this pr and need some time. Thanks~

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

HK017 commented 2 years ago

@zheng-ningxin,hello, What does this code assert len(set(num_channels_list)) == 1 mean for me to examine my own model structure? thanks

dianxin556 commented 1 year ago

I also meet the same problem , so how to solve it?

dreamlychina commented 1 year ago

I also meet the same problem , so how to solve it?

J-shang commented 1 year ago

hello @dianxin556 @dreamlychina , could you show your model for us to reproduce your issue? This problem is highly related to the model structure.