Skip to content

Add pinned GGUF mmproj capability registry - #584

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby-add-mmproj-gguf-cohort
Aug 25, 2026
Merged

justinchuby merged 3 commits into
mainfrom
justinchuby-add-mmproj-gguf-cohort

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • enumerate all 60 serialized llama.cpp clip projector types at 8d9af256337d1a501250f9bbf4c0859a654bddd6 in an immutable capability registry
  • support only exact, audited Gemma4 vision (gemma4v) and Muse Glimmer (muse-glimmer) sidecars; fail before graph construction for unknown, deferred, mismatched, quantized, or out-of-closure projectors
  • validate pinned metadata, tensor suffixes/shapes/qtypes, source and target identity, projector dimensions, and media-token contracts
  • preserve Gemma4 clipping bounds, correct its spatial pooling to 3x3, and document audited artifacts plus all projector verdicts
  • add registry closure/mutation, mixed quantized-text, early rejection, package round-trip, and independent NumPy/ORT encoder-projector parity tests

Validation

  • PYTHONPATH=src python -m pytest src/mobius/integrations/gguf/_mmproj_registry_test.py src/mobius/integrations/gguf/_mmproj_mapping_test.py src/mobius/integrations/gguf/_mmproj_test.py src/mobius/integrations/gguf/_reader_test.py -q --tb=short — 126 passed
  • lintrunner f --output oneline --all-files — passed
  • broad non-integration suite — 5963 passed, 52 skipped; two unrelated existing glm_moe_dsa symbolic-shape/checker failures remain

Stacked on #583.

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing aecebbc → 0768c8c

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 1 🔴
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 ⚪
gemma4 (gemma4) / vision_encoder — 1 change(s)

Op summary: 176 → 176 nodes

No op-sequence changes.

Interface changes:

  • input[0]: shape ['?', '?', '588'] → ['1', '?', '588']; input[1]: shape ['?', '?', '2'] → ['1', '?', '2']

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

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing aecebbc → 0768c8c

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 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 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 264 264 +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 126 126 +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 428 428 +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
justinchuby force-pushed the justinchuby-add-draft-gguf-cohort branch from 5102565 to 7488b89 Compare August 25, 2026 15:38
Base automatically changed from justinchuby-add-draft-gguf-cohort to main August 25, 2026 15:38
@justinchuby
justinchuby requested a review from a team August 25, 2026 15:38
Enumerate the llama.cpp clip projector ABI at the pinned revision and route supported Gemma4 and Muse Glimmer sidecars through an immutable fail-closed registry. Validate metadata, tensor closure, target pairing, dimensions, media tokens, and tensor qtypes before graph construction.\n\nCorrect Gemma4 pooling and clipping-bound handling, document every projector verdict and audited artifact pin, and add registry, mixed-quantization, rejection, and independent NumPy/ORT parity coverage.\n\nCo-authored-by: Copilot App <[email protected]>

Signed-off-by: Justin Chu <[email protected]>
Constrain Gemma4 vision exports to their actual single-image pooling contract. Validate the complete sidecar tensor inventory, including an exact deferred Gemma4 audio companion closure and shape policy, so unknown tensors cannot be silently dropped.\n\nRequire stable name and optional base-repository identity bindings across text and projector GGUFs, independent of file relocation. Add regression coverage for closure mutations, companion ranks, identity failures, relocation, and the static batch contract.\n\nCo-authored-by: Copilot App <[email protected]>\nCopilot-Session: cc4ea80d-0194-436b-b31b-84a8a8a42a2a

Signed-off-by: Justin Chu <[email protected]>
Preserve meaningful separators in source identities, distinguish missing metadata from empty values, and reject whitespace-only bindings while retaining conservative URL normalization.\n\nRequire Gemma4 RGB rank-4 patch weights exactly matching the exported graph and validate every pinned active Gemma4 audio field, including positive integer mel-bin metadata, before graph construction. Add collision, presence, shape, and audio metadata regressions.\n\nCo-authored-by: Copilot App <[email protected]>\nCopilot-Session: cc4ea80d-0194-436b-b31b-84a8a8a42a2a

Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-add-mmproj-gguf-cohort branch from 33a0d38 to 0768c8c Compare August 25, 2026 15:41
Copilot AI lite review requested due to automatic review settings August 25, 2026 15:41
@justinchuby
justinchuby merged commit b425a9f into main Aug 25, 2026
11 of 17 checks passed
@justinchuby
justinchuby deleted the justinchuby-add-mmproj-gguf-cohort branch August 25, 2026 15:41

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 adds a pinned, fail-closed capability registry for GGUF clip (mmproj) sidecars and tightens VLM assembly to only proceed for exact, audited projector + text-architecture pairings. It also updates Gemma4 vision import semantics (clipping + pooling) and introduces broader preflight validation and parity tests for supported paths.

Changes:

  • Introduces an immutable mmproj capability registry pinned to a specific llama.cpp commit, with explicit support gates and audited artifact pins for gemma4v and muse-glimmer.
  • Adds strict preflight validation for text/mmproj pairing (identity bindings, tensor closure, qtypes, shapes, target matching) and removes “fallback to Gemma4” VLM dispatch behavior.
  • Updates Gemma4 vision encoder contract to be explicitly single-image ([1, N, ...]), enables ClippableLinear bounds ingestion, and updates/extends unit + numerical parity tests and documentation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/mobius/tasks/_gemma4.py Updates Gemma4 vision encoder I/O contract to explicitly single-image batch and documents variable pooled token count constraints.
src/mobius/integrations/gguf/_reader.py Adds get_tensor_shape() to retrieve logical tensor shapes without dequantizing payloads.
src/mobius/integrations/gguf/_mmproj.py Adds mmproj preflight validation (identity, closure, qtypes/shapes), enforces early rejection, and tightens VLM builder dispatch based on supported projector specs.
src/mobius/integrations/gguf/_mmproj_test.py Extends synthetic mmproj writers and adds preflight guard tests plus independent NumPy/ORT parity checks.
src/mobius/integrations/gguf/_mmproj_registry.py Adds the pinned projector census + support gates and audited artifact pin metadata for supported projectors.
src/mobius/integrations/gguf/_mmproj_registry_test.py Adds closure/immutability tests and doc-matrix synchronization checks for the registry.
src/mobius/integrations/gguf/_mmproj_mapping.py Updates mapping to treat Gemma4 clipping bounds as learned parameters (not skipped stats).
src/mobius/integrations/gguf/_mmproj_mapping_test.py Updates mapping tests to assert clipping bounds are mapped for Gemma4 vision.
src/mobius/integrations/gguf/_builder.py Avoids misclassifying clip sidecars as standalone LMs in auxiliary quantization checks.
docs/api/build_from_gguf.md Documents pinned projector support matrix, audited artifacts, and the stricter pairing/closure rules.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +919 to +929
def projector_type_for_modality(metadata: Mapping[str, Any], modality: MMProjModality) -> str:
"""Resolve the pinned global-key then modality-key projector fallback."""
projector_type = metadata.get("clip.projector_type")
if not projector_type:
projector_type = metadata.get(f"clip.{modality.value}.projector_type")
if not isinstance(projector_type, str) or not projector_type:
raise ValueError(
f"clip mmproj has an active {modality.value} encoder but neither "
f"'clip.projector_type' nor 'clip.{modality.value}.projector_type' is set."
)
return projector_type
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.

3 participants