Skip to content

Commit dd5a4df

Browse files
authored
Merge branch 'master' into xinhe/mx_recipe
2 parents 8600f2f + a9bdec7 commit dd5a4df

File tree

12 files changed

+113
-4
lines changed

12 files changed

+113
-4
lines changed

.azure-pipelines/scripts/ut/3x/coverage.3x_pt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[run]
22
branch = True
33

4+
[paths]
5+
source =
6+
neural_compressor/
7+
*/site-packages/neural_compressor/
8+
*/dist-packages/neural_compressor/
9+
410
[report]
511
include =
612
*/neural_compressor/common/*

.azure-pipelines/scripts/ut/3x/coverage.3x_pt_fp8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[run]
22
branch = True
33

4+
[paths]
5+
source =
6+
neural_compressor/
7+
*/site-packages/neural_compressor/
8+
*/dist-packages/neural_compressor/
9+
410
[report]
511
include =
612
*/neural_compressor/torch/algorithms/fp8_quant/*

.azure-pipelines/scripts/ut/3x/coverage.3x_tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[run]
22
branch = True
33

4+
[paths]
5+
source =
6+
neural_compressor/
7+
*/site-packages/neural_compressor/
8+
*/dist-packages/neural_compressor/
9+
410
[report]
511
include =
612
*/neural_compressor/common/*

.azure-pipelines/ut-3x-pt-fp8.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pr:
1212
- .azure-pipelines/scripts/install_nc.sh
1313
- .azure-pipelines/ut-3x-pt-fp8.yml
1414
- .azure-pipelines/template/docker-template.yml
15+
- .azure-pipelines/scripts/ut/3x/coverage.3x_pt_fp8
1516
- neural_compressor/common
1617
- neural_compressor/torch
1718
- neural_compressor/transformers

.azure-pipelines/ut-3x-pt.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pr:
1919
- .azure-pipelines/template/docker-template.yml
2020
- .azure-pipelines/scripts/install_nc.sh
2121
- .azure-pipelines/scripts/ut/3x/run_3x_pt.sh
22+
- .azure-pipelines/scripts/ut/3x/coverage.3x_pt
2223

2324
pool: ICX-16C
2425

.azure-pipelines/ut-3x-tf.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pr:
1616
- requirements_tf.txt
1717
- .azure-pipelines/scripts/ut/3x/run_3x_tf.sh
1818
- .azure-pipelines/template/docker-template.yml
19+
- .azure-pipelines/scripts/ut/3x/coverage.3x_tf
1920

2021
pool: ICX-16C
2122

neural_compressor/mix_precision.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from .model import Model
3030
from .strategy import STRATEGIES
3131
from .utils import alias_param, logger
32-
from .utils.utility import CpuInfo, time_limit
32+
from .utils.utility import CpuInfo, secure_check_eval_func, time_limit
3333

3434

3535
@alias_param("conf", param_alias="config")
@@ -91,6 +91,8 @@ def fit(model, conf, eval_func=None, eval_dataloader=None, eval_metric=None, **k
9191
)
9292
sys.exit(0)
9393

94+
secure_check_eval_func(eval_func)
95+
9496
wrapped_model = Model(model, conf=conf)
9597

9698
precisions = list(set(conf.precisions) - set(conf.excluded_precisions))

neural_compressor/quantization.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .model import Model
2828
from .strategy import STRATEGIES
2929
from .utils import logger
30-
from .utils.utility import dump_class_attrs, time_limit
30+
from .utils.utility import dump_class_attrs, secure_check_eval_func, time_limit
3131

3232

3333
def fit(
@@ -153,6 +153,8 @@ def eval_func(model):
153153
else:
154154
metric = None
155155

156+
secure_check_eval_func(eval_func)
157+
156158
config = _Config(quantization=conf, benchmark=None, pruning=None, distillation=None, nas=None)
157159
strategy_name = conf.tuning_criterion.strategy
158160

neural_compressor/torch/export/pt2e_export.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313
# limitations under the License.
1414
"""Export model for quantization."""
1515

16+
from functools import partial
1617
from typing import Any, Dict, Optional, Tuple, Union
1718

1819
import torch
1920
from torch.fx.graph_module import GraphModule
2021

2122
from neural_compressor.common.utils import logger
22-
from neural_compressor.torch.utils import TORCH_VERSION_2_2_2, TORCH_VERSION_2_7_0, get_torch_version, is_ipex_imported
23+
from neural_compressor.torch.utils import (
24+
TORCH_VERSION_2_2_2,
25+
TORCH_VERSION_2_7_0,
26+
TORCH_VERSION_2_8_0,
27+
get_torch_version,
28+
is_ipex_imported,
29+
)
2330

2431
__all__ = ["export", "export_model_for_pt2e_quant"]
2532

@@ -52,7 +59,10 @@ def export_model_for_pt2e_quant(
5259
# Note 1: `capture_pre_autograd_graph` is also a short-term API, it will be
5360
# updated to use the official `torch.export` API when that is ready.
5461
cur_version = get_torch_version()
55-
if cur_version >= TORCH_VERSION_2_7_0:
62+
if cur_version >= TORCH_VERSION_2_8_0:
63+
export_func = torch.export.export
64+
export_func = partial(export_func, strict=True)
65+
elif cur_version >= TORCH_VERSION_2_7_0:
5666
export_func = torch.export.export_for_training
5767
else:
5868
export_func = torch._export.capture_pre_autograd_graph

neural_compressor/torch/utils/environ.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def get_ipex_version():
152152

153153
TORCH_VERSION_2_2_2 = Version("2.2.2")
154154
TORCH_VERSION_2_7_0 = Version("2.7.0")
155+
TORCH_VERSION_2_8_0 = Version("2.8.0")
155156

156157

157158
def get_torch_version():

0 commit comments

Comments
 (0)