| 111 | } |
| 112 | |
| 113 | float resolve_adapter_scale(const std::optional<std::filesystem::path> & config_path, float scale_override) { |
| 114 | if (scale_override > 0.0F) { |
| 115 | return scale_override; |
| 116 | } |
| 117 | if (!config_path.has_value()) { |
| 118 | throw std::runtime_error( |
| 119 | "VibeVoice LoRA has no adapter_config.json; pass vibevoice.lora_scale to set the merge scale"); |
| 120 | } |
| 121 | const auto root = json::parse_file(*config_path); |
| 122 | const auto rank = json::require_i64(root, "r"); |
| 123 | if (rank <= 0) { |
| 124 | throw std::runtime_error("VibeVoice LoRA adapter_config.json has non-positive r"); |
| 125 | } |
| 126 | const float alpha = json::optional_f32(root, "lora_alpha", static_cast<float>(rank)); |
| 127 | const bool use_rslora = json::optional_bool(root, "use_rslora", false); |
| 128 | const float denom = use_rslora ? std::sqrt(static_cast<float>(rank)) : static_cast<float>(rank); |
| 129 | return alpha / denom; |
| 130 | } |
| 131 | |
| 132 | std::string resolve_base_weight_name(const assets::TensorSource & base, const std::string & module_path) { |
| 133 | const std::string prefixed = std::string(kLanguageModelPrefix) + module_path + ".weight"; |
no test coverage detected