Skip to content

Do not require checkpoint in quantize() unless it's gptq #9470

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

Merged
merged 1 commit into from
Mar 20, 2025
Merged
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
5 changes: 1 addition & 4 deletions examples/models/llama/source_transformation/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ def quantize( # noqa C901
else:
torch_dtype = torch.float16

assert checkpoint_path, "Need to specify a checkpoint"
# if checkpoint_path is None:
# checkpoint_path = Path("checkpoints/meta-llama/Llama-2-7b-chat-hf/model.pth")

if qmode == "int8":
# Add quantization mode options here: group size, bit width, etc.
return WeightOnlyInt8QuantHandler(model).quantized_model()
Expand Down Expand Up @@ -149,6 +145,7 @@ def quantize( # noqa C901
from torchao.quantization.quant_api import Int8DynActInt4WeightGPTQQuantizer

if tokenizer_path is None:
assert checkpoint_path is not None, "checkpoint_path must be specified"
tokenizer_path = checkpoint_path.parent / "tokenizer.model"
assert tokenizer_path.is_file(), tokenizer_path
tokenizer = SentencePieceProcessor( # pyre-ignore[28]
Expand Down
Loading