Repository navigation
Add nine core GGUF VLM projector routes - #689
Merged
Merged
Conversation
Performance Comparison
|
Separate paired multimodal builders from role-explicit standalone sidecar builders. Add modality-aware closure validation, source evidence and quarantined companion contracts, plus reusable vision and speaker projector tasks. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Add role-explicit standalone ONNX exporters for Gemma3n, Gemma4, Idefics3, InternVL, Llama4, and Pixtral sidecars. Validate exact pairings, tensor closures, processor contracts, and immutable evidence while keeping downstream runtime support explicitly deferred. Preserve Gemma4 audio roles by default, support encoder-free unified sidecars, and cover each promoted route with independent numerical parity and fail-closed discriminator tests. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Apply the repository formatter and use the precise exception and suffix-check forms required by Ruff without changing projector behavior. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Require both co-resident encoder roles and validate the complete combined vision/audio tensor-to-graph closure. Reject missing companion weights and unknown companion tensors instead of accepting broad auxiliary namespaces. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
Persist the #688 graph-versus-runtime distinction in every standalone sidecar ONNX component while retaining non-gating export and the public runtime warning. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands mobius’s GGUF multimodal-projector (“mmproj”) support by adding explicit standalone sidecar export routes for multiple VLM projector types, along with reusable projector/vision-tower components and stronger sidecar closure/shape validation.
Changes:
- Add standalone task/build entry points to export role-explicit mmproj components (vision/audio/speaker) without implicitly building a paired text decoder.
- Introduce core projector components (pixel-unshuffle and multiple projector heads) plus a dedicated Llama4 vision tower, and wire them into a new core GGUF projector model/module.
- Harden mmproj registry/spec/validation: explicit modality pairing rules, deferred-companion quarantine, route census updates, and expanded tests/docs.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/mobius/tasks/_gguf_projector.py | New standalone tasks for exporting vision and speaker sidecar component graphs. |
| src/mobius/tasks/_gguf_core_projector.py | New audio-only role task for core standalone projector routes (Gemma3n/Gemma4 audio variants). |
| src/mobius/tasks/init.py | Export newly added GGUF projector task/model types. |
| src/mobius/models/internvl.py | Add CLS-at-end option to match InternVL GGUF ordering for the standalone route. |
| src/mobius/models/gguf_core_projector.py | New architecture-specific core sidecar modules (Idefics3/InternVL/Llama4/Pixtral + Gemma3n/Gemma4 variants). |
| src/mobius/models/gemma4.py | Parameterize Gemma4 audio encoder head count from config instead of hard-coding. |
| src/mobius/integrations/gguf/_route_census_test.py | Update route classification expectations for newly promoted/recategorized projector routes. |
| src/mobius/integrations/gguf/_mmproj.py | Add standalone build_mmproj_from_gguf, core-route shape validation dispatch, stricter tensor closure validation, unified Gemma4 handling, and mapping updates. |
| src/mobius/integrations/gguf/_mmproj_test.py | Add/adjust tests for unified Gemma4 sidecars and standalone sidecar builds; update synthetic fixtures. |
| src/mobius/integrations/gguf/_mmproj_registry.py | Extend projector spec schema (primary modality, standalone builders, model roles, deferred companions, evidence records) and add new pins/specs. |
| src/mobius/integrations/gguf/_mmproj_registry_test.py | Expand registry invariants and pin coverage for new core projector routes and standalone importability. |
| src/mobius/integrations/gguf/_mmproj_mapping.py | Fix/extend Gemma4 audio tensor mapping (including clipping bounds and historical conv norm naming). |
| src/mobius/integrations/gguf/_mmproj_mapping_test.py | Add coverage for new audio tensor mappings and historical-name swaps. |
| src/mobius/integrations/gguf/_docs_test.py | Relax doc line-count constraint for expanded generated documentation. |
| src/mobius/integrations/gguf/_core_vlm_projector.py | New core VLM projector config recovery, tensor mapping, shape validation, and standalone builder implementation. |
| src/mobius/integrations/gguf/_core_vlm_projector_test.py | New tests for config recovery, tensor mapping, shape closure validation, and reference/parity checks. |
| src/mobius/integrations/gguf/init.py | Export the new standalone build_mmproj_from_gguf entry point. |
| src/mobius/components/_llama4_vision.py | New Llama4 fixed-tile vision tower component used by GGUF llama4 sidecars. |
| src/mobius/components/_llama4_vision_test.py | Unit tests validating Llama4 vision tower execution and torch parity. |
| src/mobius/components/_core_vlm_projector.py | New reusable projector heads and shared spatial pixel-unshuffle component. |
| src/mobius/components/_core_vlm_projector_test.py | Unit tests validating projector heads against independent torch references. |
| src/mobius/components/init.py | Re-export new core projector and Llama4 vision components via the public components API. |
| docs/api/build_from_gguf.md | Update generated support matrix and artifact/pin documentation for expanded projector support. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Match llama.cpp's complex-pair rotation within each spatial-axis half and raise the independent parity head width so split-half pairing can no longer pass accidentally. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
justinchuby
force-pushed
the
justinchuby-add-core-vlm-projectors
branch
from
August 28, 2026 16:12
c1f88c7 to
c86ae99
Compare
Accept a symbolic processor tile dimension for Idefics3, InternVL, and Llama4, then flatten per-tile feature rows in processor order. Declare image presence on standalone vision graphs and add executable one- and three-tile parity, cardinality, ordering, and symbolic-shape coverage. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Justin Chu <[email protected]>
justinchuby
added a commit
that referenced
this pull request
Aug 28, 2026
## Summary - add exact standalone GGUF projector routes for `glm4v`, `glma`, `qwen2.5o`, `qwen2a`, `qwen3a`, `qwen3vl_merger`, and `qwen3tts_spkenc` - enforce metadata, tensor closure, shape, modality pairing, and F32/F16/BF16-only qtype contracts; quarantine `qwen3tts_gen` - cover Qwen3-VL 2x2 merge cardinality, DeepStack width packing, four-section decoder MRoPE, and route-selected transformer activation semantics - preserve #688's advisory-only downstream-runtime policy and semantically retain #689's core-VLM builders, roles, evidence, component-presence metadata, census, docs, and tests ## Rebased commit stack - `171cec98` — small remaining shared standalone-dispatch/export delta after #689 absorbed the reusable projector foundation - `168414fe` — exactly the seven Qwen/GLM routes, mappings, components, evidence, docs, and tests - `1de782cf` — strict pre-closure metadata validation and Qwen3 audio padding/length hardening - `4b03d27e` — processor-native Qwen3 mask ABI, consumer-scoped SiLU semantics, and single-preflight fix Shared surfaces remain additive with #689: `_MMPROJ_BUILDERS` retains both `core_vlm_projector` and `qwen_glm_projector`; generic vision/audio/speaker tasks retain core component-presence metadata and Qwen multi-output audio support. ## Review hardening - `qwen3a` accepts the pinned `Qwen3ASRProcessor` output directly as `input_features_mask: int32`, casts internally only for length arithmetic, compacts padding-derived rows, and publishes `audio_feature_lengths` - all seven routes validate consumed metadata types, positive/finite ranges, boolean presence flags, exact projector enums, and route-specific geometry before tensor closure or graph construction - `clip.use_silu` is validated and fingerprint-relevant only for `glm4v`, `glma`, and `qwen3vl_merger`; Qwen3-VL transformer FFNs follow it while final and DeepStack mergers remain tanh-GELU - public standalone dispatch performs the expensive Qwen/GLM preflight once; direct route-wrapper calls still validate when no prevalidated model is injected - the outstanding duplicate-preflight review thread was answered and resolved ## Validation - combined focused projector/task suite: 440 passed - broad non-integration suite: 9,230 passed, 64 skipped, 1 subtest passed - lintrunner clean - generated GGUF docs clean - changed production modules pass mypy with import traversal isolated - independent medium-effort review and follow-up review: no findings Immutable selected evidence totals 5,980,273,312 bytes, below the 16 GiB cap. --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: e45c53d8-129d-461b-86fc-8ed79d816efe
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
gemma3na,gemma3nv,gemma4a,gemma4ua,gemma4uv,idefics3,internvl,llama4, andpixtral.mobius.runtime_support=standalone-sidecar-only; paired multimodal runtime unvalidatedand the dispatcher emits a warning.Route contracts
gemma3nvvision_encodergemma3ngemma3naaudio_encodergemma3ngemma4aaudio_encodergemma4gemma4uvvision_encodergemma4gemma4uaaudio_encodergemma4idefics3vision_encoderllamainternvlvision_encoderqwen2llama4vision_encoderllama4pixtralvision_encoderllama(H/16)*(W/16)+(H/16)-1rowsFor Idefics3, InternVL, and Llama4, the symbolic
num_tilesinput is processed tile-wise by the encoder/projector and reshaped from[tiles, rows_per_tile, hidden]to rank-2[tiles * rows_per_tile, hidden]. ONNX row-major reshape preserves processor tile order and raster order inside each tile; no synthetic tile separators are inserted because the processor owns refined-crop/overview ordering.Gemma3n's combined sidecar requires both presence flags and validates all 825 co-resident vision/audio tensors against both role graphs. Cross-pairing, aliasing, unknown tensors, unsupported packed projector qtypes, and unrepresentable dynamic ABI paths fail closed.
Runtime policy
Mobius emits the exact ONNX component whenever the graph is representable. Downstream paired runtime execution remains explicitly deferred and advisory; it does not gate standalone graph export. Every standalone vision graph declares
when_present=image. Only F32/F16/BF16 sidecar tensor storage is accepted.Evidence and validation
main@50bb373f0fce5aeb3bda463709ca7beb48d64b00(Decouple export from downstream runtime capability gates #688), retaining its advisory runtime policy and regenerated census/docs.head_dim=8, which distinguishes adjacent complex-pair rotation from the incorrect split-half layout.lintrunner -apassed.