Repository navigation
Emit executable native VLM contracts - #418
Merged
Merged
Conversation
Derive typed component I/O, complete sequence dataflow, phases, and KV state from ONNX graph ports and validate closure before writing metadata. Co-authored-by: Copilot <[email protected]>
Performance Comparison
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR upgrades native VLM inference_metadata emission to be graph-derived and executable: every component now emits typed port declarations (dtype/rank/shape + source classification), dataflow edges include rank, image preprocessing outputs are qualified as component.port endpoints, and a new closure validator rejects incomplete/ambiguous/non-executable contracts.
Changes:
- Emit typed per-port I/O metadata for decoder/encoders (including KV port shapes) and qualify preprocessing outputs as
vision_encoder.<port>. - Route all compatible sequence-shaped edges (including
per_layer_inputs) and mark upstream sequence-producing components asevery_stepwith required token stream inputs. - Add
validate_executable_closure()to ensure every real graph input is bound exactly once with consistent dataflow/stateful/generated/external classification.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/mobius/integrations/onnx_genai/inference_metadata.py | Adds typed port serialization, sequence-edge routing, input source classification, and executable-closure validation for native VLM packages. |
| src/mobius/integrations/onnx_genai/inference_metadata_test.py | Updates tests for typed I/O + rank-carrying edges, adds regression coverage for closure validation and Gemma4 audio/embedding routing expectations. |
Comment on lines
+113
to
+122
| def _shape_metadata(port: _Port) -> list[int | str | None]: | ||
| """Return a YAML-safe graph shape without losing symbolic dimensions.""" | ||
| shape: list[int | str | None] = [] | ||
| for dim in port.dims: | ||
| if isinstance(dim, int): | ||
| shape.append(dim) | ||
| continue | ||
| value = getattr(dim, "value", None) | ||
| shape.append(str(value) if value is not None else None) | ||
| return shape |
Comment on lines
+135
to
+138
| def _same_dim(left: Any, right: Any) -> bool: | ||
| if isinstance(left, int) or isinstance(right, int): | ||
| return left == right | ||
| return getattr(left, "value", None) == getattr(right, "value", None) |
Comment on lines
+969
to
+975
| if source.dtype != target.dtype or source.rank != target.rank: | ||
| raise _closure_error( | ||
| target_endpoint, | ||
| f"edge {source_endpoint} has dtype/rank {source.dtype}/{source.rank}, " | ||
| f"but the consumer requires {target.dtype}/{target.rank}.", | ||
| "insert an explicit typed transform or remove the incompatible edge.", | ||
| ) |
| for component, model in pkg.items() | ||
| } | ||
| incoming: dict[str, list[dict[str, Any]]] = {} | ||
| for edge in pipeline.get("dataflow", []): |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
per_layer_inputs) and run sequence-producing embedding stages on every decode stepcomponent.porterrorsThe real Gemma4 audio output is rank 3 while the embedding input is rank 2, so the old invalid edge is no longer guessed; the embedding audio port is explicitly external until optional-modality/typed-audio transform semantics land.
Validation
PYTHONPATH=$PWD/src python3 -m pytest src/mobius/integrations/onnx_genai/inference_metadata_test.py tests/cli_test.py -q— 62 passedlintrunner0.12.7 with repository Ruff 0.15.14 adapters — cleanevery_step