intel-extension-for-pytorch
intel-extension-for-pytorch copied to clipboard
Typos in Documentation (github io)
Describe the issue
Typos and notes in this code sample.
- In the "stage 2" section you have a typo -> ipex.llm.ptimize shoudl be -> ipex.llm.optimize
- You have these "#noqa F401" sections are not helpful for a user and make the sample hard to read. Can you remove those?
import torch
#################### code changes #################### # noqa F401
import intel_extension_for_pytorch as ipex
from intel_extension_for_pytorch.quantization import prepare
###################################################### # noqa F401
import transformers
# load model
model = transformers.AutoModelForCausalLM.from_pretrained(...).eval()
#################### code changes #################### # noqa F401
qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping()
# stage 1: calibration
# prepare your calibration dataset samples
calib_dataset = DataLoader(your_calibration_dataset)
example_inputs = ... # get one sample input from calib_samples
calibration_model = ipex.llm.optimize(
model.eval(),
quantization_config=qconfig,
)
prepared_model = prepare(
calibration_model.eval(), qconfig, example_inputs=example_inputs
)
with torch.no_grad():
for calib_samples in enumerate(calib_dataset):
prepared_model(calib_samples)
prepared_model.save_qconf_summary(qconf_summary=qconfig_summary_file_path)
# stage 2: quantization
model = ipex.llm.ptimize(
model.eval(),
quantization_config=qconfig,
qconfig_summary_file=qconfig_summary_file_path,
)
###################################################### # noqa F401
# generation inference loop
with torch.inference_mode():
model.generate({your generate parameters})
Thanks for bringing this up! We'll fix this
@eduand-alvarez Hi, I have submitted internal PR for fixing the typo. However, we will not be able to remove the "#noqa F401" at this time - as they are needed for code format checks.
Awesome, feel free to close.
Internal PR merged - updates will be refreshed soon.
@eduand-alvarez - Looks like the issue can only be closed from your side. Can you please close it? Thanks