Skip to content

post_training_compression

post_training_compression

Hydra configuration dataclasses for the post-training compression endpoint.

PreparationConfig dataclass

PreparationConfig(replace_frozen_batchnorm=True, fuse_conv_batchnorm=True)

Pre-quantization model preparation settings.

Attributes:

Name Type Description
replace_frozen_batchnorm bool

Whether FrozenBatchNorm layers become plain BatchNorm before fusion.

fuse_conv_batchnorm bool

Whether Conv and BatchNorm pairs are fused.

BasePrunerConfig dataclass

BasePrunerConfig(amount=MISSING)

Base config for pruning strategies.

Attributes:

Name Type Description
amount float

Fraction of weights to prune, in (0, 1).

UnstructuredPrunerConfig dataclass

UnstructuredPrunerConfig(amount=MISSING, _target_='versatil.post_training_compression.pruning.UnstructuredPruner', layer_types=None)

Bases: BasePrunerConfig

Global L1 unstructured weight pruning.

Note

When layer_types is null, convolution and linear layers are pruned. Use the ${prunable_layer:*} resolver in YAML to constrain the set.

Attributes:

Name Type Description
_target_ str

Import path instantiated by Hydra.

layer_types list[str] | None

PrunableLayerType values to target. Defaults to convolution and linear layers (normalization scales and embedding tables are usually not good pruning targets).

StructuredPrunerConfig dataclass

StructuredPrunerConfig(amount=MISSING, _target_='versatil.post_training_compression.pruning.StructuredPruner', norm_order=1, dimension=0, layer_types=None)

Bases: BasePrunerConfig

Per-layer structured weight pruning using Lp-norm channel ranking.

Note

When layer_types is null, defaults to Conv1d, Linear and Conv2d. Use ${prunable_layer:*} resolver in YAML to add types.

Attributes:

Name Type Description
_target_ str

Import path instantiated by Hydra.

norm_order int

The p in Lp-norm used to rank channels (e.g., 1 for L1, 2 for L2).

dimension int

Weight tensor dimension along which to prune.

layer_types list[str] | None

PrunableLayerType values to target. Defaults to Conv1d, Conv2d, and Linear.

CompressionTargetConfig dataclass

CompressionTargetConfig(_target_='versatil.post_training_compression.compression_target.CompressionTarget', module_path=MISSING, preparation='${preparation}', pruning='${pruning}')

Per-module preparation and pruning scheme with inheritance.

Note

Absent fields in YAML inherit from the global config via Hydra interpolation defaults. Explicit null means skip.

Attributes:

Name Type Description
_target_ str

Import path instantiated by Hydra.

module_path str

Dotted path to the target submodule, or empty string for the full policy.

preparation PreparationConfig | None

BN replacement and fusion settings.

pruning list[Any] | None

Pruning strategies to apply sequentially.

TorchInductorBackendConfig dataclass

TorchInductorBackendConfig(_target_='versatil.post_training_compression.deployment_backends.torch_inductor.TorchInductorBackend')

Torch inductor deployment backend that writes .pt2 artifacts.

ExecutorchXNNPACKBackendConfig dataclass

ExecutorchXNNPACKBackendConfig(_target_='versatil.post_training_compression.deployment_backends.executorch_xnnpack.ExecutorchXNNPACKBackend', max_batch_size=32)

ExecuTorch backend that lowers artifacts to XNNPACK .pte files.

Attributes:

Name Type Description
_target_ str

Import path instantiated by Hydra.

max_batch_size int

Upper bound for dynamic batch execution in the serialized ExecuTorch program.

PostTrainingCompressorConfig dataclass

PostTrainingCompressorConfig(_target_='versatil.post_training_compression.compressor.PostTrainingCompressor', checkpoint_path=MISSING, checkpoint_name=value, output_directory=None, calibration_steps=32, generate_report=False, modules=list(), preparation=PreparationConfig(), pruning=None, quantization=None, deployment_backend=None)

Top-level config for the post-training compression endpoint.

Note

Global fields serve as defaults inherited by per-module configs via Hydra interpolation.

Attributes:

Name Type Description
_target_ str

Import path instantiated by Hydra.

checkpoint_path str

Path to the training checkpoint directory.

checkpoint_name str

Checkpoint filename inside the directory.

output_directory str | None

Where to save compressed output. Defaults to checkpoint_path/compressed/.

calibration_steps int

Number of calibration batches for static quantization.

generate_report bool

Whether to generate a quantization report after saving. Disabled by default since it runs additional forward passes for benchmarking.

modules list[CompressionTargetConfig]

Per-module compression schemes (empty = global).

preparation PreparationConfig

Global preparation settings.

pruning list[Any] | None

Global pruning strategies (inherited by modules).

quantization Any | None

Quantization workflow. None exports the float model without quantization.

deployment_backend Any | None

Deployment backend that owns artifact format and lowering. Defaults to torch inductor.