Repository navigation
Update gemma4 genai audio config logic - #223
Conversation
Performance Comparison
|
There was a problem hiding this comment.
Pull request overview
Updates Mobius’ ORT GenAI export path for Gemma4 models, especially for speech-capable variants, by switching Gemma4 audio processor config generation to the feature_extraction.sequence schema and adjusting how genai_config selects/writes processor config filenames and audio input mappings.
Changes:
- Emit Gemma4 audio feature extraction config in
feature_extraction.sequenceformat and write it asaudio_feature_extraction.json. - Prioritize Gemma4 model types when populating
visionconfig parameters ingenai_config.json. - Override Gemma4 speech section settings in
genai_config.json(config filename + input mapping).
|
The author of this PR, apsonawane, is not an activated member of this organization on Codecov. |
justinchuby
left a comment
There was a problem hiding this comment.
Thanks! Could you provide context in the PR description?
|
Could you include tests? Thanks |
|
Added tests and updated the description |
follow up from this PR: #223 --------- Co-authored-by: Justin Chu <[email protected]>
Gemma4 Audio Encoder Support for ORT-GenAI Export
Summary
Adds audio encoder export support for Gemma4 multimodal models in the ORT-GenAI integration pipeline. This enables Gemma4 any-to-any (vision+audio+text) models to be exported with the correct audio processor configuration and genai_config.json speech section.
Changes
auto_export.py_write_audio_processor_config()— New function that writesaudio_feature_extraction.jsonfor Gemma4 models using thefeature_extraction.sequenceschema required byOrtxCreateSpeechFeatureExtractor. The pipeline consists ofAudioDecoder→Gemma4LogMelwith USM-style 128-dim log-mel spectrogram parameters._write_genai_config()— Gemma4 speech section overrides:filename:audio_encoder/model.onnxconfig_filename:audio_feature_extraction.json(instead of defaultaudio_processor.json)input_namesmapping:audio_embeds→input_features,attention_mask→input_features_mask_write_vision_processor_config()— Renamed from_write_processor_configfor clarity. Gemma4 vision path now writesimage_processor.jsonwithDecodeImage→Gemma4ImageTransformtransforms pipeline, checked beforehas_speechto ensure vision config is always written for VLM+audio models.write_ort_genai_config()— Calls_write_audio_processor_config()and includes result in the output dict under"audio_processor".auto_export_test.pyAdded 6 new tests covering audio export:
test_audio_no_audio_returns_none_write_audio_processor_configreturnsNonewhen config has noaudioattributetest_audio_non_gemma4_returns_noneNonefor non-Gemma4 model typestest_audio_gemma4_writes_feature_extraction_jsonaudio_feature_extraction.jsonwith correctfeature_extraction.sequenceschema,AudioDecoder+Gemma4LogMelops, and expected attrstest_gemma4_audio_processor_json_writtenwrite_ort_genai_configproducesaudio_feature_extraction.jsontest_gemma4_audio_processor_not_written_without_audioaudiotest_gemma4_genai_config_speech_sectiongenai_config.jsonspeech section has correctconfig_filename,filename, and input mapping (input_features/input_features_mask)Notes
feature_extraction.sequenceformat (notprocessor.transforms) is required by the onnxruntime-extensionsOrtxCreateSpeechFeatureExtractorAPI._write_vision_processor_configrename updates the existing test reference (test_gemma4_image_processor_json_written).