eager
eager
¶
Eager torchao quantization workflow.
EagerQuantizationWorkflow
¶
Bases: BaseQuantizationWorkflow
Eager torchao quantization workflow for PTQ and QAT.
Initialize eager torchao quantization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
targets
|
list[EagerQuantizationModuleTarget]
|
Module-level eager quantization targets. |
required |
is_qat
|
bool
|
Whether this workflow is used for QAT checkpoint training and conversion. |
False
|
auto_filter_incompatible_linears
|
bool
|
Whether to skip linears whose
|
True
|
Source code in src/versatil/quantization/workflows/eager.py
load_policy_context
¶
Load a float or QAT-prepared checkpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path
|
str
|
Directory containing the training checkpoint. |
required |
checkpoint_name
|
str
|
Checkpoint filename to load from the directory. |
required |
Returns:
| Type | Description |
|---|---|
PolicyContext
|
Float policy context for PTQ, or QAT-prepared policy context for |
PolicyContext
|
QAT conversion. |
Source code in src/versatil/quantization/workflows/eager.py
quantize
¶
Apply eager quantization and export the policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
PolicyContext
|
Loaded policy context containing the eager policy to mutate. |
required |
exportable
|
ExportablePolicy
|
Export wrapper around the same policy. |
required |
calibration_steps
|
int
|
Unused for eager quantization. |
required |
Returns:
| Type | Description |
|---|---|
QuantizedContext
|
Exported eager-quantized model and example inputs for deployment. |
Source code in src/versatil/quantization/workflows/eager.py
prepare_model
¶
Apply fake quantization modules in-place before QAT training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Policy model to prepare for QAT. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the workflow is not a QAT workflow, if a target path
is invalid, or if a target selects no eligible |
Source code in src/versatil/quantization/workflows/eager.py
convert_model
¶
Convert prepared fake-quant modules to quantized modules in-place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Policy model previously prepared by |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the workflow is not a QAT workflow, or if
|