Deploy

Model deployment pipeline for Frankenstein Transformer.

Converts trained checkpoints to optimized, quantized deployable artifacts. Supports both BitNet-quantized and standard FP32 deployment formats, with optional post-deployment validation.

class src.deploy.deploy.ModelDeployer(config: FrankensteinModelConfig, device: str = 'cpu')[source]

Bases: object

Handles conversion of trained models to deployment-ready format.

Loads a training checkpoint, initializes the model, and exports it in either quantized (BitNet ternary) or standard FP32 format, along with config JSON and deployment metadata.

config

FrankensteinModelConfig for the model.

device

PyTorch device for deployment conversion.

model

The loaded FrankensteinEncoder instance.

__init__(config: FrankensteinModelConfig, device: str = 'cpu')[source]

Initialize the deployer.

Parameters:
  • config – Model configuration.

  • device – PyTorch device string for conversion.

convert_to_deployment(output_dir: str, save_format: str = 'quantized', bake_bitnet: bool = True) None[source]

Convert model to deployment format.

Parameters:
  • output_dir – Directory to save deployment artifacts

  • save_format – ‘quantized’ or ‘standard’

  • bake_bitnet – When save_format='quantized' and BitNet is enabled, bake BitLinear weights to faithful ternary values before packing (default True). No effect otherwise.

load_training_checkpoint(checkpoint_path: str) None[source]

Load model from training checkpoint.

Parameters:

checkpoint_path – Path to training checkpoint

validate_deployment(deployment_dir: str) bool[source]

Validate that deployed model can be loaded and used.

Parameters:

deployment_dir – Directory containing deployment artifacts

Returns:

True if validation successful

src.deploy.deploy.main(argv=None)[source]