def prepare_fp8(m, optimizer=None):
    """Convert modules to FP8 modules (e.g, convert nn.Linear to FP8Linear) in the model."""
    optimized_model, optimized_optimizer = _copy_model_and_optimizer(m, optimizer)
    new_m, new_optimizer = convert_rec(optimized_model, optimized_optimizer)
    if optimizer is None:
        return new_m
    return new_m, new_optimizer
Convert modules to FP8 modules (e.g, convert nn.Linear to FP8Linear) in the model.
intel_extension_for_pytorch/quantization/fp8/util.py