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
14.06k stars 1.82k forks source link

nni norm_pruning example error #5660

Closed NoyLalzary closed 1 year ago

NoyLalzary commented 1 year ago

Hello! I am trying to locally run a pytorch version of one of the pruning examples (nni/examples/compression/pruning/norm_pruning.py). However, it seems that the config_list that is generate from the function "auto_set_denpendency_group_ids" has some problem.

The config_list is: [{'op_names': ['layer3.1.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '0152545ff8de4d14a8cfe727bf9769d1', 'internal_metric_block': 1}, {'op_names': ['layer1.0.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '5c913fb3076441e2af16c32c03758329', 'internal_metric_block': 1}, {'op_names': ['layer2.0.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '497a228f19e047d8a26fa94cc97fbabf', 'internal_metric_block': 1}, {'op_names': ['layer4.0.downsample.0'], 'sparse_ratio': 0.5, 'dependency_group_id': 'ea22b181139c4199b090c4e702d85083', 'internal_metric_block': 1}, {'op_names': ['layer3.1.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': '60ccd2e1a186412e89d256682007b2f7', 'internal_metric_block': 1}, {'op_names': ['layer4.1.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '70578023ad6e48c1b14ef44d5e6a0c3f', 'internal_metric_block': 1}, {'op_names': ['conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '01d9e39d16e94df4838ea98275f5d445', 'internal_metric_block': 1}, {'op_names': ['layer1.0.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': '01d9e39d16e94df4838ea98275f5d445', 'internal_metric_block': 1}, {'op_names': ['layer3.0.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '0cbb55f71a484d64b775d7d82380d0dd', 'internal_metric_block': 1}, {'op_names': ['layer4.0.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': 'ea22b181139c4199b090c4e702d85083', 'internal_metric_block': 1}, {'op_names': ['layer1.1.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': '01d9e39d16e94df4838ea98275f5d445', 'internal_metric_block': 1}, {'op_names': ['layer2.0.downsample.0'], 'sparse_ratio': 0.5, 'dependency_group_id': '3a2f40dea91340f296b0e40049ee1b57', 'internal_metric_block': 1}, {'op_names': ['layer2.1.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': 'aa5de9115c5141aeb1736ed8d9f479fd', 'internal_metric_block': 1}, {'op_names': ['layer4.1.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': 'ea22b181139c4199b090c4e702d85083', 'internal_metric_block': 1}, {'op_names': ['layer2.1.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': '3a2f40dea91340f296b0e40049ee1b57', 'internal_metric_block': 1}, {'op_names': ['layer3.0.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': '60ccd2e1a186412e89d256682007b2f7', 'internal_metric_block': 1}, {'op_names': ['layer4.0.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': '526922a4a69d4a46b2fdbf937f8283dc', 'internal_metric_block': 1}, {'op_names': ['layer1.1.conv1'], 'sparse_ratio': 0.5, 'dependency_group_id': 'f1dbbaba5cce46698e3efbcd84d48e4c', 'internal_metric_block': 1}, {'op_names': ['layer3.0.downsample.0'], 'sparse_ratio': 0.5, 'dependency_group_id': '60ccd2e1a186412e89d256682007b2f7', 'internal_metric_block': 1}, {'op_names': ['layer2.0.conv2'], 'sparse_ratio': 0.5, 'dependency_group_id': '3a2f40dea91340f296b0e40049ee1b57', 'internal_metric_block': 1}]

The error I get: Or(And({Or('sparsity', 'sparsity_per_layer'): And(<class 'float'>, <function at 0x7d11a9a048b0>), Optional('op_types'): And(['Conv2d', 'Linear'], <function CompressorSchema._modify_schema.. at 0x7d11a98b8ca0>), Optional('op_names'): And([<class 'str'>], <function CompressorSchema._modify_schema.. at 0x7d11a74cb520>), Optional('op_partial_names'): [<class 'str'>]}, <function CompressorSchema._modify_schema.. at 0x7d11a74cbeb0>), And({'exclude': <class 'bool'>, Optional('op_types'): And(['Conv2d', 'Linear'], <function CompressorSchema._modify_schema.. at 0x7d11a74cbe20>), Optional('op_names'): And([<class 'str'>], <function CompressorSchema._modify_schema.. at 0x7d11a74cbd90>), Optional('op_partial_names'): [<class 'str'>]}, <function CompressorSchema._modify_schema.. at 0x7d11a74cb490>), And({'total_sparsity': And(<class 'float'>, <function at 0x7d11a9a07be0>), Optional('max_sparsity_per_layer'): {<class 'str'>: <class 'float'>}, Optional('op_types'): And(['Conv2d', 'Linear'], <function CompressorSchema._modify_schema.. at 0x7d11a7429ea0>), Optional('op_names'): And([<class 'str'>], <function CompressorSchema._modify_schema.. at 0x7d11a7428790>)}, <function CompressorSchema._modify_schema.. at 0x7d11a7428430>)) did not validate {'op_names': ['layer3.1.conv1'], 'sparse_ratio': 0.5, 'dependenc... Missing key: Or('sparsity', 'sparsity_per_layer') Missing key: 'exclude' Missing key: 'total_sparsity'

Would be happy to understand what I am missing. Thanks a lot! Noy