Add ASR fp16 recipe for MahmoudAshraf/mms-300m-1130-forced-aligner#1095
Add ASR fp16 recipe for MahmoudAshraf/mms-300m-1130-forced-aligner#1095ssss141414 wants to merge 7 commits into
Conversation
|
if without the config, could perf run it directly? |
As PR's description, it will failed on build stage without config. And the following command will not be run (perf/ eval)... |
if it is the case, should we update the code to make it work? |
c2f69f1 to
a17b59c
Compare
Standard Wav2Vec2ForCTC model. Stock 'winml build' auto-config loads ASR via AutoModelForSpeechSeq2Seq, which rejects Wav2Vec2Config and fails. This recipe forces model_class=AutoModelForCTC (via 'winml config --model-class'), making the model buildable. Validated on CPU: fp16 build exit 0 (250.6s), 426 FLOAT16/0 FLOAT32 inits, output logits[1,49,31] CTC frames, L1 perf P50 133.9ms.
…or all-10-bucket README)
a17b59c to
0976f77
Compare
|
Updated in 0976f77. The code now disambiguates ASR loaders from published architecture metadata: |
xieofxie
left a comment
There was a problem hiding this comment.
Yes — this makes sense. The diagnosis is correct: automatic-speech-recognition is an ambiguous pipeline task, and task-only resolution picks AutoModelForSpeechSeq2Seq, which can't load a Wav2Vec2Config CTC checkpoint. Resolving from the published architectures metadata is the right layer to disambiguate, and the fix is properly architecture-driven with no model-id hardcoding (satisfies the repo's no-hardcoded-logic rule).
Verified locally at 7e972a0:
ruff checkclean;tests/unit/loader/test_config_resolution.py→ 17 passed (CTC auto-task, CTC explicit-task, Whisper seq2seq regression);- adjacent resolver suites (
test_detect_task,test_detect_task_and_class,test_resolve_task_override,test_known_tasks) → 90 passed, no regressions.
The override is correctly inserted before the TasksManager default in both the user-task and detection paths, so custom MODEL_CLASS_MAPPING entries still win and seq2seq speech models keep AutoModelForSpeechSeq2Seq. Returning the AutoModelForCTC auto-class (rather than the concrete Wav2Vec2ForCTC) keeps the two ASR families symmetric — good call. The recipe correctly drops loader.model_class now that resolution is automatic, follows the <model>/<ep>/<device>/<task>_<precision>_config.json layout, and its quant block is just the standard to_dict serialization (the int8/calibration fields are inert for mode="fp16").
One design-discussion note inline; non-blocking. Also a doc nit on the PR description below.
|
|
||
| architecture = architectures[0] | ||
| for (mapped_task, suffix), auto_class_name in _ARCHITECTURE_AUTO_CLASS_OVERRIDES.items(): | ||
| if task == mapped_task and architecture.endswith(suffix): |
There was a problem hiding this comment.
Design question (non-blocking): this introduces a second architecture-based resolution mechanism alongside the existing _resolve_model_class_from_config, which already reads architectures[0] and would return the concrete Wav2Vec2ForCTC. That helper only runs as the last fallback in Stage 2 (after TasksManager succeeds with the wrong seq2seq class), which is exactly why the bug slips through — so inserting an arch check before TasksManager is the correct move.
The trade-off worth calling out: this is a hand-maintained (task, suffix) allowlist, so every future ambiguous-task family (e.g. another dual-family pipeline task) needs a new entry. An alternative would be to prefer the concrete config architecture over the TasksManager default whenever architectures is present and the task is known-ambiguous — generalizing without a suffix table. I think the targeted map is the safer, more reviewable choice here (it can't regress the many tasks where the Auto* class is intentionally preferred), so I'd keep it — just flagging that the map will accrete entries over time. A short comment noting "add an entry per ambiguous task family" on _ARCHITECTURE_AUTO_CLASS_OVERRIDES would help the next person.
MahmoudAshraf/mms-300m-1130-forced-aligner: generalized CTC loader fix and fp16 recipe
This PR fixes ASR model-class resolution for CTC architectures and adds the validated CPU/fp16 recipe for
MahmoudAshraf/mms-300m-1130-forced-aligner.Root cause
The
automatic-speech-recognitiontask covers two incompatible model families:AutoModelForCTC;AutoModelForSpeechSeq2Seq.Before this fix, task-only resolution selected
AutoModelForSpeechSeq2Seqfor this publishedWav2Vec2ForCTCcheckpoint and failed with:Generalized code fix
Model-class resolution now uses the checkpoint's published architecture metadata when the task is ambiguous:
ForCTCresolve toAutoModelForCTC;A regression test confirms
WhisperForConditionalGenerationstill resolves toAutoModelForSpeechSeq2Seq.The recipe no longer sets
loader.model_class; it relies on the generalized resolver. It now supplies only the task/model type plus fp16 export and EP settings.Recipe
Added:
examples/recipes/MahmoudAshraf_mms-300m-1130-forced-aligner/cpu/cpu/automatic-speech-recognition_fp16_config.jsonOn CPU, pass
--precision fp16explicitly because automatic CPU precision otherwise selects fp32.Validation
Wav2Vec2ForCTC->AutoModelForCTC.input_values[1,16000]->logits.tests/unit/loader/test_config_resolution.py.fp16 goal-ladder evidence
--precision fp16The historical baseline failure is now closed by reusable code; the recipe is retained for fp16 and EP configuration rather than as a model-class workaround.