Improve HF qwen3_omni: preserve audio_sample_rate in kwargs restructuring (#29255)

Signed-off-by: Jeremy Teboul <jeremyteboul@fb.com>
Co-authored-by: Jeremy Teboul <jeremyteboul@fb.com>
This commit is contained in:
jeremyteboul
2026-01-02 20:31:09 -08:00
committed by GitHub
parent 0eee877f67
commit 97a01308e9
3 changed files with 312 additions and 3 deletions

View File

@@ -751,6 +751,9 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
mm_kwargs = dict(mm_kwargs)
tok_kwargs = dict(tok_kwargs)
if Version(TRANSFORMERS_VERSION) < Version("4.58.0"):
# Extract audio_sample_rate before restructuring
audio_sample_rate = mm_kwargs.pop("audio_sample_rate", None)
# move truncation to audio_kwargs level to avoid conflict
# with tok_kwargs
mm_kwargs["audio_kwargs"] = {
@@ -760,6 +763,28 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
"truncation": tok_kwargs.pop("truncation", False)
}
# Validate and conditionally pass audio_sample_rate
# WhisperFeatureExtractor has a fixed sampling rate, and vLLM's
# audio loader already resamples audio to the target rate.
# Only pass the value if it matches to avoid unexpected behavior.
if audio_sample_rate is not None:
expected_sr = feature_extractor.sampling_rate
if audio_sample_rate != expected_sr:
logger.warning(
"[%s] audio_sample_rate mismatch: user provided %dHz "
"but model expects %dHz. Ignoring user value. "
"vLLM's audio loader already resampled to %dHz.",
self.__class__.__name__,
audio_sample_rate,
expected_sr,
expected_sr,
)
else:
# Sample rate matches, safe to pass
mm_kwargs["audio_kwargs"]["audio_sample_rate"] = (
audio_sample_rate
)
hf_inputs = super()._call_hf_processor(
prompt=prompt,
mm_data=mm_data,