@@ -209,6 +209,15 @@ struct audio_decoder_ggml_ctx {
209209 return std::make_pair (t, data);
210210 }
211211
212+ // read an optional u32 hyperparameter, falling back if the key is absent
213+ uint32_t get_hparam_u32 (const char * key, uint32_t fallback) const {
214+ auto key_id = gguf_find_key (ctx_gguf, key);
215+ if (key_id < 0 ) {
216+ return fallback;
217+ }
218+ return gguf_get_val_u32 (ctx_gguf, key_id);
219+ }
220+
212221 ggml_tensor * get_weight (const char * fmt, ...) {
213222 std::vector<char > str (128 );
214223 va_list va;
@@ -674,9 +683,10 @@ class audio_decoder_lfm25 : public mtmd_audio_decoder {
674683 // output modality switch
675684 std::vector<mtmd_output_modality> modalities;
676685
677- static constexpr auto interleaved_n_text = 6 ;
678- static constexpr auto interleaved_n_audio = 12 ;
679- int modality_left = INT_MAX ;
686+ // interleaved modality cadence, read from gguf with fallback defaults
687+ int interleaved_n_text = 6 ;
688+ int interleaved_n_audio = 12 ;
689+ int modality_left = INT_MAX ;
680690
681691 // sampling
682692 llama_sampler_ptr smpl;
@@ -688,6 +698,9 @@ class audio_decoder_lfm25 : public mtmd_audio_decoder {
688698 ctx (use_gpu) {
689699 ctx.load_gguf (vocoder_path.c_str ());
690700
701+ interleaved_n_text = ctx.get_hparam_u32 (" interleaved_n_text" , interleaved_n_text);
702+ interleaved_n_audio = ctx.get_hparam_u32 (" interleaved_n_audio" , interleaved_n_audio);
703+
691704 decoder_model.init (ctx);
692705
693706 // audio tokenizer
0 commit comments