quic / aimet

AIMET is a library that provides advanced quantization and compression techniques for trained neural network models.
https://quic.github.io/aimet-pages/index.html
Other
2.16k stars 384 forks source link

Recursion error in QuantizationSimModel #3532

Open DongGeun123 opened 6 days ago

DongGeun123 commented 6 days ago

Traceback (most recent call last): model_quantizer.prepare_quantsim(dummy_input, args, dataset_builder.train_dataloader, tokenizer) self.create_quantsim(dummy_input=dummy_input) QuantizationSimModel( File "/usr/local/lib/python3.10/dist-packages/aimet_torch/quantsim.py", line 267, in init quantsim_configurator = self.configure_quantization_ops(config_file, default_output_bw, default_param_bw, File "/usr/local/lib/python3.10/dist-packages/aimet_torch/quantsim.py", line 1602, in configure_quantization_ops return QuantSimConfigurator(self.model, self.connected_graph, config_file, default_output_bw, File "/usr/local/lib/python3.10/dist-packages/aimet_torch/quantsim_config/quantsim_config.py", line 127, in init self._set_quantsim_configs() File "/usr/local/lib/python3.10/dist-packages/aimet_common/quantsim_config/quantsim_config.py", line 159, in _set_quantsim_configs self._set_supergroup_configs(self._quantsim_configs[ConfigDictKeys.SUPERGROUPS]) File "/usr/local/lib/python3.10/dist-packages/aimet_torch/quantsim_config/quantsim_config.py", line 510, in _set_supergroup_configs conv_bn_pairs = find_scale_foldable_bns(self._conn_graph) File "/usr/local/lib/python3.10/dist-packages/aimet_torch/quantsim_config/quantsim_config.py", line 507, in find_scale_foldable_bns graph_searcher.find_all_patterns_in_graph_apply_actions() File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_searcher.py", line 206, in find_all_patterns_in_graph_apply_actions GraphSearcher._find_patterns_apply_actions(self, op, pattern_matcher, File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_searcher.py", line 167, in _find_patterns_apply_actions GraphSearcher._find_patterns_apply_actions(self, consumer, pattern_matcher, File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_searcher.py", line 167, in _find_patterns_apply_actions GraphSearcher._find_patterns_apply_actions(self, consumer, pattern_matcher, File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_searcher.py", line 167, in _find_patterns_apply_actions GraphSearcher._find_patterns_apply_actions(self, consumer, pattern_matcher, [Previous line repeated 980 more times] File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_searcher.py", line 145, in _find_patterns_apply_actions matched_patterns_start_indices_dict = pattern_matcher.get_matching_patterns(op_types_sliding_window) File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_pattern_matcher.py", line 179, in get_matching_patterns return self._get_all_sliced_patterns_and_match(sliding_window_op_type_pattern) File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_pattern_matcher.py", line 156, in _get_all_sliced_patterns_and_match found_match, matched_pattern = self._get_matched_sliced_pattern(sliced_pattern) File "/usr/local/lib/python3.10/dist-packages/aimet_common/graph_pattern_matcher.py", line 113, in _get_matched_sliced_pattern if s_pattern == pattern_with_callback.pattern: RecursionError: maximum recursion depth exceeded in comparison

quic-geunlee commented 3 days ago

Hi @DongGeun123 Would you like to try the following code snippet before instantiating the QuantizationSimModel?

import sys
sys.setrecursionlimit(10**6)