Skip to content

Commit 948bf56

Browse files
justinchubyCopilot
andcommitted
Populate AudioConfig from sensevoice encoder_conf in _extract_audio_config
The arch_validation tests for sensevoice_small failed because the HuggingFace config for SenseVoice (model_type=sensevoice) keeps every encoder field nested under encoder_conf (output_size, attention_heads, num_blocks, tp_blocks, linear_units, kernel_size) plus an input_size/vocab_size at the top level and num_mels under frontend_conf. _extract_audio_config did not know about this layout, so config.audio came back None and the SenseVoiceSmallModel ctor hit 'assert audio is not None'. The L1 path with the tiny synthetic config still worked because that fixture sets config.audio directly; only the real HF config (L2) was broken. Add a sensevoice branch that maps encoder_conf.{output_size, attention_heads, num_blocks, tp_blocks, linear_units, kernel_size}, top-level input_size, and frontend_conf.n_mels into AudioConfig. pytest tests/arch_validation_test.py -k sensevoice_small -v test_config_downloads_and_parses PASSED test_full_graph_builds PASSED test_graph_shapes_consistent PASSED Full src/ + build_graph: 2753 passed, 41 skipped. Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
1 parent c289382 commit 948bf56

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎src/mobius/_configs.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,25 @@ def _extract_audio_config(config, parent_config, model_type: str) -> dict:
774774
)
775775
}
776776

777+
# SenseVoice / FunASR-style: encoder config lives under "encoder_conf"
778+
# and the mel-spec frontend under "frontend_conf". Top-level holds
779+
# input_size + vocab_size. model_type is "sensevoice".
780+
if model_type == "sensevoice":
781+
encoder_conf = getattr(config, "encoder_conf", None) or {}
782+
frontend_conf = getattr(config, "frontend_conf", None) or {}
783+
if isinstance(encoder_conf, dict) and encoder_conf:
784+
audio_fields.update(
785+
attention_dim=encoder_conf.get("output_size"),
786+
attention_heads=encoder_conf.get("attention_heads"),
787+
num_blocks=encoder_conf.get("num_blocks"),
788+
tp_num_blocks=encoder_conf.get("tp_blocks"),
789+
linear_units=encoder_conf.get("linear_units"),
790+
kernel_size=encoder_conf.get("kernel_size"),
791+
input_size=getattr(config, "input_size", None),
792+
)
793+
if isinstance(frontend_conf, dict):
794+
audio_fields["num_mel_bins"] = frontend_conf.get("n_mels")
795+
777796
# Build AudioConfig sub-config if any audio fields are set
778797
has_audio = any(v is not None for v in audio_fields.values())
779798

0 commit comments

Comments
 (0)