Skip to content

Support complete sharded GGUF imports - #652

Closed
justinchuby wants to merge 1 commit into
mainfrom
justinchuby-implement-sharded-gguf
Closed

justinchuby wants to merge 1 commit into
mainfrom
justinchuby-implement-sharded-gguf

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • assemble a complete local GGUF shard set as one lazy logical model while retaining every reader/memmap
  • validate filename identity, contiguous split.no, matching split.count and split.tensors.count, compatible metadata/container properties, tensor extents, and unique tensor names
  • resolve Hugging Face shard references as an exact complete set pinned to one immutable commit, with cache-aware total-size/free-space preflight before downloads
  • preserve single-file behavior, quantized tensor import, and runtime artifact identity hashing across Hub snapshot symlinks
  • document generated user-facing shard behavior

Tests

  • python -m pytest src/mobius/integrations/gguf/_reader_test.py src/mobius/integrations/gguf/_shard_set_test.py src/mobius/integrations/gguf/_preflight_test.py src/mobius/integrations/gguf/_runtime_evidence_test.py src/mobius/integrations/gguf/_builder_test.py -q --tb=short (538 passed)
  • python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q -k 'not phi4mm and not apply_weights_unknown' --tb=short (8,362 passed, 57 skipped, 12 deselected)
  • lintrunner f --output oneline --all-files
  • lintrunner -a

All shard coverage uses tiny generated GGUF files and mocked Hub metadata/download boundaries. The motivating multi-gigabyte artifact was not downloaded.

Assemble strict local shard sets as one lazy logical GGUF model and resolve Hub sets at an immutable revision with cache-aware capacity preflight. Preserve quantized tensor paths, deterministic metadata, runtime identity hashing, and single-file behavior.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 26, 2026 15:27
@github-actions

Copy link
Copy Markdown

Performance Comparison

Comparing ee521b0 → eacf244

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.

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds first-class support for split (multi-shard) GGUF models across local files and Hugging Face Hub references, including stricter shard-set validation and stable artifact identity hashing.

Changes:

  • Extend sharded GGUF assembly/validation (container compatibility checks, deterministic merged metadata, tensor source routing).
  • Add Hugging Face Hub shard-set resolution/download that pins an immutable commit, preflights cache space, and blocks incomplete sets.
  • Update runtime evidence to hash “identity paths” (regular-file blob targets) while preserving logical shard filenames.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/mobius/integrations/gguf/_shard_set.py Adds merged metadata, container compatibility validation, tensor source helpers, and identity-path plumbing for shard sets.
src/mobius/integrations/gguf/_builder.py Implements Hub shard-set selection, pinned complete-set downloads with free-space preflight, and binds shard identity paths for evidence hashing.
src/mobius/integrations/gguf/_runtime_evidence.py Hashes shard “identity paths” (regular files) while incorporating logical shard filenames into the digest.
src/mobius/integrations/gguf/_reader.py Exposes _tensor_source() to support per-tensor parsing against the owning file/offset.
src/mobius/integrations/gguf/_shard_set_test.py Adds tests for metadata-only first shard, split metadata mismatches, and Hub shard resolution behavior.
src/mobius/integrations/gguf/_runtime_evidence_test.py Adds test coverage for identity hashing with snapshot symlinks resolving to blob files.
src/mobius/integrations/gguf/_builder_test.py Adds sharded quantized build coverage and updates incomplete-shard Hub failure expectations.
src/mobius/integrations/gguf/_docs.py Documents split GGUF behavior and Hub pinning/preflight guarantees.
src/mobius/integrations/gguf/init.py Updates public example usage to include local and Hub shard references.
docs/api/build_from_gguf.md Mirrors docs update for split GGUF and Hub shard resolution behavior.

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

justinchuby added a commit that referenced this pull request Aug 27, 2026
## Summary

- classify every unresolved authoritative GGUF architecture, projector,
tokenizer, MTP, and speculative-draft route exactly once
- generate concrete implementation, evidence, ABI/dependency, artifact,
and rejection batches from live registries
- preserve exact registry reasons in machine-readable census records and
reconcile PRs #645, #651, #652, and #656 without claiming open work as
supported
- distinguish ordinary runtime evidence from ORT GenAI
heterogeneous-state schema issue #605
- pin availability-only F16/Q8_0 sidecar identities for LFM2-VL and
Pixtral without implying tensor closure, graph parity, or runtime
support

## Census

- 285 unresolved routes: 144 architectures, 60 projectors, 57
tokenizers, 22 MTP routes, and 2 draft routes
- 67 immediately implementable
- 95 evidence-only
- 100 dependency/runtime-ABI blocked
- 4 artifact unavailable
- 19 intentionally rejected

## Validation

- generated documentation check
- 1,371 focused GGUF tests passed, 1 skipped
- broad deterministic suite: 8,467 passed, 62 skipped, 1 subtest passed
- Ruff/format lint passed
- strict mypy passed for changed source modules
- independent incremental review found no significant issues

## Waivers

