Skip to content

Commit 45a477d

Browse files
titaiwangmsCopilot
andauthored
Fix VibeVoice streaming ASR source resolution (#739)
## Summary - integrate both supported VibeVoice streaming ASR checkpoints into the shared fail-closed source resolver - pin config, processor, and weight sources to each checkpoint's verified revision - preserve module-specific weight preprocessing: only TTS layouts receive the `checkpoint_layout` argument - retain fail-closed rejection for unsupported BitNet and standalone acoustic-tokenizer checkpoints ## Root cause #723 was tested before #726 landed, although both changed VibeVoice source resolution. The combined `main` state classified the newly supported streaming ASR IDs as unsupported before their architecture-specific exporter could load the pinned config. The fix does not bypass or weaken #726's resolver. It makes streaming ASR an explicit supported provenance route and removes the now-redundant exact-ID pinning branch from the Transformers builder. ## Validation - `python -m pytest src/mobius/integrations/transformers/_builder_test.py src/mobius/models/vibevoice_test.py -q --tb=short` (`60 passed, 1 skipped`) - builder-level `load_weights=True` regression coverage verifies pinned config/weight revisions, the native ASR preprocessing signature, and emitted source metadata for both variants - targeted lintrunner checks: clean - revised lightweight correctness and risk reviews: PASS --------- Signed-off-by: titaiwang <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 99d3155 commit 45a477d

4 files changed

Lines changed: 140 additions & 32 deletions

File tree

‎src/mobius/integrations/transformers/_builder.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ def build_transformers_model(
402402
_config_from_hf,
403403
_default_task_for_model,
404404
)
405-
from mobius.models.vibevoice import VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS
406405

407406
detection_revision = revision
408407
vibevoice_sources = None
@@ -437,9 +436,6 @@ def build_transformers_model(
437436
# processor contract. Keep config detection and weight loading pinned.
438437
revision = VIBEVOICE_ASR_REVISION
439438
detection_revision = VIBEVOICE_ASR_REVISION
440-
if model_id in VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS and detection_revision is None:
441-
revision = VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS[model_id]
442-
detection_revision = revision
443439
if model_id == "nvidia/RE-USE" and detection_revision is None:
444440
# Pin the very first AutoConfig/raw-JSON probe, not only the later
445441
# bespoke loader. Otherwise mutable Hub main could change dispatch
@@ -758,7 +754,10 @@ def build_transformers_model(
758754
)
759755
state_dict = _download_weights(model_id, revision=revision)
760756
if hasattr(model_module, "preprocess_weights"):
761-
if vibevoice_sources is not None:
757+
if (
758+
vibevoice_sources is not None
759+
and vibevoice_sources.weight_layout is not None
760+
):
762761
state_dict = model_module.preprocess_weights(
763762
state_dict,
764763
checkpoint_layout=vibevoice_sources.weight_layout,

‎src/mobius/integrations/transformers/_builder_test.py‎

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,11 +1476,88 @@ def preprocess_weights(self, state_dict, *, checkpoint_layout):
14761476
}
14771477

14781478

1479+
@pytest.mark.parametrize(
1480+
("model_id", "revision"),
1481+
(
1482+
("microsoft/VibeVoice-ASR-Streaming-1.5B", "4262d23d8a539a6530cf64fbd0b1751ef9a30853"),
1483+
("microsoft/VibeVoice-ASR-Streaming-7B", "60d858b518b4e19d404af3737f848fc185b30177"),
1484+
),
1485+
)
1486+
def test_streaming_asr_uses_pinned_sources_and_native_weight_preprocessing(
1487+
monkeypatch, model_id, revision
1488+
) -> None:
1489+
"""The shared resolver must preserve streaming ASR's preprocessing signature."""
1490+
parent = SimpleNamespace(model_type="vibevoice", architectures=[])
1491+
package = ModelPackage(
1492+
{
1493+
"audio_encoder": ir.Model(
1494+
ir.Graph([], [], nodes=[], name="audio_encoder"), ir_version=11
1495+
)
1496+
}
1497+
)
1498+
calls = []
1499+
1500+
class StreamingAsrModule(_DummyModule):
1501+
def preprocess_weights(self, state_dict):
1502+
calls.append(("preprocess", state_dict))
1503+
return state_dict
1504+
1505+
monkeypatch.setattr(
1506+
transformers_builder,
1507+
"_load_transformers_config",
1508+
lambda *args, **kwargs: calls.append(("config", args, kwargs)) or (parent, False),
1509+
)
1510+
monkeypatch.setattr(
1511+
transformers_builder,
1512+
"_select_primary_config",
1513+
lambda value: (value, value, "VibeVoiceForASRStreamingTraining"),
1514+
)
1515+
monkeypatch.setattr(
1516+
transformers_builder,
1517+
"_resolve_module_class",
1518+
lambda *args, **kwargs: (
1519+
StreamingAsrModule,
1520+
"vibevoice-asr-streaming",
1521+
"VibeVoiceForASRStreamingTraining",
1522+
),
1523+
)
1524+
monkeypatch.setattr(
1525+
_config_resolver,
1526+
"_config_from_hf",
1527+
lambda *args, **kwargs: make_config(model_type="vibevoice"),
1528+
)
1529+
monkeypatch.setattr(
1530+
transformers_builder, "build_from_module", lambda *args, **kwargs: package
1531+
)
1532+
state_dict = {"weight": torch.ones(())}
1533+
monkeypatch.setattr(
1534+
transformers_builder,
1535+
"_download_weights",
1536+
lambda *args, **kwargs: calls.append(("weights", args, kwargs)) or state_dict,
1537+
)
1538+
1539+
result = transformers_builder.build_transformers_model(model_id)
1540+
1541+
assert result is package
1542+
assert calls == [
1543+
(
1544+
"config",
1545+
(model_id,),
1546+
{"revision": revision, "trust_remote_code": False},
1547+
),
1548+
("weights", (model_id,), {"revision": revision}),
1549+
("preprocess", state_dict),
1550+
]
1551+
assert package["audio_encoder"].metadata_props == {
1552+
"mobius.source_revision": revision,
1553+
"mobius.executable_source": f"{model_id}@{revision}",
1554+
"mobius.processor_source": f"{model_id}@{revision}",
1555+
}
1556+
1557+
14791558
@pytest.mark.parametrize(
14801559
"model_id",
14811560
[
1482-
"microsoft/VibeVoice-ASR-Streaming-7B",
1483-
"microsoft/VibeVoice-ASR-Streaming-1.5B",
14841561
"microsoft/VibeVoice-ASR-BitNet",
14851562
"microsoft/VibeVoice-AcousticTokenizer",
14861563
"Microsoft/VibeVoice-ASR-BitNet",

‎src/mobius/models/vibevoice.py‎

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,24 @@
4646
VIBEVOICE_EXECUTABLE_MODEL_ID = "vibevoice/VibeVoice-1.5B-hf"
4747
VIBEVOICE_EXECUTABLE_REVISION = "edc39f80f5cae656da37baf8faa8f5502bf7081f"
4848
VIBEVOICE_MICROSOFT_PROVENANCE_REVISION = VIBEVOICE_REVISION
49+
VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS = {
50+
"microsoft/VibeVoice-ASR-Streaming-1.5B": "4262d23d8a539a6530cf64fbd0b1751ef9a30853",
51+
"microsoft/VibeVoice-ASR-Streaming-7B": "60d858b518b4e19d404af3737f848fc185b30177",
52+
}
53+
VIBEVOICE_ASR_STREAMING_MODEL_ID = "microsoft/VibeVoice-ASR-Streaming-1.5B"
54+
VIBEVOICE_ASR_STREAMING_REVISION = VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS[
55+
VIBEVOICE_ASR_STREAMING_MODEL_ID
56+
]
57+
VIBEVOICE_ASR_STREAMING_SOURCE_REVISION = "505653d3873b065a488aea551c6ee3dc51d3062f"
4958

5059

5160
@dataclasses.dataclass(frozen=True)
5261
class VibeVoiceSources:
53-
"""Immutable provenance for one VibeVoice TTS build.
62+
"""Immutable provenance for one supported VibeVoice checkpoint.
5463
55-
``model_id`` and ``weight_revision`` are always the user's checkpoint. The
56-
official 1.5B release predates Transformers-native VibeVoice metadata, so
57-
its executable config and processor are resolved from the pinned conversion
58-
mirror while its official weights remain the only downloaded weights.
64+
``model_id`` and ``weight_revision`` are always the user's checkpoint.
65+
``weight_layout`` is set only when the module accepts an explicit checkpoint
66+
layout during weight preprocessing.
5967
"""
6068

6169
model_id: str
@@ -64,18 +72,10 @@ class VibeVoiceSources:
6472
config_revision: str
6573
processor_model_id: str
6674
processor_revision: str
67-
weight_layout: str
75+
weight_layout: str | None
6876

6977

7078
_UNSUPPORTED_VIBEVOICE_MODELS = {
71-
"microsoft/VibeVoice-ASR-Streaming-7B": (
72-
"VibeVoice ASR Streaming requires the VibeVoice-ASR streaming task, "
73-
"which Mobius does not export yet."
74-
),
75-
"microsoft/VibeVoice-ASR-Streaming-1.5B": (
76-
"VibeVoice ASR Streaming requires the VibeVoice-ASR streaming task, "
77-
"which Mobius does not export yet."
78-
),
7979
"microsoft/VibeVoice-ASR-BitNet": (
8080
"VibeVoice ASR BitNet requires the VibeVoice-ASR task and BitNet "
8181
"weight loader, which Mobius does not export yet."
@@ -104,6 +104,25 @@ def resolve_vibevoice_sources(model_id: str, revision: str | None) -> VibeVoiceS
104104
raise NotImplementedError(
105105
f"{model_id} is unsupported: {unsupported[canonical_model_id]}"
106106
)
107+
streaming_revisions = {
108+
known_model_id.casefold(): pinned_revision
109+
for known_model_id, pinned_revision in VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS.items()
110+
}
111+
if canonical_model_id in streaming_revisions:
112+
pinned_revision = streaming_revisions[canonical_model_id]
113+
if revision not in {None, pinned_revision}:
114+
raise ValueError(
115+
f"{model_id} is only verified at revision {pinned_revision}; got {revision}."
116+
)
117+
return VibeVoiceSources(
118+
model_id=model_id,
119+
weight_revision=pinned_revision,
120+
config_model_id=model_id,
121+
config_revision=pinned_revision,
122+
processor_model_id=model_id,
123+
processor_revision=pinned_revision,
124+
weight_layout=None,
125+
)
107126
if canonical_model_id == VIBEVOICE_MODEL_ID.casefold():
108127
if revision not in {None, VIBEVOICE_REVISION}:
109128
raise ValueError(
@@ -1233,17 +1252,6 @@ def preprocess_weights(
12331252
return routed
12341253

12351254

1236-
VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS = {
1237-
"microsoft/VibeVoice-ASR-Streaming-1.5B": "4262d23d8a539a6530cf64fbd0b1751ef9a30853",
1238-
"microsoft/VibeVoice-ASR-Streaming-7B": "60d858b518b4e19d404af3737f848fc185b30177",
1239-
}
1240-
VIBEVOICE_ASR_STREAMING_MODEL_ID = "microsoft/VibeVoice-ASR-Streaming-1.5B"
1241-
VIBEVOICE_ASR_STREAMING_REVISION = VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS[
1242-
VIBEVOICE_ASR_STREAMING_MODEL_ID
1243-
]
1244-
VIBEVOICE_ASR_STREAMING_SOURCE_REVISION = "505653d3873b065a488aea551c6ee3dc51d3062f"
1245-
1246-
12471255
class VibeVoiceASRStreamingAudioEncoder(nn.Module):
12481256
"""Encode waveform chunks with streaming ASR's two causal tokenizers."""
12491257

‎src/mobius/models/vibevoice_test.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from mobius._registry import registry
2727
from mobius._testing.ort_inference import OnnxModelSession
2828
from mobius.models.vibevoice import (
29+
VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS,
2930
VIBEVOICE_EXECUTABLE_MODEL_ID,
3031
VIBEVOICE_EXECUTABLE_REVISION,
3132
VIBEVOICE_MODEL_ID,
@@ -127,6 +128,29 @@ def test_official_vibevoice_sources_normalize_hub_id_case():
127128
resolve_vibevoice_sources("Microsoft/VibeVoice-ASR-BitNet", None)
128129

129130

131+
@pytest.mark.parametrize(
132+
("model_id", "revision"),
133+
tuple(VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS.items()),
134+
)
135+
def test_streaming_asr_sources_pin_checkpoint_assets(model_id, revision):
136+
sources = resolve_vibevoice_sources(model_id, None)
137+
138+
assert sources is not None
139+
assert sources.model_id == model_id
140+
assert sources.weight_revision == revision
141+
assert sources.config_model_id == model_id
142+
assert sources.config_revision == revision
143+
assert sources.processor_model_id == model_id
144+
assert sources.processor_revision == revision
145+
assert sources.weight_layout is None
146+
147+
148+
@pytest.mark.parametrize("model_id", VIBEVOICE_ASR_STREAMING_MODEL_REVISIONS)
149+
def test_streaming_asr_sources_reject_unverified_revisions(model_id):
150+
with pytest.raises(ValueError, match="only verified"):
151+
resolve_vibevoice_sources(model_id, "different-streaming-asr-revision")
152+
153+
130154
@pytest.mark.parametrize(
131155
("source", "expected"),
132156
[

0 commit comments

Comments
 (0)