Skip to content

none

none

No-quantization workflow for float model export.

NoQuantizationWorkflow

Bases: BaseQuantizationWorkflow

Export the float policy without applying quantization.

quantization_mode property

quantization_mode

Return none because this workflow skips quantization.

quantization_workflow property

quantization_workflow

Return the serialized no-quantization workflow value.

prepare_model

prepare_model(model)

Leave the model unchanged before training.

Parameters:

Name Type Description Default
model Module

Policy model passed by the training workspace.

required
Source code in src/versatil/quantization/workflows/none.py
def prepare_model(self, model: nn.Module) -> None:
    """Leave the model unchanged before training.

    Args:
        model: Policy model passed by the training workspace.
    """
    return None

load_policy_context

load_policy_context(checkpoint_path, checkpoint_name)

Load the float policy 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 unquantized export.

Source code in src/versatil/quantization/workflows/none.py
def load_policy_context(
    self,
    checkpoint_path: str,
    checkpoint_name: str,
) -> PolicyContext:
    """Load the float policy checkpoint.

    Args:
        checkpoint_path: Directory containing the training checkpoint.
        checkpoint_name: Checkpoint filename to load from the directory.

    Returns:
        Float policy context for unquantized export.
    """
    return load_float_policy_context(
        checkpoint_path=checkpoint_path,
        checkpoint_name=checkpoint_name,
    )

quantize

quantize(context, exportable, calibration_steps)

Export the policy without modifying weights or graph quantization.

Parameters:

Name Type Description Default
context PolicyContext

Loaded float policy context.

required
exportable ExportablePolicy

Policy wrapper exposing positional tensor inputs for torch.export.

required
calibration_steps int

Unused for unquantized export.

required

Returns:

Type Description
QuantizedContext

Quantized context whose float and deployment models are the same

QuantizedContext

exported graph.

Source code in src/versatil/quantization/workflows/none.py
def quantize(
    self,
    context: PolicyContext,
    exportable: ExportablePolicy,
    calibration_steps: int,
) -> QuantizedContext:
    """Export the policy without modifying weights or graph quantization.

    Args:
        context: Loaded float policy context.
        exportable: Policy wrapper exposing positional tensor inputs for
            ``torch.export``.
        calibration_steps: Unused for unquantized export.

    Returns:
        Quantized context whose float and deployment models are the same
        exported graph.
    """
    example_inputs = build_example_inputs(
        exportable=exportable,
        observation_space=context.observation_space,
        observation_horizon=context.observation_horizon,
        tokenizer=context.tokenizer,
    )
    exported = export_policy(exportable=exportable, example_inputs=example_inputs)
    return QuantizedContext(
        float_model=exported,
        quantized_model=exported,
        example_inputs=example_inputs,
        quantization_workflow=self.quantization_workflow,
    )