Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

reorg file and make tiny change

wenhuach21c1d52eaa174f
diff --git a/autoround/README.md b/README.md
similarity index 94%
rename from autoround/README.md
rename to README.md
index 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:**
```bash
CUDA_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 --nu
It's recommended to use `--enable_minmax_tuning`.
-detailed arguments:
-- `--model_name`: the local model path or huggingface format.
## Tips
Consider 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__.py
new file mode 100644
index 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, AutoOPTRound
diff --git a/autoround/src/autoround.py b/auto_round/autoround.py
similarity index 99%
rename from autoround/src/autoround.py
rename to auto_round/autoround.py
index 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 copy
import time
from collections import UserDict
@@ -1049,7 +1043,7 @@ class AutoRound(object):
Returns:
The specified optimizer.
"""
- from .sign_sgd import SGD
+ from sign_sgd import SGD
return SGD
diff --git a/autoround/src/sign_sgd.py b/auto_round/sign_sgd.py
similarity index 100%
rename from autoround/src/sign_sgd.py
rename to auto_round/sign_sgd.py
diff --git a/auto_round/version.py b/auto_round/version.py
new file mode 100644
index 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 file
diff --git a/autoround/src/__init__.py b/autoround/src/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/autoround/eval/__init__.py b/examples/eval/__init__.py
similarity index 100%
rename from autoround/eval/__init__.py
rename to examples/eval/__init__.py
diff --git a/autoround/eval/eval.py b/examples/eval/eval.py
similarity index 99%
rename from autoround/eval/eval.py
rename to examples/eval/eval.py
index 2ab94912b..61eeab142 100644
--- a/autoround/eval/eval.py
+++ b/examples/eval/eval.py
@@ -3,14 +3,11 @@ import os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
import os.path
import torch
-import torch.nn as nn
-from parse_results import result_parser
+from .parse_results import result_parser
import pprint
-import json
import re
import shutil
import transformers
-import time
EXT_TASKS = ['wikitext2', 'ptb', 'c4', 'ptb-new', 'c4-new']
fewshots_dict = {}
diff --git a/autoround/eval/parse_results.py b/examples/eval/parse_results.py
similarity index 100%
rename from autoround/eval/parse_results.py
rename to examples/eval/parse_results.py
diff --git a/autoround/eval/utils.py b/examples/eval/utils.py
similarity index 100%
rename from autoround/eval/utils.py
rename to examples/eval/utils.py
diff --git a/autoround/main.py b/examples/main.py
similarity index 99%
rename from autoround/main.py
rename to examples/main.py
index 4307e141e..a1a0bb766 100644
--- a/autoround/main.py
+++ b/examples/main.py
@@ -1,7 +1,7 @@
import argparse
import sys
-sys.path.insert(0, './')
-from src.autoround import AutoRound, AutoAdamRound
+sys.path.insert(0, '../')
+from auto_round import AutoRound, AutoAdamRound
parser = argparse.ArgumentParser()
import torch
diff --git a/autoround/requirements.txt b/examples/requirements.txt
similarity index 90%
rename from autoround/requirements.txt
rename to examples/requirements.txt
index 25c5f5238..04d132ae6 100644
--- a/autoround/requirements.txt
+++ b/examples/requirements.txt
@@ -1,10 +1,11 @@
transformers==4.36.0
torch==2.0.1
git+https://github.com/EleutherAI/lm-evaluation-harness.git@008fc2a23245c40384f2312718433eeb1e0f87a9
-fsspec==2023.9.2
tiktoken
transformers_stream_generator
peft
sentencepiece
einops
+accelerate
+datasets
diff --git a/requirments.txt b/requirments.txt
new file mode 100644
index 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