PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
reorg file and make tiny change
wenhuach21c1d52eaa174f
diff --git a/autoround/README.md b/README.mdsimilarity index 94%rename from autoround/README.mdrename to README.mdindex 95b5e59f6..2cebacfe1 100644--- a/autoround/README.md+++ b/README.md@@ -22,7 +22,7 @@ AutoRound is an advanced weight-only quantization algorithm, based on SignRound.| THUDM/chatglm3-6b | 4.34/4.36 || mistralai/Mistral-7B-v0.1 | 4.34/4.36 |- Please note that all experiments in the SignRound+ technical report were conducted using transformers version 4.34.1.+Please note that all experiments in the SignRound+ technical report were conducted using transformers version 4.34.1.@@ -33,6 +33,8 @@ pip install -r requirements.txt```## Usage+cd to examples folder+- **Default Settings:**```bashCUDA_VISIBLE_DEVICES=0 python3 main.py --model_name facebook/opt-125m --amp --num_bits 4 --group_size -1 --enable_minmax_tuning --use_quant_input@@ -51,8 +53,6 @@ CUDA_VISIBLE_DEVICES=0 python3 main.py --model_name facebook/opt-125m --amp --nuIt's recommended to use `--enable_minmax_tuning`.-detailed arguments:-- `--model_name`: the local model path or huggingface format.## TipsConsider increasing tuning steps and adjusting the learning rate based on a scaling law to achieve better results, albeit with increased tuning time. For instance, at step 800, a learning rate of 0.00125 could be employed.diff --git a/auto_round/__init__.py b/auto_round/__init__.pynew file mode 100644index 000000000..b3aec764e--- /dev/null+++ b/auto_round/__init__.py@@ -0,0 +1,14 @@+# Copyright (c) 2023 Intel Corporation+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+from .autoround import AutoRound, AutoAdamRound, AutoOPTRounddiff --git a/autoround/src/autoround.py b/auto_round/autoround.pysimilarity index 99%rename from autoround/src/autoround.pyrename to auto_round/autoround.pyindex 03c834c9f..dd9e37b81 100644--- a/autoround/src/autoround.py+++ b/auto_round/autoround.py@@ -14,19 +14,13 @@import logging--logging.basicConfig(level=logging.INFO,- format=('%(filename)s: '- '%(levelname)s: '- '%(funcName)s(): '- '%(lineno)d:\t'- '%(message)s')- )-import torch-logger = logging.getLogger()-+logger = logging.getLogger("autoround")+fh = logging.StreamHandler()+fh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(filename)s L%(lineno)d : %(message)s', "%Y-%m-%d %H:%M:%S")+fh.setFormatter(fh_formatter)+logger.addHandler(fh)import copyimport timefrom collections import UserDict@@ -1049,7 +1043,7 @@ class AutoRound(object):Returns:The specified optimizer."""- from .sign_sgd import SGD+ from sign_sgd import SGDreturn SGDdiff --git a/autoround/src/sign_sgd.py b/auto_round/sign_sgd.pysimilarity index 100%rename from autoround/src/sign_sgd.pyrename to auto_round/sign_sgd.pydiff --git a/auto_round/version.py b/auto_round/version.pynew file mode 100644index 000000000..1a1828052--- /dev/null+++ b/auto_round/version.py@@ -0,0 +1,15 @@+# Copyright (c) 2023 Intel Corporation+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Intel® auto-round: An open-source Python library supporting popular model weight only compression based on signround."""+__version__ = "0.1"\ No newline at end of filediff --git a/autoround/src/__init__.py b/autoround/src/__init__.pydeleted file mode 100644index e69de29bb..000000000diff --git a/autoround/eval/__init__.py b/examples/eval/__init__.pysimilarity index 100%rename from autoround/eval/__init__.pyrename to examples/eval/__init__.pydiff --git a/autoround/eval/eval.py b/examples/eval/eval.pysimilarity index 99%rename from autoround/eval/eval.pyrename to examples/eval/eval.pyindex 2ab94912b..61eeab142 100644--- a/autoround/eval/eval.py+++ b/examples/eval/eval.py@@ -3,14 +3,11 @@ import osos.environ["TOKENIZERS_PARALLELISM"] = "false"import os.pathimport torch-import torch.nn as nn-from parse_results import result_parser+from .parse_results import result_parserimport pprint-import jsonimport reimport shutilimport transformers-import timeEXT_TASKS = ['wikitext2', 'ptb', 'c4', 'ptb-new', 'c4-new']fewshots_dict = {}diff --git a/autoround/eval/parse_results.py b/examples/eval/parse_results.pysimilarity index 100%rename from autoround/eval/parse_results.pyrename to examples/eval/parse_results.pydiff --git a/autoround/eval/utils.py b/examples/eval/utils.pysimilarity index 100%rename from autoround/eval/utils.pyrename to examples/eval/utils.pydiff --git a/autoround/main.py b/examples/main.pysimilarity index 99%rename from autoround/main.pyrename to examples/main.pyindex 4307e141e..a1a0bb766 100644--- a/autoround/main.py+++ b/examples/main.py@@ -1,7 +1,7 @@import argparseimport sys-sys.path.insert(0, './')-from src.autoround import AutoRound, AutoAdamRound+sys.path.insert(0, '../')+from auto_round import AutoRound, AutoAdamRoundparser = argparse.ArgumentParser()import torchdiff --git a/autoround/requirements.txt b/examples/requirements.txtsimilarity index 90%rename from autoround/requirements.txtrename to examples/requirements.txtindex 25c5f5238..04d132ae6 100644--- a/autoround/requirements.txt+++ b/examples/requirements.txt@@ -1,10 +1,11 @@transformers==4.36.0torch==2.0.1git+https://github.com/EleutherAI/lm-evaluation-harness.git@008fc2a23245c40384f2312718433eeb1e0f87a9-fsspec==2023.9.2tiktokentransformers_stream_generatorpeftsentencepieceeinops+accelerate+datasetsdiff --git a/requirments.txt b/requirments.txtnew file mode 100644index 000000000..6cb975036--- /dev/null+++ b/requirments.txt@@ -0,0 +1,5 @@+transformers==4.36.0+torch==2.0.1+sentencepiece+accelerate+datasets\ No newline at end of file