Skip to content

Add dense GGUF architecture cohort - #572

Merged
justinchuby merged 1 commit into
mainfrom
justinchuby-gguf-dense-transformer-cohort
Aug 25, 2026
Merged

justinchuby merged 1 commit into
mainfrom
justinchuby-gguf-dense-transformer-cohort

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

Adds the first reviewable C01 dense-transformer GGUF cohort on top of #571, using llama.cpp commit 8d9af256337d1a501250f9bbf4c0859a654bddd6 as the tensor-family source of truth.

GGUF architecture mobius graph Config/tensor/graph Runtime
olmo OLMoCausalLMModel supported supported with pinned real GGUF evidence
olmo2 OLMo2CausalLMModel supported supported with pinned real GGUF evidence
cohere2 CohereCausalLMModel supported deferred pending real parity/generation evidence
arcee ArceeCausalLMModel supported deferred pending real parity/generation evidence
smollm3 SmolLM3CausalLMModel supported supported with pinned real GGUF evidence
exaone CausalLMModel supported deferred pending real parity/generation evidence

Architecture correctness

  • Adds exact pinned upstream tensor-family closure and a falsification test that removes a required mapping.
  • Rejects missing required metadata rather than synthesizing success-shaped configs.
  • Preserves OLMo weight-free LayerNorm, OLMo2 post-norm/full-width QK norms, Cohere2 parallel pre-norm/interleaved RoPE/3-sliding-1-full NoPE schedule, Arcee ReLU² non-gated MLP, and SmolLM3 every-fourth-layer NoPE behavior.
  • Explicitly rejects olmo2 files carrying OLMo3 sliding-window patterns until the graph supports per-layer sliding attention.
  • Fixes the existing InternLM2 Q/K reverse permutation with a direct value regression against pinned converter behavior.
  • Centralizes quantization-aware linear/embedding construction so specialized graph classes do not silently replace packed modules with float modules.
  • Rebinds tied quantized LM heads when specialized models replace their text backbones.

Real GGUF evidence

Pinned revisions, exact filenames, sizes, SHA-256 values, and per-tensor qtype tables are encoded in tests/gguf_dense_cohort_integration_test.py for:

  • QuantFactory/AMD-OLMo-1B-GGUF@5f34243a42dbae2141b8f5286320bf63d51eeefb
  • allenai/OLMo-2-0425-1B-Instruct-GGUF@62f8c199538474c3e33ed5d7e0580abd66686a27
  • ggml-org/SmolLM3-3B-GGUF@4965cb60b150737b68a0408c36aeefb65078f894

All three packages build, save, open in ORT CPU, and produce deterministic finite logits and pinned greedy outputs.

The mixed Q4_K_M files do not use native preservation. Q4_K and Q6_K projections are dequantized and affine-requantized to explicit-zero-point 4-bit/block-32 MatMulNBits; compatible embeddings use GatherBlockQuantized; float norm tensors remain float.

Explicit exclusions

The PR does not infer compatibility from common names. Deferred candidates include GPT-NeoX and Phi-2 (fused/interleaved or dual-form QKV), Baichuan and MPT (ALiBi), StarCoder (learned positions), and unproven Qwen/Command-R aliases. Large Command-R/Seed artifacts were not downloaded.

Validation

  • 1,112 GGUF unit tests
  • 52 affected model graph tests
  • 3 pinned real-GGUF integration tests
  • 5,511 broader non-integration tests
  • Changed-file lintrunner clean

The existing glm_moe_dsa symbolic shape-inference/checker failures reproduce independently and are excluded from the final broad run.

@github-actions

github-actions Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing b6d166a → 29d33a9

Model Sub-model Changes Status

No architecture changes detected. ✅


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

@github-actions

github-actions Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing b6d166a → 29d33a9

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-gguf-registry-foundation branch from 184176f to 3b52342 Compare August 25, 2026 14:48
Base automatically changed from justinchuby-gguf-registry-foundation to main August 25, 2026 14:49
@justinchuby
justinchuby requested a review from a team August 25, 2026 14:49
Add exact config and tensor mappings for OLMo, OLMo2, Cohere2, Arcee, SmolLM3, and Exaone against the pinned llama.cpp architecture census. Preserve architecture-specific normalization, RoPE, attention schedules, quantized module wiring, and InternLM2 Q/K permutation semantics.

