执行摘要
本PR是一个文档更新,将已实现的Gemma 4模型(Gemma4ForCausalLM和Gemma4ForConditionalGeneration)添加到vLLM的支持模型列表文档中,并澄清了音频和视频模态的支持细节,旨在提高文档准确性和用户体验,无代码变更,风险极低。
功能与动机
为什么做:Gemma 4模型已在vLLM代码中实现(如gemma4.py、gemma4_mm.py),但未在官方文档supported_models.md中列出,导致用户可能无法发现或误用。PR body明确说明:“Gemma4ForCausalLM and Gemma4ForConditionalGeneration are already implemented and registered in vLLM, but were missing from the documentation table”,因此需要更新文档以反映实际支持。
实现拆解
变更仅涉及一个文件docs/models/supported_models.md,按以下步骤拆解:
- 更新文本模型表格:在“Text-only models”部分添加
Gemma4ForCausalLM行,包括模型名、描述、示例Hugging Face ID(如google/gemma-4-E2B-it)、LoRA和管道并行(PP)支持状态,格式与现有Gemma 3条目一致。
- 更新多模态模型表格:在“Multimodal models”部分添加
Gemma4ForConditionalGeneration行,指定模态为T + I⁺ + V + A*(文本、多图像、视频、音频),其中*标记表示音频仅特定变体支持,并标注PP支持。
- 添加新注释和通用标记:在文档脚注中新增
<sup>*</sup> Only specific variants of the model support this modality作为可复用通用标记;同时添加note块,详细说明音频仅限gemma-4-E2B和gemma-4-E4B变体,视频非原生输入但vLLM实现内部处理,用户可直接发送视频消息。
关键源码片段(整理自文档更新):
| `Gemma4ForCausalLM` | Gemma 4 | `google/gemma-4-E2B-it`, etc. | ✅︎ | ✅︎ |
| `Gemma4ForConditionalGeneration` | Gemma 4 | T + I⁺ + V + A<sup>*</sup> | `google/gemma-4-E2B-it`, etc. | | ✅︎ |
<sup>*</sup> Only specific variants of the model support this modality (see notes below).
!!! note
For `Gemma4ForConditionalGeneration`:
- audio input is only supported by the `gemma-4-E2B` and `gemma-4-E4B` variants.
- The model does not ingest videos directly. However, vLLM’s Gemma 4 implementation supports video inputs by handling video processing internally. Users can send videos directly in the message structure to vLLM.
评论区精华
review讨论中最有价值的交锋围绕模态支持准确性:
- DarkLight1337初始提问:“I think we also have multi-video and multi-audio support”,引发对代码
get_supported_mm_limits的检查。
- lucianommartins澄清核心细节:“all models support text + image; only e2b and e4b support audio input; no model support video input”,并解释视频通过vLLM内部ingestor处理。
- ywang96基于代码引用确认:“Based on gemma4_mm.py lines 207-212, we can support multiple audio”,推动文档更新。
- 最终共识:文档移除视频原生支持标记,添加变体特定音频注释,确保用户角度的准确性。
风险与影响
风险:作为纯文档更新,无技术回归、性能或安全风险;主要风险是文档不准确可能导致用户误解Gemma 4模态支持,但已通过review讨论和代码验证(如引用gemma4_mm.py)降低。
影响:正面影响文档用户,提高Gemma 4模型可发现性和使用指导;不影响系统运行;新增通用标记*为未来模型文档提供可复用模式,提升团队维护效率。
关联脉络
与历史PR #39234(“[Models][Gemma4] Prevent GPU/CPU sync in embed_input_ids”)相关,后者修复Gemma 4多模态模型的GPU/CPU同步问题,本PR则补充了该模型的官方文档支持,共同构成Gemma 4在vLLM中从实现到文档的完整支持链条。近期PR趋势显示vLLM持续扩展模型支持(如Gemma系列、量化整合),本PR是这一演进中的文档配套更新。
参与讨论