Download src/psi/models/interaction_arch/loading.py from Tinghong-Ye22/code-HFD: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/Tinghong-Ye22/code-HFD/resolve/main/src/psi/models/interaction_arch/loading.py
- Command line
-
hf download hf://Tinghong-Ye22/code-HFD/src/psi/models/interaction_arch/loading.py
-
curl -L -o loading.py https://huggingface.co/Tinghong-Ye22/code-HFD/resolve/main/src/psi/models/interaction_arch/loading.py
1.01 kB
| """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) | |