Validate strict tensor closure, synthetic float and quantized graph execution, and pinned real OLMo-family GGUF artifacts while deferring runtime claims that lack real-weight evidence.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-gguf-dense-transformer-cohort branch from fbdc807 to 29d33a9 Compare August 25, 2026 14:54
Copilot AI lite review requested due to automatic review settings August 25, 2026 14:54
@justinchuby
justinchuby merged commit 05b4417 into main Aug 25, 2026
18 of 23 checks passed
@justinchuby
justinchuby deleted the justinchuby-gguf-dense-transformer-cohort branch August 25, 2026 14:55

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

Adds the first “C01 dense-transformer” GGUF cohort to the GGUF registry pipeline, including architecture-scoped config/tensor-map requirements, model-graph adaptations for quantization-aware modules, and pinned real-GGUF integration evidence where runtime is claimed.

Changes:

  • Extend the GGUF architecture registry/spec to cover olmo, olmo2, cohere2, arcee, smollm3, and exaone (including required-metadata gates and pinned upstream tensor-family closure).
  • Centralize quantization-aware embedding/linear construction and update several model classes to preserve tying behavior when swapping specialized text backbones.
  • Add synthetic and real-artifact tests plus documentation updates to make the new support boundary explicit and verifiable.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/gguf_dense_cohort_integration_test.py Adds pinned real-GGUF integration tests (download → hash/size/qtypes → build → save → ORT CPU run → deterministic logits/greedy token).
src/mobius/models/smollm.py Uses quantization-aware embedding/linear factories and swaps in the specialized SmolLM3 text backbone via _replace_text_model().
src/mobius/models/olmo.py Makes OLMo/OLMo2 text backbones quantization-aware and swaps them in via _replace_text_model().
src/mobius/models/cohere.py Adds dense-cohort Cohere2 semantics (sliding/full attention and per-layer RoPE gating) and uses quantization-aware linear factories.
src/mobius/models/base.py Introduces linear_class_for_config() / embedding_for_config() helpers and _replace_text_model() to preserve tying across specialized backbone swaps.
src/mobius/models/arcee.py Passes quantization-aware linear factory into the Arcee MLP component.
src/mobius/integrations/gguf/_upstream.py Extends pinned-upstream architecture representation to include exact tensor-family closures.
src/mobius/integrations/gguf/_upstream_data/llamacpp_pin.json Adds tensor_families entries for the new dense architectures in the upstream pin data.
src/mobius/integrations/gguf/_tensor_processors_test.py Adds InternLM2 Q/K permutation regression + dense-cohort permutation contract assertions.
src/mobius/integrations/gguf/_tensor_mapping.py Adds explicit tensor-name mapping tables/overrides for OLMo and Arcee plus OLMo2 extras.
src/mobius/integrations/gguf/_spec.py Adds required_metadata to GGUFArchitectureSpec and validates its consistency with support claims.
src/mobius/integrations/gguf/_config_mapping.py Adds required-metadata enforcement, Cohere2 head-dim/partial-RoPE handling, dense sliding/NoPE semantics, and OLMo clamp rejection.
src/mobius/integrations/gguf/_config_mapping_test.py Adds dense-cohort config mapping tests, including missing-required-metadata rejection coverage.
src/mobius/integrations/gguf/_builder_test.py Extends GGUF builder test fixtures to emit architecture-specific tensor sets and validates ORT CPU execution for the dense cohort.
src/mobius/integrations/gguf/_arch_registry.py Registers the new dense architectures with explicit support/deferred verdicts and required metadata.
src/mobius/integrations/gguf/_arch_registry_test.py Updates supported-count pin, adds pinned tensor-family closure tests, and tightens “supported” labeling to all-verdicts-supported.
docs/api/build_from_gguf.md Updates the support matrix and documents dense-cohort validation boundaries and pinned real-GGUF evidence.

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

Comment thread src/mobius/models/base.py
Comment on lines +433 to +444
def _replace_text_model(self, model: nn.Module) -> None:
"""Replace the text model while preserving tied embedding/head parameters."""
self.model = model
if isinstance(self.lm_head, TiedQuantizedLMHead):
self.lm_head = TiedQuantizedLMHead(
self.model.embed_tokens,
self.config.hidden_size,
self.config.vocab_size,
)
elif self.config.tie_word_embeddings:
self.lm_head.weight = self.model.embed_tokens.weight

