File size: 1,012 Bytes
06f9561
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Common loader for audio, multimodal and native speech inference."""
def load_swa_checkpoint(run_dir, checkpoint_step, launch_config, device):
    import os
    import torch
    budget = float(os.environ.get("HFD_INFER_MEMORY_BUDGET_GIB", "0"))
    if budget > 0 and str(device).startswith("cuda"):
        total = torch.cuda.get_device_properties(device).total_memory
        torch.cuda.set_per_process_memory_fraction(min(1.0, budget * 2**30 / total), device)
    architecture = getattr(launch_config.model, "interaction_architecture", "legacy")
    if architecture == "a1_c_deferred":
        from .runtime import load_inference_model
        return load_inference_model(run_dir, checkpoint_step, launch_config, device)
    if architecture != "legacy":
        raise ValueError(f"Unknown interaction architecture: {architecture}")
    from psi.models.full_duplex_swa import FullDuplexSwaModel
    return FullDuplexSwaModel.from_streaming_checkpoint(
        run_dir, checkpoint_step, launch_config, device)