- no large model payloads downloaded; availability pins use immutable
repository revisions plus API-reported LFS SHA-256 and byte size
- open PRs #651/#652/#656 are dependency records only and are not
promoted as current-main capability
- no unsupported cache/state ABI is forced; packed quantized support
remains governed by existing fail-closed capability records

Do not merge yet.

---------

Signed-off-by: Justin Chu <[email protected]>
Copilot-Session: d1a98adf-88cb-471b-8c46-7a84083db24c
justinchuby added a commit that referenced this pull request Aug 27, 2026
## Stack

- Depends on #655 (`justinchuby-finish-qwen4exp-core`).
- Includes the sharded GGUF importer commit from #652
(`eacf244864284cc96bd70f1187b145446783aab4`) so the three-file artifact
is evaluated as one complete model.

## Summary

- register `general.architecture=qwen4exp` as `qwen4_exp_text` with the
exact Qwen3.8 Flash-Next config, DeltaNet/QSA schedule,
hyper-connections, PLE, routed/shared MoE, and output HC mixer metadata
- pin
`unsloth/Qwen3.8-Flash-Next-GGUF@d3bc75ee6ccef3efc1e228ec00a6cc2cdb1e2249`,
all three shard sizes/LFS SHA-256 identities, and the metadata-only
shard-0 closure `0 + 595 + 629 = 1224`
- map every GGUF tensor family, including GGUF split indexer Q/K rows
reconstructed exactly into Hugging Face's fused `index_qk_proj`
- validate every tensor name, logical shape, and dynamic qtype using the
complete bounded-header manifest digest
`25a1e6a2073caf19d3a3835dd23702a19fa09cc651506e11a13de7b48076359d`
- preserve existing official fused HF indexer checkpoints while
accepting only the exact GGUF split representation on the GGUF path
- fail closed before Hub payload download when header policy cannot be
established, source/revision/shard identity differs, or either payload
mode is requested

## Fail-closed payload policy

The only published `UD-IQ1_S` route is intentionally not emitted as an
executable ONNX payload:

- `per_layer_token_embd.weight` is an enormous IQ4_NL embedding with no
compatible native gather ABI
- rank-3 routed expert banks dynamically mix IQ1_S/IQ2_XXS gate/up with
IQ4_NL down tensors; released runtime evidence does not establish a
matching mixed-format sparse native-block MoE ABI
- these tensors are not ordinary affine rank-2 `MatMulNBits`
- float32 dequantization would materialize roughly 191 GiB for the PLE
table alone, exceeding the bounded 8 GiB single-tensor policy

The exact header/config/mapping support is therefore a truthful
preflight foundation for future ABI work, not a quantized-runtime claim.

## Validation

- targeted Qwen4Exp/GGUF/registry review suite: `1187 passed, 2 skipped`
- complete GGUF + Qwen4Exp + graph serial suite: `4865 passed, 54
skipped`
- broad serial non-integration suite: `8409 passed, 64 skipped, 12
deselected, 1 subtest passed`
- `lintrunner f --output oneline --all-files && lintrunner -a`: clean
- GPT-5.6 Sol medium review run twice; fused-HF compatibility, complete
qtype evidence, config pinning, and Hub fallback findings were resolved

## Waivers

- No full payload download, real-weight runtime execution, L4, or L5
claim is made for the GGUF route. The exact pinned artifact is
deliberately rejected before its 72+ GB payload is downloaded because
neither supported native preservation nor bounded dequantization is
truthful under the current Mobius/ORT ABI.
- Runtime support remains deferred. This PR must not be interpreted as
ORT or ORT GenAI execution evidence for the quantized artifact.

---------

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@justinchuby

Copy link
Copy Markdown
Member Author

Closing as superseded by the sharded GGUF implementation and subsequent hardening that landed through the Qwen4Exp/mainline work. The unresolved Copilot findings are being audited against current main; any still-applicable gaps will be fixed in a focused follow-up rather than merging this conflicting historical branch.

justinchuby added a commit that referenced this pull request Aug 27, 2026
## Summary

- resolve local sharded-GGUF symlinks to their verified regular-file
targets before artifact identity hashing, while retaining logical shard
filenames in the digest
- make missing `split.count`, `split.no`, and `split.tensors.count`
diagnostics deterministic
- add regressions covering the `build_from_gguf` symlink path, artifact
hashing, missing targets, and reversed shard ordering

This follows up on the still-applicable Copilot findings from #652 after
its sharded import functionality was superseded on `main` by #656.

## Validation

- `python -m pytest src/mobius/integrations/gguf/_shard_set_test.py -q
--tb=short` (51 passed)
- `python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q
-k "not phi4mm and not apply_weights_unknown" --tb=short -n auto` (8627
passed, 64 skipped)
- `lintrunner f --output oneline --all-files`
- independent code review: no findings

---------

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
justinchuby added a commit that referenced this pull request Aug 27, 2026
Derive Granite routed expert width from feed_forward_length exactly, reject contradictory serialized expert widths without lossy numeric conversion, and reconcile the authoritative route census with closed #652 plus merged #656 and #675.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 71862fcb-bc9a-4734-b047-b5376afabc3e
Signed-off-by: Justin Chu <[email protected]>
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