base
base
¶
Shared quantization workflow types.
BaseQuantizationWorkflow
¶
Bases: ABC
Base class for ordered quantization workflows.
quantization_mode
abstractmethod
property
¶
Return the quantization path name: none, pt2e or eager.
pt2e_backend_names
property
¶
Return serialized PT2E backend names used by this workflow.
load_policy_context
abstractmethod
¶
Load the policy context required by this workflow.
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
|
Policy context with the loaded policy, metadata, normalizer, and |
PolicyContext
|
optional tokenizer. |
Source code in src/versatil/quantization/workflows/base.py
quantize
abstractmethod
¶
Run the workflow and return exported deployment inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
PolicyContext
|
Loaded policy context used by the workflow. |
required |
exportable
|
ExportablePolicy
|
Policy wrapper exposing positional tensor inputs for
|
required |
calibration_steps
|
int
|
Maximum calibration batches for workflows that require calibration. |
required |
Returns:
| Type | Description |
|---|---|
QuantizedContext
|
Quantized context containing the float export, selected deployment |
QuantizedContext
|
model, example inputs, and serialized workflow name. |
Source code in src/versatil/quantization/workflows/base.py
prepare_model
¶
Prepare fake-quant modules before loading or training QAT weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Eager policy model to mutate in-place. |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the workflow does not implement QAT preparation. |
Source code in src/versatil/quantization/workflows/base.py
validate_targets
¶
Validate this workflow's target module paths and overlaps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Policy model whose submodule tree should contain every target. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a target path does not exist or two targets overlap. |
Source code in src/versatil/quantization/workflows/base.py
QuantizedContext
dataclass
¶
Quantized export result plus inputs and metadata needed for deployment.
validate_quantization_targets
¶
Validate quantization target paths and overlap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Policy model whose submodule tree should contain every target. |
required |
targets
|
list[QuantizationModuleTarget]
|
Module targets configured for one quantization workflow. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a target path does not exist or two targets overlap. |