Skip to content

Fix Gemma4 text-only image closure - #421

Merged
justinchuby merged 1 commit into
mainfrom
squad/badger-gemma4-text-closure
Jul 22, 2026
Merged

Fix Gemma4 text-only image closure#421
justinchuby merged 1 commit into
mainfrom
squad/badger-gemma4-text-closure

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • resolve Joi gap Update security.md #1 by declaring embedding.image_features optional
  • emit an empty [0, hidden_size] zero fallback when image input is absent
  • gate vision_encoder with the same generic image presence key
  • cover Gemma4 graph contracts and emitted inference metadata

Validation

  • ruff check src/mobius/tasks/_gemma4.py tests/build_graph_test.py src/mobius/integrations/onnx_genai/inference_metadata_test.py
  • python3 -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.

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>
@github-actions

Copy link
Copy Markdown

Performance Comparison

Comparing 3861631aefa2e8

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 60 60 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 68 68 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 107 107 +0.0%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 54 54 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 62 62 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 58 58 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 98 98 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 60 60 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 56 56 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 62 62 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 58 58 +0.0%
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0%
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0%
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0%
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0%
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0%
qwen3_5_vl (hybrid-qwen-vl) num_nodes 413 413 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 166 166 +0.0%
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0%
whisper (speech-to-text) num_nodes 128 128 +0.0%

No performance regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_encoder component presence as "image" so pipeline metadata can gate the phase/stage on image presence.
  • Mark embedding.image_features as 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.

@github-actions

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 3861631aefa2e8

Model Sub-model Changes Status
bert (feature-extraction) model 0
falcon model 0
gemma2 model 0
gemma4 (gemma4) decoder 0
gemma4 (gemma4) embedding 0
gemma4 (gemma4) vision_encoder 0
gemma4_text model 0
gpt2 model 0
llama model 0
llama (static-cache) model 0
mamba (ssm-text-generation) model 0
phi3 model 0
phi3 (static-cache) model 0
qwen model 0
qwen (static-cache) model 0
qwen2 model 0
qwen2 (static-cache) model 0
qwen2_moe model 0
qwen2_moe (static-cache) model 0
qwen3 model 0
qwen3 (static-cache) model 0
qwen3_5_moe (hybrid-text-generation) model 0
qwen3_5_text (hybrid-text-generation) model 0
qwen3_5_vl (hybrid-qwen-vl) decoder 0
qwen3_5_vl (hybrid-qwen-vl) embedding 0
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0
qwen3_moe model 0
qwen3_moe (static-cache) model 0
qwen3_next (hybrid-text-generation) model 0
t5 (seq2seq) decoder 0
t5 (seq2seq) encoder 0
whisper (speech-to-text) decoder 0
whisper (speech-to-text) encoder 0

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@justinchuby
justinchuby merged commit 38cb789 into main Jul 22, 2026
22 of 23 checks passed
@justinchuby
justinchuby deleted the squad/badger-gemma4-text-closure branch July 22, 2026 17:03
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.

2 participants