Skip to content

Populate AudioConfig from sensevoice encoder_conf in _extract_audio_config - #307

Merged
justinchuby merged 1 commit into
mainfrom
fix-sensevoice-arch-validation
May 20, 2026
Merged

justinchuby merged 1 commit into
mainfrom
fix-sensevoice-arch-validation

Conversation

@justinchuby

Copy link
Copy Markdown
Member

What

tests/arch_validation_test.py failed for sensevoice_small with AssertionError in SenseVoiceSmallModel.__init__ (assert audio is not None).

Why

HuggingFace SenseVoice (model_type=sensevoice) keeps every encoder field nested under encoder_conf, plus input_size/vocab_size at the top level and n_mels under frontend_conf:

{
  "model_type": "sensevoice",
  "vocab_size": 25055,
  "input_size": 560,
  "encoder_conf": {
    "output_size": 512,
    "attention_heads": 4,
    "num_blocks": 50,
    "tp_blocks": 20,
    "linear_units": 2048,
    "kernel_size": 11
  },
  "frontend_conf": {"n_mels": 80}
}

_extract_audio_config had no branch for sensevoice, so config.audio came back None. The L1 build_graph test still passed because its tiny synthetic config sets config.audio directly; only the L2 arch-validation path (real HF config) was broken.

Fix

Map encoder_conf.* + top-level input_size + frontend_conf.n_mels into the corresponding AudioConfig fields. All target fields (attention_dim, attention_heads, num_blocks, tp_num_blocks, linear_units, kernel_size, input_size, num_mel_bins) already exist on AudioConfig — no new fields needed.

Tests

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 unit suite (src/ + tests/build_graph_test.py): 2753 passed, 41 skipped, 0 failures.

…onfig

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]>
@github-actions

Copy link
Copy Markdown

Performance Comparison

Comparing 9f5b173 → 948bf56

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 60 60 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 107 107 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 53 53 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 61 61 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 58 58 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 98 98 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 59 59 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 61 61 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 58 58 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 413 413 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

@justinchuby
justinchuby merged commit 2a17a92 into main May 20, 2026
23 checks passed
@justinchuby
justinchuby deleted the fix-sensevoice-arch-validation branch May 20, 2026 06:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes HuggingFace SenseVoice config parsing so ArchitectureConfig.audio is populated during L2 arch validation builds, preventing SenseVoiceSmallModel.__init__ from failing with assert audio is not None.

Changes:

  • Add a model_type == "sensevoice" branch in _extract_audio_config() to map encoder_conf.*, top-level input_size, and frontend_conf.n_mels into AudioConfig.

@github-actions

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 9f5b173 → 948bf56

Model Sub-model Changes Status
bert (feature-extraction) model 0 ⚪
falcon model 0 ⚪
gemma2 model 0 ⚪
gemma4 (gemma4) decoder 0 ⚪
gemma4 (gemma4) embedding 0 ⚪
gemma4 (gemma4) vision_encoder 0 ⚪
gemma4_text model 0 ⚪
gpt2 model 0 ⚪
llama model 0 ⚪
llama (static-cache) model 0 ⚪
mamba (ssm-text-generation) model 0 ⚪
phi3 model 0 ⚪
phi3 (static-cache) model 0 ⚪
qwen model 0 ⚪
qwen (static-cache) model 0 ⚪
qwen2 model 0 ⚪
qwen2 (static-cache) model 0 ⚪
qwen2_moe model 0 ⚪
qwen2_moe (static-cache) model 0 ⚪
qwen3 model 0 ⚪
qwen3 (static-cache) model 0 ⚪
qwen3_5_moe (hybrid-text-generation) model 0 ⚪
qwen3_5_text (hybrid-text-generation) model 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) decoder 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) embedding 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0 ⚪
qwen3_moe model 0 ⚪
qwen3_moe (static-cache) model 0 ⚪
qwen3_next (hybrid-text-generation) model 0 ⚪
t5 (seq2seq) decoder 0 ⚪
t5 (seq2seq) encoder 0 ⚪
whisper (speech-to-text) decoder 0 ⚪
whisper (speech-to-text) encoder 0 ⚪

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@codecov

codecov Bot commented May 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mobius/_configs.py 0.00% 6 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants