Repository navigation
Add OCR and document GGUF projector cohort - #691
Merged
Merged
Conversation
Performance Comparison
|
🏗️ 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 adds first-class support for exporting standalone GGUF multimodal projector sidecars for an OCR/document-focused cohort, including a new public entrypoint that requires callers to specify the exact projector route and paired text architecture (rather than synthesizing or implicitly omitting decoders).
Changes:
- Introduces standalone projector
ModelTasks and abuild_mmproj_from_gguf(...)API path for explicit sidecar-role export. - Implements OCR/document GGUF sidecar builder + tensor-name mapping, and expands mmproj validation (typed metadata checks, suffix-closure enforcement, variant/indexed tensor families, deferred-companion quarantine, and per-route shape validation).
- Adds reusable OCR projector components and extensive unit tests; updates docs and route census expectations accordingly.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/mobius/tasks/_gguf_projector.py | Adds standalone tasks/models for exporting vision/audio/speaker projector components without a text decoder. |
| src/mobius/tasks/init.py | Exposes the new GGUF projector task/model symbols via the tasks public API. |
| src/mobius/integrations/gguf/_route_census_test.py | Updates expected route-category counts to account for new classifications. |
| src/mobius/integrations/gguf/_ocr_projector.py | Adds standalone OCR/document sidecar builder, module selection, and weight mapping logic. |
| src/mobius/integrations/gguf/_ocr_projector_test.py | Adds coverage for header evidence, tensor closure enforcement, mapping behavior, and role emission. |
| src/mobius/integrations/gguf/_mmproj.py | Adds build_mmproj_from_gguf, standalone preflight, and expands tensor-closure + shape/metadata validation features. |
| src/mobius/integrations/gguf/_mmproj_registry_test.py | Updates registry tests for new supported projector routes, artifact pins, and metadata schema additions. |
| src/mobius/integrations/gguf/_mmproj_mapping.py | Adds OCR/document tensor-to-ONNX mapping (map_ocr_projector_to_onnx) and helper mappers. |
| src/mobius/integrations/gguf/_docs.py | Documents the new standalone sidecar build flow and OCR/document cohort evidence approach. |
| src/mobius/integrations/gguf/_docs_test.py | Adjusts doc-line-count guard to accommodate new generated documentation content. |
| src/mobius/integrations/gguf/init.py | Exports build_mmproj_from_gguf from the gguf integrations package. |
| src/mobius/components/_sam_vision.py | Extends SAM vision encoder to support rel-pos/pos-embed resizing and configurable MLP activation; fixes window pad ordering. |
| src/mobius/components/_ocr_projectors.py | Adds reusable OCR/document projector blocks (Dots, PaddleOCR, YouTu-VL, LightOn, DeepSeek, Dots3Note audio). |
| src/mobius/components/_ocr_projectors_test.py | Adds numerical parity tests for the new projector blocks vs independent PyTorch references. |
| src/mobius/components/_ocr_encoders_test.py | Adds independent numerical parity and execution tests for new OCR/document encoders and fp16 rotary behavior. |
| src/mobius/components/init.py | Exposes new OCR/document components via the components public API. |
| docs/api/build_from_gguf.md | Updates generated GGUF support documentation to include standalone mmproj export and OCR cohort evidence. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
justinchuby
force-pushed
the
justinchuby-add-ocr-projector-cohort
branch
3 times, most recently
from
August 28, 2026 19:00
d946217 to
cca5df4
Compare
Implement exact standalone graph import for nine OCR and document sidecar routes, including typed metadata and suffix-exact closures, processor-native media contracts, mixed Dots vision/audio roles, immutable range-read header evidence, and independent numerical parity. Keep quantized sidecars and downstream runtime claims fail-closed while preserving route pairing and source fingerprint isolation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: dc949491-5a7d-40f0-afb8-dd76d1738594 Signed-off-by: Justin Chu <[email protected]>
Remove an unused route-local variable, use tuple suffix matching, and retain unambiguous regex assertions after rebasing the generated surfaces onto latest main. Co-authored-by: Copilot App <[email protected]> Copilot-Session: dc949491-5a7d-40f0-afb8-dd76d1738594 Signed-off-by: Justin Chu <[email protected]>
Keep the onnxscript float32 retention marker explicit to mypy while preserving fp16/bf16 rotary frequency execution. Co-authored-by: Copilot App <[email protected]> Copilot-Session: dc949491-5a7d-40f0-afb8-dd76d1738594 Signed-off-by: Justin Chu <[email protected]>
Prioritize mixed audio namespaces, cover every real tensor with an explicit encoder/projector role, and document the three pinned upstream compatibility tensors that are serialized but graph-inert. Co-authored-by: Copilot App <[email protected]> Copilot-Session: dc949491-5a7d-40f0-afb8-dd76d1738594 Signed-off-by: Justin Chu <[email protected]>
Regenerate the GGUF support census after promoting the nine OCR routes and correct DeepSeek positional interpolation, CLS ordering, antialiasing, and exact SAM GELU semantics found by independent review. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Preserve the canonical multi-output audio task from PR #690, remove the duplicate replayed task, and regenerate shared registry census and documentation after promoting the OCR routes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Record the processor-to-graph adapter boundary explicitly: split packed processor rows into one image per encoder invocation and concatenate outputs in original image order. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Both Dots3Note route identifiers intentionally build the co-resident vision and audio roles, so remove the shadowed audio-only fallback noted during PR review. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Add explicit DeepSeek local-crop presence inputs and overview-only cardinality, retain Dots/Paddle/YouTu rotary math in float32 through trigonometry, reject invalid LightOn/YouTu head geometry, and fail closed on invalid Dots expert top-k values. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Require LightOnOCR and YouTu-VL head dimensions to be divisible by four so their split 2D rotary layout remains shape-compatible. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Apply the shared two-dimensional RoPE head-dimension constraint to Dots and PaddleOCR as well as LightOnOCR and YouTu-VL. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Declare independent image and audio presence metadata for the Dots3Note mixed sidecar components so downstream workflow assembly can omit absent modalities. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Preserve PR #694 projector builders and evidence while restoring OCR audio validation, registry expectations, census counts, and generated documentation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Thread empty local batches safely through SAM attention, slice DeepSeek placeholder inputs before local encoding, and reject incompatible Dots3Note audio rotary geometry. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Use ONNX control flow to bypass local encoders for processor zero-crop placeholders while preserving captured parameter names, and complete Dots3Note audio rotary geometry validation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Preserve PR #696 standalone audio routes while restoring the OCR registry order, completed route census, and generated support documentation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Fail preflight and component construction when OCR2 head geometry cannot split rotary dimensions into equal pairs. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Remove the fixed 512-position lookup from Dots, PaddleOCR, and YouTu-VL so long-aspect processor grids compute unbounded float32 frequencies before reduced-precision attention casts. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Regenerate the GGUF support document after rebasing the OCR projector matrix onto PR #693's export-status and tokenizer-reporting changes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Verify complete initializer loading, emit OCR-aware quantization reports, and persist source identity, component schemas, output width, pairing, and runtime advisory metadata. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
Pass the bound empty-branch builders directly when constructing both ONNX If subgraphs. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24 Signed-off-by: Justin Chu <[email protected]>
justinchuby
force-pushed
the
justinchuby-add-ocr-projector-cohort
branch
from
August 28, 2026 19:24
cca5df4 to
1c5253d
Compare
justinchuby
added a commit
that referenced
this pull request
Aug 28, 2026
## Summary - Add exact target/draft GGUF pair construction with separate cache namespaces, target hidden-state outputs, shared embedding/LM-head bridges, atomic package publication, and self-verifying graph identities. - Add a direct ONNX Runtime greedy coordinator for DFlash and EAGLE3 with accepted-prefix verification, target/draft cache rollback, compressed-vocabulary remapping, strict output-capacity bounds, and target-only baseline comparison. - Add a separate test-only direct ORT oracle that imports neither `DraftPairRunner` nor production transition helpers, derives target-layer/remap/block/mask contracts from raw immutable GGUF metadata, and compares production behavior against independently recorded transitions. - Make EAGLE3 consume real draft-owned embeddings, normalize GGUF/HuggingFace hidden-state indices correctly, and preserve fully-owned cross-width variants. - Semantically rebase onto exact current `main` at `d68f66418096e0fe9a073764b819d6898de314de`, integrating #696, #693, and #691 while retaining shared MTP cache/publication/status infrastructure without duplication. - Keep higher-level runtime compatibility advisory; no production revision pin or downstream runtime gate is added. ## Immutable evidence Evidence is bound in `testdata/evidence/gguf_draft_runtime_evidence.json` (13,293,887,389 bytes total, below the 16 GiB cap), including artifact/config/tokenizer/source/graph/package/runtime hashes. Separate SHA-256-bound independent traces record every proposal ID/remapped token and proposal-logit digest, posterior/accepted prefix/correction, target verification/replay logits and tokens, target/draft cache lengths and tensor digests before/tentative/committed/replay states, final cache states, exact counters, and the explicit batch-size-one reorder disposition. - **DFlash:** `Qwen/Qwen3-4B-GGUF@bc640142...` + `AtomicChat/Qwen3-4B-DFlash-GGUF@b53c7de6...`; 32/32 direct-ORT greedy tokens equal target-only, 18/75 proposals accepted, 3 multi-token rounds, 5 rejected-suffix rollbacks. Independent full-tensor Q8 source comparison: cosine `0.999879`, relative L2 `0.005406`. - **EAGLE3:** `Qwen/Qwen3-8B-GGUF@7c41481f...` + `williamliao/Qwen3-8B-EAGLE3-Speculator-GGUF@44480ff4...`; 32/32 direct-ORT greedy tokens equal target-only, 20/43 proposals accepted, 7 multi-token rounds, 10 rejected-suffix rollbacks. Independent pinned llama.cpp conversion matches all 15 tensor names, qtypes, shapes, and values exactly. - Pinned llama.cpp additionally exercised the real acceptance loops with 49/114 DFlash and 45/85 EAGLE3 accepted tokens. - Four mutations now alter execution before validation: wrong mapping/order is fed through target verification, draft-cache corruption is threaded into the next round, and target rollback corruption is replayed against full committed history. Each fails its distinct semantic invariant. Target Q4_K/Q6_K imports truthfully report lossy INT4 affine block-32 repacking; target-only and speculative comparisons use the same repacked target graph. Every target replay starts from an empty cache and rebuilds the complete prompt plus committed token history. Quantized batched verification and full-history replay can differ numerically, so both states are bound and maximum absolute differences are recorded (DFlash `1.967625`, EAGLE3 `0.912386`) while replay argmax tokens must match exactly. Draft replay likewise reconstructs the complete committed history from empty state. Production DFlash uses target-only tail generation when fewer than one fixed block remains; EAGLE3 caps each final proposal width to `remaining - 1`. Parametric tests prove target sessions, caches, and counters never process beyond requested `max_new_tokens` for remaining capacity 1 through width+1. The reference coordinator is batch-size 1 and truthfully reports beam/reorder unsupported. Higher-level execution remains `runtime_unvalidated` without gating export. ## Validation - Final exact-main broad non-integration suite: 9,668 passed, 64 skipped, 1 subtest passed. - Final affected draft+MTP+CLI/evidence/docs/census suite: 302 passed, 2 real-artifact probes skipped by opt-in. - Both immutable real-artifact probes were rerun after the three blocker fixes; all eight execution-mutating discriminator runs failed at their expected semantic invariants. - Pinned Ruff format/lint, generated GGUF docs, and focused isolated mypy passed. `_config_mapping.py` retains three unrelated pre-existing mypy errors outside the DFlash change. - Final medium review specifically verified execution-mutating discriminators, complete empty-cache target replay, bounded final-round production behavior, DFlash mask metadata propagation, and semantic #693/#691 conflict resolution; no significant findings remain. No CI monitoring or merge is requested. --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]>
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
deepseekocr,deepseekocr2,dots3note_a,dots3note_v,dots_ocr,granite4_vision,lightonocr,paddleocr, andyoutuvlbuild_mmproj_from_gguf()without synthesizing a text decoder or gating export on downstream runtime supportRoutes and immutable evidence
Pinned semantic source:
ggml-org/llama.cpp@8d9af256337d1a501250f9bbf4c0859a654bddd6.deepseekocrdeepseek2-ocrsabafallah/DeepSeek-OCR-GGUF@d26779bcd1cb301fec3ff82adc672f18384776fcdeepseekocr2deepseek2-ocrsabafallah/DeepSeek-OCR-2-GGUF@d08e5af400c64fa8a9b89b04ba373b600b02e05ddots_ocrqwen2ggml-org/dots.ocr-GGUF@2c093a32ca360a396bc6d87d60408636130b9d9bdots3note_v/dots3note_adots3noteggml-org/dots3-note-prev-GGUF@e5e7f6692337c0782c2bb4e2395174fd99879448paddleocrpaddleocrPaddlePaddle/PaddleOCR-VL-1.6-GGUF@511b09642bb324401f15f97cc23bc67e8f0a291dlightonocrqwen3noctrex/LightOnOCR-1B-1025-GGUF@fe9d27bebcd975de319b2129a700791e6c9e00aeyoutuvldeepseek2tencent/Youtu-VL-4B-Instruct-GGUF@1b7e295135d85a169d93823aa4215faf2c427092granite4_visiongraniteibm-granite/granite-vision-4.1-4b-GGUF@b1fa14294b0f5cac04c43076d1c4574091abf117Only the first 8-16 MiB of each immutable sidecar and paired-text header were range-read. The complete parsed metadata/tensor inventories and isolated fingerprints are committed as
tests/data/gguf_ocr_projector_headers.json.xz; all downloaded sparse files and processor caches were deleted. Every selected sidecar is individually below 16 GiB, including the 15,546,328,640-byte Dots3Note F16 sidecar.Graph and processor contracts
runtime=DEFERREDremains truthful for every route. Standalone export emits a warning that downstream multimodal assembly is unvalidated. Packed/quantized mmproj tensors fail closed; callers need F32/F16/BF16 sidecars. There are no production model-ID or revision gates.Validation
438 passed9115 passed, 64 skipped, 12 deselected, 1 subtest passedlintrunner f --output oneline --all-fileslintrunner -a --output onelinepython scripts/generate_gguf_support_docs.py --checkgit diff --check origin/main...HEAD0errors (13pre-existing_mmproj.pyerrors outside changed lines)Capability waivers
Real-weight full-sidecar execution and L4/L5 generation are not claimed: the cohort uses immutable range-read headers plus reduced independent numerical graph parity so it stays within the artifact budget. Downstream runtime validation is intentionally deferred and is not an ONNX export gate.
Base:
50bb373f0fce5aeb3bda463709ca7beb48d64b00Head:
7ef5be18cfe9fe545dba11ec1e221e3f84bd627b