| 559 | |
| 560 | |
| 561 | def modules_to_convert(prefix: str, fd_config: FDConfig): |
| 562 | import fnmatch |
| 563 | |
| 564 | if ( |
| 565 | hasattr(fd_config.model_config, "quantization_config") |
| 566 | and fd_config.model_config.quantization_config is not None |
| 567 | ): |
| 568 | if "modules_to_not_convert" in fd_config.model_config.quantization_config: |
| 569 | patterns = fd_config.model_config.quantization_config["modules_to_not_convert"] |
| 570 | for p in patterns: |
| 571 | if fnmatch.fnmatch(prefix, p) or fnmatch.fnmatch(prefix, p + ".*"): |
| 572 | return False |
| 573 | return True |
| 574 | else: |
| 575 | return True |