Skip to content

Freeze IPEX version for INT8 SQ support #2221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ accelerate
protobuf
sentencepiece != 0.1.92
datasets >= 1.1.3
torch >= 1.10
torch == 2.7.0
transformers < 4.48.0 # TODO: ILITV-3858
pytest
wandb
Expand All @@ -11,4 +11,4 @@ neural-compressor
lm_eval <= 0.4.7
peft
optimum-intel
intel_extension_for_pytorch
intel_extension_for_pytorch == 2.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"--approach", type=str, default="static", help="Select from ['dynamic', 'static', 'weight-only']"
)
parser.add_argument("--optimized", action="store_true")
parser.add_argument("--autotune", action="store_true", help="Use autotune to find the best alpha for SmoothQuant.")
parser.add_argument("--ipex", action="store_true", help="Use intel extension for pytorch.")
parser.add_argument("--load", action="store_true", help="Load quantized model.")
parser.add_argument("--accuracy", action="store_true")
Expand Down Expand Up @@ -204,15 +205,25 @@ def eval_func(model):

example_inputs = get_example_inputs(user_model, calib_dataloader)

from neural_compressor.torch.quantization import SmoothQuantConfig, autotune, TuningConfig
tune_config = TuningConfig(config_set=SmoothQuantConfig.get_config_set_for_tuning())
user_model = autotune(
user_model,
tune_config=tune_config,
eval_fn=eval_func,
run_fn=run_fn,
example_inputs=example_inputs,
)
if args.autotune:
from neural_compressor.torch.quantization import SmoothQuantConfig, autotune, TuningConfig
tune_config = TuningConfig(config_set=SmoothQuantConfig.get_config_set_for_tuning())
user_model = autotune(
user_model,
tune_config=tune_config,
eval_fn=eval_func,
run_fn=run_fn,
example_inputs=example_inputs,
)
else:
from neural_compressor.torch.quantization import SmoothQuantConfig, prepare, convert
args.alpha = eval(args.alpha)
excluded_precisions = [] if args.int8_bf16_mixed else ["bf16"]
quant_config = SmoothQuantConfig(alpha=args.alpha, folding=False, excluded_precisions=excluded_precisions)

user_model = prepare(model=user_model, quant_config=quant_config, example_inputs=example_inputs)
run_fn(user_model)
user_model = convert(user_model)
user_model.save(args.output_dir)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ function run_tuning {
extra_cmd=$extra_cmd" --ipex --sq --alpha 0.5"
elif [ "${topology}" = "llama2_7b_ipex_sq" ]; then
model_name_or_path="meta-llama/Llama-2-7b-hf"
extra_cmd=$extra_cmd" --ipex --sq --alpha 0.8"
extra_cmd=$extra_cmd" --ipex --sq --alpha 0.65"
elif [ "${topology}" = "gpt_j_ipex_sq" ]; then
model_name_or_path="EleutherAI/gpt-j-6b"
extra_cmd=$extra_cmd" --ipex --sq --alpha 1.0"
extra_cmd=$extra_cmd" --ipex --sq --alpha 0.5"
fi

python -u run_clm_no_trainer.py \
Expand Down