Skip to content

Add nine core GGUF VLM projector routes - #689

Merged
justinchuby merged 7 commits into
mainfrom
justinchuby-add-core-vlm-projectors
Aug 28, 2026
Merged

justinchuby merged 7 commits into
mainfrom
justinchuby-add-core-vlm-projectors

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add role-explicit standalone GGUF sidecar export for gemma3na, gemma3nv, gemma4a, gemma4ua, gemma4uv, idefics3, internvl, llama4, and pixtral.
  • Add reusable pixel-unshuffle, Idefics3, InternVL, Llama4, and Pixtral projector components plus a dedicated Llama4 vision tower.
  • Recover revision-neutral graph config and exact tensor mappings from each sidecar while pinning immutable revisions only in the evidence registry.
  • Preserve active Gemma4 audio by default and support encoder-free Gemma4 unified vision/audio sidecars without collapsing their roles.
  • Integrate the Decouple export from downstream runtime capability gates #688 graph-versus-runtime policy: exact component export remains non-gating, while every saved standalone graph records mobius.runtime_support=standalone-sidecar-only; paired multimodal runtime unvalidated and the dispatcher emits a warning.

Route contracts

Projector ModelPackage role Text target Processor-native feature contract
gemma3nv vision_encoder gemma3n 768x768 image, 256 feature rows
gemma3na audio_encoder gemma3n 128-bin input features, 188 feature rows
gemma4a audio_encoder gemma4 Clipped Conformer audio features
gemma4uv vision_encoder gemma4 48x48 merged patches, one row per valid patch
gemma4ua audio_encoder gemma4 Raw 640-sample frames, one row per valid frame
idefics3 vision_encoder llama Dynamic tile count, 512x512 tiles, 64 rows per tile
internvl vision_encoder qwen2 Dynamic tile count, 448x448 tiles, 256 rows per tile, CLS-last GGUF ordering
llama4 vision_encoder llama4 Dynamic tile count, 336x336 tiles, 144 rows per tile; adjacent-pair split-axis 2D RoPE
pixtral vision_encoder llama Dynamic patch-aligned image; (H/16)*(W/16)+(H/16)-1 rows

For Idefics3, InternVL, and Llama4, the symbolic num_tiles input 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

  • Semantically rebased onto main@50bb373f0fce5aeb3bda463709ca7beb48d64b00 (Decouple export from downstream runtime capability gates #688), retaining its advisory runtime policy and regenerated census/docs.
  • Immutable sparse-header preflight covered every promoted route; artifacts and processors are pinned in the generated evidence census and remain within the 16 GiB budget.
  • 226 focused projector, mapping, pairing, census, documentation, and independent numerical parity tests passed.
  • One- and three-tile executable tests for Idefics3, InternVL, and Llama4 prove symbolic input shape, cardinality, batch-major tile/raster ordering, image-presence metadata, and parity with independently executed single tiles.
  • 9,038 broad non-integration tests passed, with 64 skipped and one subtest passed.
  • Llama4 full-tower independent parity uses head_dim=8, which distinguishes adjacent complex-pair rotation from the incorrect split-half layout.
  • Targeted mypy passed for all new/shared projector sources.
  • lintrunner -a passed.
  • Independent medium-effort final review found no remaining issues.
  • The inline image-presence review thread was answered and resolved.
  • Temporary GGUF headers, sparse files, extracted sources, and scratch payloads were removed before publication.

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 28, 2026 15:55
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 50bb373 → 09492a5

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 324 KB 324 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +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 265 265 +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 127 127 +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 450 450 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 176 176 +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.

justinchuby and others added 5 commits August 28, 2026 08:57
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]>
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 50bb373 → 09492a5

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)

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 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.

Comment thread src/mobius/tasks/_gguf_projector.py Resolved
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
justinchuby force-pushed the justinchuby-add-core-vlm-projectors branch from c1f88c7 to c86ae99 Compare August 28, 2026 16:12
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
justinchuby merged commit f494a75 into main Aug 28, 2026
16 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-add-core-vlm-projectors branch August 28, 2026 16:26
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
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