Asr switch#97
Draft
aviv1ron1 wants to merge 11 commits into
Draft
Conversation
Register an ASR multimodal processor on GraniteSwitchForCausalLM: audio is transcribed and a <|audio|> marker is replaced with the transcript tokens (PromptReplacement), so the scheduler sizes KV for the real length. The model's embed_multimodal supplies those positions' embeddings via the token table (the seam a future trained audio encoder will reuse), and embed_input_ids scatters them. Audio capability is gated per-checkpoint by config.asr_enabled. Alpha scope: audio runs on the base model (no adapter control-token handling).
New --enable-audio / --asr-model / --asr-device flags. When audio is enabled the composer adds the <|audio|> marker token (before the embedding resize) and writes asr_enabled / asr_model_id / asr_device into the checkpoint config, so the vLLM backend's gated audio processor activates for that checkpoint.
tests/unit/test_asr.py: CPU-tier unit coverage for the ASR backend (audio coercion, mono/resample, lazy-load, transcribe with mocked pipeline); loads the leaf module by path so it runs without the vLLM extra. docs/AUDIO.md: how to compose --enable-audio, call it (Python + OpenAI server), the cascade design and the future-encoder seam, and alpha limitations.
The Granite content-part loop only handled type=='text' and dropped audio parts, so chat/OpenAI-server requests rendered without the <|audio|> marker and prompt replacement failed. Add configure_audio_chat_template(): injects an elif that appends the marker for any part whose type contains 'audio' (covers audio / input_audio / audio_url). Called during compose when audio is enabled.
Set requires_raw_input_tokens=True so vLLM passes raw input_ids to forward on the multimodal path, letting the switch detect adapter control tokens for audio requests. embed_input_ids now applies the switch's token-exchange rewrite (control -> substitute id) via a new SingleSwitch.apply_token_exchange helper, so control tokens get in-distribution embeddings exactly as on the text path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.