Fix Gemma4 text-only image closure - #421
Merged
Merged
Conversation
Resolve Joi gap #1 by emitting an optional image_features fallback and gating vision_encoder on the generic image presence key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Performance Comparison
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Gemma4 multimodal packages so text-only prompts don’t require image inputs by making embedding.image_features an optional input with a well-defined “absent” fallback, and by declaring a consistent presence key used to gate the vision stage in emitted ONNX GenAI pipeline metadata.
Changes:
- Declare
vision_encodercomponent presence as"image"so pipeline metadata can gate the phase/stage on image presence. - Mark
embedding.image_featuresas an optional input with an “absent” contract of zeros shaped[0, hidden_size]. - Extend graph/metadata tests to assert the new component presence + optional input contracts and their emitted inference metadata.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/build_graph_test.py | Adds assertions for vision_encoder presence key and embedding.image_features optional-input contract across Gemma4 variants. |
| src/mobius/tasks/_gemma4.py | Declares presence gating for vision graphs and declares image_features optional with a zero fallback shape. |
| src/mobius/integrations/onnx_genai/inference_metadata_test.py | Updates metadata tests to cover optional image input emission and vision phase gating. |
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
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.
Summary
embedding.image_featuresoptional[0, hidden_size]zero fallback when image input is absentvision_encoderwith the same genericimagepresence keyValidation
ruff check src/mobius/tasks/_gemma4.py tests/build_graph_test.py src/mobius/integrations/onnx_genai/inference_metadata_test.pypython3 -m pytest tests/build_graph_test.py src/mobius/integrations/onnx_genai/inference_metadata_test.py -q(1297 passed, 42 skipped)No model-name runtime branching was added; metadata emission remains contract-driven.