Skip to content
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

Adjust CLI support for PTQ #11421

Merged
merged 1 commit into from
Nov 27, 2024
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
6 changes: 4 additions & 2 deletions nemo/collections/llm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,11 @@ def validate(
@run.cli.entrypoint(name="ptq", namespace="llm")
def ptq(
nemo_checkpoint: str,
export_config: ExportConfig,
calib_tp: int = 1,
calib_pp: int = 1,
quantization_config: Annotated[Optional[QuantizationConfig], run.Config[QuantizationConfig]] = None,
export_config: Optional[Union[ExportConfig, run.Config[ExportConfig]]] = None,
) -> Path:
# TODO: Fix "nemo_run.cli.cli_parser.CLIException: An unexpected error occurred (Argument: , Context: {})"
"""
Applies Post-Training Quantization (PTQ) for a model using the specified quantization and export configs. It runs
calibration for a small dataset to collect scaling factors low-precision GEMMs used by desired quantization method.
Expand All @@ -297,6 +296,9 @@ def ptq(
Returns:
Path: The path where the quantized checkpoint has been saved after calibration.
"""
if not quantization_config:
quantization_config = QuantizationConfig()

if export_config.path is None:
raise ValueError("The export_config.path needs to be specified, got None.")

Expand Down
Loading