diff --git a/.azure-pipelines/scripts/codeScan/codespell/inc_dict.txt b/.azure-pipelines/scripts/codeScan/codespell/inc_dict.txt index 91e466f168a..f96d82fb7e9 100644 --- a/.azure-pipelines/scripts/codeScan/codespell/inc_dict.txt +++ b/.azure-pipelines/scripts/codeScan/codespell/inc_dict.txt @@ -1,5 +1,6 @@ activ ans +assertin datas ende lates diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a467a878b6..92ff6c02d82 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer files: (.*\.(py|md|rst|yaml|yml))$ @@ -101,7 +101,7 @@ repos: )$ - repo: https://github.com/psf/black.git - rev: 24.3.0 + rev: 24.10.0 hooks: - id: black files: (.*\.py)$ @@ -115,12 +115,12 @@ repos: )$ - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 + rev: 1.19.1 hooks: - id: blacken-docs args: [--line-length=120, --skip-errors] additional_dependencies: - - black==24.3.0 + - black==24.10.0 exclude: | (?x)^( examples/.+| @@ -130,7 +130,7 @@ repos: )$ - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell args: [-w] @@ -149,7 +149,7 @@ repos: )$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.5 + rev: v0.8.6 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix, --no-cache] diff --git a/docs/source/CODE_OF_CONDUCT.md b/docs/source/CODE_OF_CONDUCT.md index 8d023b77469..7dde9603942 100644 --- a/docs/source/CODE_OF_CONDUCT.md +++ b/docs/source/CODE_OF_CONDUCT.md @@ -14,7 +14,7 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal +level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards diff --git a/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/data_utils.py b/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/data_utils.py index 6ceef9517df..e24a4351e7f 100644 --- a/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/data_utils.py +++ b/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/data_utils.py @@ -1241,7 +1241,7 @@ def loadDataset( data_ready = False # pre-process data if needed - # WARNNING: when memory mapping is used we get a collection of files + # WARNING: when memory mapping is used we get a collection of files if data_ready: print("Reading pre-processed data=%s" % (str(pro_data))) file = str(pro_data) diff --git a/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/dlrm_data_pytorch.py b/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/dlrm_data_pytorch.py index f6f30f8e663..0a4b29da5ab 100644 --- a/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/dlrm_data_pytorch.py +++ b/examples/3.x_api/pytorch/recommendation/dlrm/static_quant/ipex/dlrm_data_pytorch.py @@ -111,7 +111,7 @@ def __init__( data_ready = False # pre-process data if needed - # WARNNING: when memory mapping is used we get a collection of files + # WARNING: when memory mapping is used we get a collection of files if data_ready: print("Reading pre-processed data=%s" % (str(pro_data))) file = str(pro_data) diff --git a/examples/notebook/dynas/BERT_SST2_Supernet_NAS.ipynb b/examples/notebook/dynas/BERT_SST2_Supernet_NAS.ipynb index 604211ce32c..46f9e448307 100644 --- a/examples/notebook/dynas/BERT_SST2_Supernet_NAS.ipynb +++ b/examples/notebook/dynas/BERT_SST2_Supernet_NAS.ipynb @@ -189,7 +189,7 @@ "# Perform Search\n", "\n", "After the DyNAS configuration parameters are set, the search process can be started. Depending on how many evaluations `config.dynas.num_evals` were defined, the search time can vary from hours to days. \n", - "The search process will populate the `config.dynas.results_csv_path` file and will also return a list of the final iteration's best sub-network population recommondation. \n", + "The search process will populate the `config.dynas.results_csv_path` file and will also return a list of the final iteration's best sub-network population recommendation. \n", "\n", "Note: example search results are provided for the plotting section if you wish to skip this step for now. " ] diff --git a/examples/notebook/dynas/MobileNetV3_Supernet_NAS.ipynb b/examples/notebook/dynas/MobileNetV3_Supernet_NAS.ipynb index d678c1c13da..ae8929cc37a 100644 --- a/examples/notebook/dynas/MobileNetV3_Supernet_NAS.ipynb +++ b/examples/notebook/dynas/MobileNetV3_Supernet_NAS.ipynb @@ -191,7 +191,7 @@ "# Perform Search\n", "\n", "After the DyNAS configuration parameters are set, the search process can be started. Depending on how many evaluations `config.dynas.num_evals` were defined, the search time can vary from hours to days. \n", - "The search process will populate the `config.dynas.results_csv_path` file and will also return a list of the final iteration's best sub-network population recommondation. \n", + "The search process will populate the `config.dynas.results_csv_path` file and will also return a list of the final iteration's best sub-network population recommendation. \n", "\n", "Note: example search results are provided for the plotting section if you wish to skip this step for now. " ] diff --git a/examples/pytorch/nlp/huggingface_models/question-answering/distillation/eager/utils_qa.py b/examples/pytorch/nlp/huggingface_models/question-answering/distillation/eager/utils_qa.py index 8433cca2b77..484c0c87857 100644 --- a/examples/pytorch/nlp/huggingface_models/question-answering/distillation/eager/utils_qa.py +++ b/examples/pytorch/nlp/huggingface_models/question-answering/distillation/eager/utils_qa.py @@ -288,7 +288,7 @@ def postprocess_qa_predictions_with_beam_search( assert len(predictions[0]) == len( features - ), f"Got {len(predictions[0])} predicitions and {len(features)} features." + ), f"Got {len(predictions[0])} predictions and {len(features)} features." # Build a map example to its corresponding features. example_id_to_index = {k: i for i, k in enumerate(examples["id"])} diff --git a/examples/pytorch/nlp/huggingface_models/question-answering/optimization_pipeline/prune_once_for_all/fx/utils_qa.py b/examples/pytorch/nlp/huggingface_models/question-answering/optimization_pipeline/prune_once_for_all/fx/utils_qa.py index 8433cca2b77..484c0c87857 100644 --- a/examples/pytorch/nlp/huggingface_models/question-answering/optimization_pipeline/prune_once_for_all/fx/utils_qa.py +++ b/examples/pytorch/nlp/huggingface_models/question-answering/optimization_pipeline/prune_once_for_all/fx/utils_qa.py @@ -288,7 +288,7 @@ def postprocess_qa_predictions_with_beam_search( assert len(predictions[0]) == len( features - ), f"Got {len(predictions[0])} predicitions and {len(features)} features." + ), f"Got {len(predictions[0])} predictions and {len(features)} features." # Build a map example to its corresponding features. example_id_to_index = {k: i for i, k in enumerate(examples["id"])} diff --git a/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/fx/python/models/ssd_r34.py b/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/fx/python/models/ssd_r34.py index 1d7522acbe8..8bb0e89f89f 100644 --- a/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/fx/python/models/ssd_r34.py +++ b/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/fx/python/models/ssd_r34.py @@ -262,7 +262,7 @@ def __init__(self, label_num=81, backbone='resnet34', model_path="./resnet34-333 self.size=(1200,1200) dboxes = dboxes_R34_coco(list(self.size),[3,3,2,2,2,2]) self.encoder = Encoder(dboxes) - # intitalize all weights + # initialize all weights self._init_weights() self.device = 1 def _build_additional_features(self, input_channels): diff --git a/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd300.py b/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd300.py index 62446aaa048..8508180d1d3 100644 --- a/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd300.py +++ b/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd300.py @@ -41,7 +41,7 @@ def __init__(self, label_num, backbone='resnet34', model_path="./resnet34-333f7e self.loc = nn.ModuleList(self.loc) self.conf = nn.ModuleList(self.conf) - # intitalize all weights + # initialize all weights self._init_weights() def _build_additional_features(self, input_size, input_channels): diff --git a/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd_r34.py b/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd_r34.py index 3390e61f24c..b62eff7a28c 100644 --- a/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd_r34.py +++ b/examples/pytorch/object_detection/ssd_resnet34/quantization/ptq/ipex/ssd_r34.py @@ -65,7 +65,7 @@ def __init__(self, label_num, backbone='resnet34', model_path="./resnet34-333f7e self.loc = nn.ModuleList(self.loc) self.conf = nn.ModuleList(self.conf) - # intitalize all weights + # initialize all weights self._init_weights() def _build_additional_features(self, input_channels): diff --git a/examples/pytorch/object_detection/ssd_resnet34/quantization/qat/fx/ssd/ssd300.py b/examples/pytorch/object_detection/ssd_resnet34/quantization/qat/fx/ssd/ssd300.py index 83c364201a0..b4202d79296 100644 --- a/examples/pytorch/object_detection/ssd_resnet34/quantization/qat/fx/ssd/ssd300.py +++ b/examples/pytorch/object_detection/ssd_resnet34/quantization/qat/fx/ssd/ssd300.py @@ -40,7 +40,7 @@ def __init__(self, label_num, backbone='resnet34', model_path=None): self.loc = nn.ModuleList(self.loc) self.conf = nn.ModuleList(self.conf) - # intitalize all weights + # initialize all weights self._init_weights() def _build_additional_features(self, input_size, input_channels): diff --git a/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/data_utils.py b/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/data_utils.py index 00199cbcb4b..1cda5d8c0f1 100644 --- a/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/data_utils.py +++ b/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/data_utils.py @@ -1160,7 +1160,7 @@ def loadDataset( data_ready = False # pre-process data if needed - # WARNNING: when memory mapping is used we get a collection of files + # WARNING: when memory mapping is used we get a collection of files if data_ready: print("Reading pre-processed data=%s" % (str(pro_data))) file = str(pro_data) diff --git a/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/dlrm_data_pytorch.py b/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/dlrm_data_pytorch.py index 748947065cf..283cf8a4aac 100644 --- a/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/dlrm_data_pytorch.py +++ b/examples/pytorch/recommendation/dlrm/quantization/ptq/fx/dlrm_data_pytorch.py @@ -97,7 +97,7 @@ def __init__( data_ready = False # pre-process data if needed - # WARNNING: when memory mapping is used we get a collection of files + # WARNING: when memory mapping is used we get a collection of files if data_ready: print("Reading pre-processed data=%s" % (str(pro_data))) file = str(pro_data) diff --git a/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/data_utils.py b/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/data_utils.py index 6ceef9517df..e24a4351e7f 100644 --- a/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/data_utils.py +++ b/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/data_utils.py @@ -1241,7 +1241,7 @@ def loadDataset( data_ready = False # pre-process data if needed - # WARNNING: when memory mapping is used we get a collection of files + # WARNING: when memory mapping is used we get a collection of files if data_ready: print("Reading pre-processed data=%s" % (str(pro_data))) file = str(pro_data) diff --git a/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/dlrm_data_pytorch.py b/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/dlrm_data_pytorch.py index f6f30f8e663..0a4b29da5ab 100644 --- a/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/dlrm_data_pytorch.py +++ b/examples/pytorch/recommendation/dlrm/quantization/ptq/ipex/dlrm_data_pytorch.py @@ -111,7 +111,7 @@ def __init__( data_ready = False # pre-process data if needed - # WARNNING: when memory mapping is used we get a collection of files + # WARNING: when memory mapping is used we get a collection of files if data_ready: print("Reading pre-processed data=%s" % (str(pro_data))) file = str(pro_data) diff --git a/neural_compressor/adaptor/adaptor.py b/neural_compressor/adaptor/adaptor.py index cd03a1c4070..7f621a42b7c 100644 --- a/neural_compressor/adaptor/adaptor.py +++ b/neural_compressor/adaptor/adaptor.py @@ -49,7 +49,7 @@ def __init__(self, framework_specific_info): @abstractmethod def quantize(self, tune_cfg, model, dataloader, q_func=None): - """The function is used to do calibration and quanitization in post-training quantization. + """The function is used to do calibration and quantization in post-training quantization. Args: tune_cfg(dict): The chosen tuning configuration. diff --git a/neural_compressor/adaptor/mxnet.py b/neural_compressor/adaptor/mxnet.py index 57f28bbcbe6..b28364180ea 100644 --- a/neural_compressor/adaptor/mxnet.py +++ b/neural_compressor/adaptor/mxnet.py @@ -59,7 +59,7 @@ def __init__(self, framework_specific_info): @dump_elapsed_time("Pass quantize model") def quantize(self, tune_cfg, nc_model, dataloader, q_func=None): - """The function is used to do MXNet calibration and quanitization in post-training + """The function is used to do MXNet calibration and quantization in post-training quantization. Args: diff --git a/neural_compressor/adaptor/onnxrt.py b/neural_compressor/adaptor/onnxrt.py index a564b62086a..b3bf7a58c27 100644 --- a/neural_compressor/adaptor/onnxrt.py +++ b/neural_compressor/adaptor/onnxrt.py @@ -252,7 +252,7 @@ def _need_smooth_quant(self, tune_cfg) -> bool: @dump_elapsed_time("Pass quantize model") def quantize(self, tune_cfg, model, data_loader, q_func=None): - """The function is used to do calibration and quanitization in post-training + """The function is used to do calibration and quantization in post-training quantization. Args: @@ -1853,7 +1853,7 @@ def __init__(self, framework_specific_info): @dump_elapsed_time("Pass quantize model") def quantize(self, tune_cfg, model, data_loader, q_func=None): - """The function is used to do calibration and quanitization in post-training + """The function is used to do calibration and quantization in post-training quantization. Args: diff --git a/neural_compressor/adaptor/tf_utils/graph_util.py b/neural_compressor/adaptor/tf_utils/graph_util.py index 827d5521b9d..0591abb8247 100644 --- a/neural_compressor/adaptor/tf_utils/graph_util.py +++ b/neural_compressor/adaptor/tf_utils/graph_util.py @@ -212,7 +212,7 @@ def query_fusion_pattern_nodes(self, patterns=None): return self._search_patterns(patterns) def _search_patterns(self, input_pattern): - """Search user specified patterns on internal grpah structure. + """Search user specified patterns on internal graph structure. Args: input_pattern (list): The element of the pattern list could be string/list/tuple. diff --git a/neural_compressor/adaptor/torch_utils/hawq_metric.py b/neural_compressor/adaptor/torch_utils/hawq_metric.py index 86fbb022b95..c911eff125b 100644 --- a/neural_compressor/adaptor/torch_utils/hawq_metric.py +++ b/neural_compressor/adaptor/torch_utils/hawq_metric.py @@ -23,14 +23,11 @@ import logging import numpy as np -import torch.nn -import torch.nn as nn from torch.quantization.quantize_fx import fuse_fx logger = logging.getLogger(__name__) from typing import Any, Callable, Dict, List, Optional, Set, Union -import torch import tqdm diff --git a/neural_compressor/data/datasets/dummy_dataset_v2.py b/neural_compressor/data/datasets/dummy_dataset_v2.py index e7efe314dfe..67b75ba906d 100644 --- a/neural_compressor/data/datasets/dummy_dataset_v2.py +++ b/neural_compressor/data/datasets/dummy_dataset_v2.py @@ -236,7 +236,7 @@ def __init__( self.label_shape = len(self.dense_shape) * self.label_shape assert len(self.label_shape) == len( self.dense_shape - ), "length of dense_shape should be euqal to length of label_shape" + ), "length of dense_shape should be equal to length of label_shape" self.label_dim = len(self.label_shape) self.input_dim = 1 if isinstance(dense_shape, tuple) else len(dense_shape) diff --git a/neural_compressor/tensorflow/quantization/utils/graph_util.py b/neural_compressor/tensorflow/quantization/utils/graph_util.py index 3eb99baeccf..2e6a745366e 100644 --- a/neural_compressor/tensorflow/quantization/utils/graph_util.py +++ b/neural_compressor/tensorflow/quantization/utils/graph_util.py @@ -212,7 +212,7 @@ def query_fusion_pattern_nodes(self, patterns=None): return self._search_patterns(patterns) def _search_patterns(self, input_pattern): - """Search user specified patterns on internal grpah structure. + """Search user specified patterns on internal graph structure. Args: input_pattern (list): The element of the pattern list could be string/list/tuple.