intel-extension-for-pytorch icon indicating copy to clipboard operation
intel-extension-for-pytorch copied to clipboard

Typos in Documentation (github io)

Open eduand-alvarez opened this issue 1 year ago • 5 comments

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})

eduand-alvarez avatar Feb 26 '24 16:02 eduand-alvarez

Thanks for bringing this up! We'll fix this

kminhta avatar Feb 27 '24 22:02 kminhta

@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.

intel-ravig avatar Mar 05 '24 00:03 intel-ravig

Awesome, feel free to close.

eduand-alvarez avatar Mar 07 '24 21:03 eduand-alvarez

Internal PR merged - updates will be refreshed soon.

intel-ravig avatar Mar 13 '24 05:03 intel-ravig

@eduand-alvarez - Looks like the issue can only be closed from your side. Can you please close it? Thanks

intel-ravig avatar Mar 13 '24 05:03 intel-ravig