MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / resolve_adapter_scale

Function resolve_adapter_scale

src/models/vibevoice/lora.cpp:113–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113float 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
132std::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";

Callers 1

Calls 4

parse_fileFunction · 0.85
require_i64Function · 0.85
optional_f32Function · 0.85
optional_boolFunction · 0.85

Tested by

no test coverage detected