Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
Signed-off-by: Cheng, Penghui <penghui.cheng@intel.com>
  • Loading branch information
PenghuiCheng committed Jan 17, 2024
1 parent ed873c9 commit de190fd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/neural_compressor/language-modeling/run_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,10 @@ def compute_metrics(eval_preds):
if optim_args.apply_quantization and optim_args.quantization_approach in {"static", "dynamic", "weight_only"}:
model = trainer.model if isinstance(trainer.model, PreTrainedModel) else trainer.model._model
quantizer = INCQuantizer.from_pretrained(model)
if optim_args.quantization_approach != "dynamic":
if optim_args.quantization_approach in ["static", "weight_only"]:
num_calibration_samples = min(len(train_dataset), optim_args.num_calibration_samples)
train_dataset = train_dataset.select(range(num_calibration_samples))
if optim_args.quantization_approach == "static":
quantization_config.calibration_sampling_size = num_calibration_samples
quantization_config.calibration_sampling_size = num_calibration_samples

quantizer.quantize(
quantization_config=quantization_config,
Expand Down

0 comments on commit de190fd

Please sign in to comment.