Comment on lines +143 to +148
for layer_index, (layer, past_kv) in enumerate(zip(self.layers, past_kvs)):
layer_type = (
self.layer_types[layer_index] if self.layer_types else "full_attention"
)
use_rope = self.no_rope_layers is None or self.no_rope_layers[layer_index] == 1
hidden_states, present_kv = layer(
justinchuby added a commit that referenced this pull request Aug 25, 2026
## Summary

- add pinned llama.cpp (`8d9af256337d1a501250f9bbf4c0859a654bddd6`) GGUF
specs for `olmoe`, `phimoe`, `qwen2moe`, `qwen3moe`, and `granitemoe`
- implement exact metadata/config extraction, canonical Qwen aliases,
tensor-family closure, routing/norm/scaling semantics, and Granite
dense-vs-MoE dispatch
- preserve 3-D expert ordering through affine and native quantized
imports, split fused Phi QKV tensors, and preserve tied quantized
Qwen3/Granite embedding heads
- reverse llama.cpp's GraniteMoE Q/K row permutation in both float and
packed quantized imports
- map pinned expert `.scale`/`.input_scale` suffixes and reject affected
files before graph construction because Mobius cannot safely represent
NVFP4 scale2/activation-scale sidecars
- extend the same suffix-aware preflight to reachable MTP
`nextn.eh_proj` scale sidecars before either backbone or MTP graph
construction
- add generated support docs, negative closure/shape tests, and float/Q4
synthetic save-load-ORT coverage

Stacks on #572 (`justinchuby-gguf-dense-transformer-cohort`).

## Real artifact import evidence (runtime deferred)

### GraniteMoE

Validated with:

- repository: `bartowski/granite-3.0-1b-a400m-instruct-GGUF`
- repository revision: `0e1c3cecaa6e49ac0721be91ef441ec72eae62d4`
- file: `granite-3.0-1b-a400m-instruct-Q4_K_M.gguf`
- size: `821,845,024` bytes
- LFS SHA-256:
`074f09e13484e54e73c93830d34e9fa9917a6319fb8bae762a22594b9b4da0dc`
- source config/tokenizer:
`ibm-granite/granite-3.0-1b-a400m-instruct@ffec3c35bdfd97a06f0b4cd5fcc92cd9b1584445`
- stored qtypes: 73 F32, 144 Q4_K, 25 Q6_K

The pinned integration test verifies exact tensor closure, 24 routers,
2,304 routed expert projections, mixed-qtype routing, 2,401
`MatMulNBits` nodes including the tied quantized head, zero `QMoE`
nodes, ONNX save/load, full 49,155-token logits, and repeatable
three-token cached decoding. This is deterministic Mobius execution
evidence, not independent llama.cpp/HuggingFace parity, so GraniteMoE
runtime remains deferred.

## Runtime-DEFERRED

All five entries—`olmoe`, `phimoe`, `qwen2moe`, `qwen3moe`, and
`granitemoe`—have exact registry/config/tensor support and synthetic
float/Q4 ORT execution, but no qualifying independent real-weight
cross-runtime evidence.

The only compatible Phi representative found was
`tripathyShaswata/Phi-tiny-MoE-instruct-GGUF@873ccb08cd3380ee2c08573d45267fac9a6cc81b`,
file `Phi-tiny-MoE-instruct-Q8_0.gguf`, size `3,999,171,104` bytes,
SHA-256
`297fa09e906e18aaf03850e77d6de8d9ee8e246e00916ac09787ae2cf4bb6019`,
sourced from
`microsoft/Phi-tiny-MoE-instruct@2fe50e88d0e2a5a132563815686ea0dcc8e252b5`.
It was not downloaded because it is not a reasonably sized
representative.

## Validation

- `504 passed` full focused GGUF/model tests after the
Granite/expert-scale fixes
- `160 passed` focused MTP/builder/tensor-mapping tests after the MTP
scale preflight fix
- `1 passed` revised pinned Granite real-artifact integration test
- `5585 passed, 52 skipped` broad non-integration suite with
`glm_moe_dsa` excluded
- full `lintrunner f --output oneline --all-files`

The two excluded `glm_moe_dsa` shape-inference/checker failures
reproduce unchanged on the stack base and are unrelated to this cohort.

---------

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[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