Skip to content

constants

constants

Constants and enums for post-training compression.

QuantizationWorkflow

Bases: StrEnum

Quantization workflow used during compression.

ArtifactFormat

Bases: StrEnum

Deployment artifact format emitted by deployment backends.

DeploymentBackendName

Bases: StrEnum

Deployment backend identifiers stored in metadata.

CompressionMetadataKey

Bases: StrEnum

Keys used in compression metadata JSON files.

CompressionFilename

Bases: StrEnum

Standard filenames in compressed checkpoint directories.

PrunableLayerType

Bases: StrEnum

Layer types targeted by pruning strategies.

to_module_type

to_module_type()

Resolve to the corresponding torch.nn.Module class.

Source code in src/versatil/post_training_compression/constants.py
def to_module_type(self) -> type[nn.Module]:
    """Resolve to the corresponding torch.nn.Module class."""
    mapping: dict[str, type[nn.Module]] = {
        PrunableLayerType.CONV1D.value: nn.Conv1d,
        PrunableLayerType.CONV2D.value: nn.Conv2d,
        PrunableLayerType.LINEAR.value: nn.Linear,
    }
    return mapping[self.value]

PruningTargetAttribute

Bases: StrEnum

PyTorch module attribute names targeted by pruning.