Load LoRA weights from a checkpoint file. Args: lora_weights_path: Path to LoRA weights (.pth file or directory containing lora_weights.ckpt). Returns: tuple: (loaded_keys, skipped_keys) - lists of loaded and skipped parameter names.
(self, lora_weights_path: str)
| 315 | # LoRA Interface (delegated to VoxCPMModel) |
| 316 | # ------------------------------------------------------------------ # |
| 317 | def load_lora(self, lora_weights_path: str) -> tuple: |
| 318 | """Load LoRA weights from a checkpoint file. |
| 319 | |
| 320 | Args: |
| 321 | lora_weights_path: Path to LoRA weights (.pth file or directory |
| 322 | containing lora_weights.ckpt). |
| 323 | |
| 324 | Returns: |
| 325 | tuple: (loaded_keys, skipped_keys) - lists of loaded and skipped parameter names. |
| 326 | |
| 327 | Raises: |
| 328 | RuntimeError: If model was not initialized with LoRA config. |
| 329 | """ |
| 330 | if self.tts_model.lora_config is None: |
| 331 | raise RuntimeError( |
| 332 | "Cannot load LoRA weights: model was not initialized with LoRA config. " |
| 333 | "Please reinitialize with lora_config or lora_weights_path parameter." |
| 334 | ) |
| 335 | return self.tts_model.load_lora_weights(lora_weights_path) |
| 336 | |
| 337 | def unload_lora(self): |
| 338 | """Unload LoRA by resetting all LoRA weights to initial state (effectively disabling LoRA).""" |