Skip to content

Asr switch#97

Draft
aviv1ron1 wants to merge 11 commits into
mainfrom
asr-switch
Draft

Asr switch#97
aviv1ron1 wants to merge 11 commits into
mainfrom
asr-switch

Conversation

@aviv1ron1

Copy link
Copy Markdown
Collaborator

No description provided.

aviv1ron1 added 11 commits June 14, 2026 14:14
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.
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.

1 participant