Skip to content

Add exact BitNet, embedding, and Talkie GGUF tasks - #641

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby-exact-specialized-models
Aug 26, 2026
Merged

justinchuby merged 3 commits into
mainfrom
justinchuby-exact-specialized-models

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • add an exact dedicated BitNet graph with post-attention/post-FFN subnorms, ternary TQ1_0/TQ2_0 float-import proof, scalar projection-scale folding, and cached prefill/decode parity
  • add dedicated stateless bidirectional gemma-embedding and llama-embed feature-extraction graphs with pooling/output ABI, exact attention schedules/scales, optional Gemma dense heads, and package metadata
  • add an exact Talkie causal graph with weight-free RMSNorm, inverse NeoX RoPE, post-RoPE Q/K normalization, learned Q gain and embedding skip, logit scaling, and dynamic/static KV-cache behavior
  • add strict pre-build metadata/tensor closure, architecture-owned mappings, real-config YAML evidence, generated support docs, and fail-closed residual blockers

Promotion boundaries

  • BitNet: exact float import only. Packed preservation remains rejected because available target operators cannot encode ternary codebooks plus scalar sidecars exactly; runtime packaging remains deferred.
  • gemma-embedding: exact dense split-QKV profile, including symmetric local/full attention schedule and optional post-pooling dense modules.
  • llama-embed: exact dense, split-QKV, unbiased, full-head, default-RoPE profile. The pinned Nemotron artifact's factor-8 Llama 3 RoPE remains explicitly blocked.
  • Talkie: exact pinned scalar-gain/skip profile only. The public PocketAI artifact's hidden-width skip vector and missing pinned logit scale remain explicitly blocked.
  • Quantized embedding and Talkie imports remain rejected. Quantized BitNet claims are limited to value-proven dequantized float import; no packed runtime claim is made.

Evidence

  • nonzero NumPy/ORT Talkie prefill and decode parity, including cached normalized/RoPE K/V values
  • deterministic embedding parity proving future-token visibility, padding, local windows, pooling, dense projection, and no-cache ABI
  • synthetic package-level GGUF builds for both embedding architectures and Talkie
  • value-level TQ1_0/TQ2_0 packed decoding and BitNet HF/ORT cached parity
  • pinned real-artifact configs with explicit waivers where public files fall outside promoted closure

Validation

  • initialized all-files lint: clean
  • focused specialized gate: 62 passed, 1607 deselected
  • broad serial non-integration: 8297 passed, 57 skipped, 12 deselected, 1 subtest passed
  • direct GPT-5.6 Sol medium architecture/regression review completed; fixed fail-open Gemma dense-without-pooling profile and reran affected/full gates

Base: 6617fe2b69aa9b2cd1a08dbe18a7563ac4ad7f32

justinchuby and others added 3 commits August 25, 2026 20:03
Implement BitNet's attention and FFN subnorm topology, exact ternary dequantization with scalar projection scale folding, and strict tensor closure validation. Keep packed quantization and runtime packaging fail-closed until their independent value and generation evidence exists.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Implement dedicated bidirectional feature-extraction graphs for Gemma and Llama embedding GGUFs, including pooling, local attention, optional dense heads, strict tensor closure, and stateless package ABI.\n\nImplement Talkie's weight-free normalization, inverse NeoX RoPE, post-RoPE Q/K normalization, learned gains and skips, logit scaling, and causal KV-cache behavior. Reject unsupported public and quantized profiles explicitly and add value-based parity and package tests.\n\nCo-authored-by: Copilot App <[email protected]>\nCopilot-Session: 6f7146cd-ceda-48ee-a494-06d3b12bc12d

Signed-off-by: Justin Chu <[email protected]>
Associate the reviewed two-commit specialized GGUF delta with its Copilot session.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 6f7146cd-ceda-48ee-a494-06d3b12bc12d
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 26, 2026 03:23
@@ -0,0 +1,268 @@
# Copyright (c) Microsoft Corporation.
@github-actions

Copy link
Copy Markdown

Performance Comparison

Comparing 6617fe2 → 4f24dc9

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.

@github-actions

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 6617fe2 → 4f24dc9

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 import surface by adding dedicated “exact-float” model graphs and tasks for BitNet, two stateless embedding architectures (gemma-embedding and llama-embed), and the Talkie causal LM. It also tightens GGUF validation to fail closed earlier, updates the architecture registry/support matrix, and adds synthetic parity tests and pinned YAML evidence cases.

Changes:

  • Add new exact model implementations: BitNet (with attention/FFN sub-norms), Talkie (inverse NeoX RoPE + post-RoPE Q/K norm + embedding skip/logit scale), and stateless GGUF embedding models (GemmaEmbedding + LlamaEmbed).
  • Introduce a dedicated 2-input embedding feature-extraction task and route GGUF embedding architectures to it.
  • Extend GGUF validation, tensor mapping/processing, registry entries, tests, and documentation to reflect the newly “supported for float import” architectures.

Reviewed changes

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

Show a summary per file
File Description
tests/cli_test.py Updates a CLI guard test to use a still-deferred GGUF architecture (“pockettts”) now that Talkie is supported.
tests/build_graph_test.py Adjusts encoder graph assertions to account for the new 2-input stateless embedding ABI (no token_type_ids).
tests/_test_configs.py Adds tiny configs for BitNet, Talkie, and the two GGUF embedding module types.
testdata/cases/encoder/llama-embed-nemotron-8b-gguf.yaml Adds a pinned evidence case documenting fail-closed RoPE-scaling boundaries for llama-embed GGUF.
testdata/cases/encoder/embeddinggemma-300m-gguf.yaml Adds a pinned evidence case for gemma-embedding GGUF with environment/repro constraints.
testdata/cases/causal-lm/talkie-1930-13b-it-gguf.yaml Adds a pinned evidence case describing why the public Talkie artifact is out-of-scope for the promoted scalar profile.
testdata/cases/causal-lm/bitnet-b1_58-2b-4t.yaml Adds a pinned HF BitNet evidence case documenting current promotion boundaries.
testdata/cases/causal-lm/bitnet-b1_58-2b-4t-gguf.yaml Adds a pinned GGUF BitNet evidence case describing why legacy/public artifacts don’t close parity gates.
src/mobius/tasks/_feature_extraction.py Adds GGUFEmbeddingFeatureExtractionTask implementing the two-input stateless embedding ABI.
src/mobius/tasks/init.py Exports/Registers the new embedding feature-extraction task string → task mapping.
src/mobius/models/talkie.py Adds the dedicated Talkie causal LM graph implementation.
src/mobius/models/talkie_test.py Adds synthetic closure, mapping, and ORT prefill/decode parity tests for Talkie.
src/mobius/models/gguf_embeddings.py Adds dedicated stateless embedding graphs for gemma-embedding and llama-embed GGUF.
src/mobius/models/gguf_embeddings_test.py Adds synthetic closure, mapping, and numerical parity tests for the two embedding architectures.
src/mobius/models/bitnet.py Adds the dedicated BitNet causal LM graph (post-attention/post-FFN sub-norm topology).
src/mobius/models/bitnet_test.py Adds BitNet closure checks, qtype dequantization-by-value tests, scale folding tests, and synthetic HF/ORT cache parity.
src/mobius/models/init.py Exports the new model classes from the models package.
src/mobius/integrations/gguf/_upstream_gap_test.py Updates deferred-architecture parameterization now that BitNet is supported for float import.
src/mobius/integrations/gguf/_tensor_processors.py Adds a BitNet tensor processor to fold optional scalar *.scale tensors into dequantized weights.
src/mobius/integrations/gguf/_tensor_mapping.py Adds GGUF→HF mapping tables for embedding models, BitNet, and Talkie.
src/mobius/integrations/gguf/_config_mapping.py Adds postprocessors for Talkie and GGUF embedding profiles; enforces exact promoted subsets.
src/mobius/integrations/gguf/_builder.py Adds fail-closed validation hooks for BitNet/Talkie/embedding closures and routes embedding GGUF archs to the new task.
src/mobius/integrations/gguf/_builder_test.py Updates GGUF builder tests to reflect Talkie’s new status (removed from unrelated parameter sets).
src/mobius/integrations/gguf/_arch_registry.py Promotes BitNet, gemma-embedding, llama-embed, and Talkie to supported float import with explicit reasons/constraints.
src/mobius/integrations/gguf/_arch_registry_test.py Updates expected supported-count and per-architecture quantized verdict assertions.
src/mobius/components/_attention.py Adds an overridable _project_output() hook used by BitNet to insert post-attention sub-norm before o_proj.
src/mobius/_registry.py Registers the new model types and default model IDs for build() discovery.
src/mobius/_configs/_base.py Extends ArchitectureConfig with embedding dense head dimension fields needed by GGUF embedding graphs.
docs/api/build_from_gguf.md Updates the GGUF support matrix and per-architecture entries for new supported float-import routes.

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

Comment thread tests/_test_configs.py
Comment on lines +146 to +154
(
"bitnet",
{
"hidden_act": "relu2",
"tie_word_embeddings": True,
"rms_norm_eps": 1e-5,
},
True,
),
Comment on lines +35 to +48
def __init__(self, size: int, eps: float):
super().__init__()
self._scale = [1.0] * size
self._eps = eps

def forward(self, op: OpBuilder, hidden_states: ir.Value) -> ir.Value:
scale = op.CastLike(op.Constant(value_floats=self._scale), hidden_states)
return op.RMSNormalization(
hidden_states,
scale,
axis=-1,
epsilon=self._eps,
stash_type=1,
)
@justinchuby
justinchuby merged commit fcd5b3b into main Aug 26, 2026
17 of 27 checks passed
@justinchuby
justinchuby deleted the justinchuby-exact-specialized-models branch August 26, 2026 04:26
justinchuby added a commit that referenced this pull request Aug 26, 2026
## Summary

Promotes two exact graph-supported GGUF routes to runtime-supported
under the released `onnxruntime-genai==0.15.2` contract:

- Qwen2.5-0.5B-Instruct Q8_0:
`Qwen/Qwen2.5-0.5B-Instruct-GGUF@9217f5db79a29953eb74d5343926648285ec7e67`,
`qwen2.5-0.5b-instruct-q8_0.gguf`, 675,710,816 bytes, SHA-256
`ca59ca7f13d0e15a8cfa77bd17e65d24f6844b554a7b6c12e07a5f89ff76844e`, 291
tensors (`F32=121`, `Q8_0=170`).
- LFM2-350M F16:
`LiquidAI/LFM2-350M-GGUF@8fdc9d526b7ed346b19257551b05816c7912ecc2`,
`LFM2-350M-F16.gguf`, 711,482,304 bytes, SHA-256
`379ffdcbf08147c0313f6f1ce7ff558a2bc935eda633f4b46c52347032419c42`, 148
tensors (`F16=93`, `F32=55`).

Evidence binds exact artifact, import route, tokenizer assets/revisions,
graph identity, runtime-package identity, complete logits, 20-step
decode, deterministic generation, replay/rollback/non-vacuous batch
reorder, ModelPackage save/load, CLI publication, and OGA 0.15.2
execution. The inherited SmolLM runtime record was also refreshed after
#641 changed its route identity, with exact real parity and OGA probes
rather than accepting a structural fingerprint alone.

## Identities

- Qwen route
`f7391f2aac9a7617c1c10e397e91b6f31b80bb3c5f338966b46e7d3935246500`;
graph
`b0d1814ea69dddd405e30541e9009ba6fb73930f98538921d5c2eaa4a14f5d2c`;
package
`cb43c76e1bc3db07a6a3631c7a99e7c47b6891807fecffdb3b70fddd9c108173`.
- LFM2 route
`c961bba579ea33a2472a7c5d3f469c76f1f8c7aae8440a7eaa86bc6e878a42f4`;
graph
`2a15694cd5ff9f5c9f798feeca91cc41174842065ada80a18b288478725b3342`;
package
`87b8cdd1edc8c5be948716df3efe551f5fc8f96762d7ea3f99b27688ca9f24af`.
- Qwen tokenizer
`Qwen/Qwen2.5-0.5B-Instruct@a338b55dd21219a5f4da42bc11a9313d1a27d4cc`;
LFM2 tokenizer
`LiquidAI/LFM2-350M@73e3c253078a3b97c2e14b4c4665679f4d9b6d56`.

## Validation

- Exact Qwen and LFM2 final-main probes: passed.
- Refreshed SmolLM F16 parity/package and OGA 0.15.2 probes: passed.
- Refreshed SmolLM2 F16 and Q4/dequantized route probes: passed.
- Focused evidence/package/tokenizer/YAML gates: 626 passed, 9
deselected.
- Broad serial non-integration: 8,305 passed, 57 skipped, 12 deselected.
- Initialized all-files formatter and lint: passed.
- Direct GPT-5.6 Sol medium evidence/security review: fixed overlapping
HF/ORT/OGA lifetimes, added 2x free-space enforcement, tightened
Hub-cache symlink containment including parent escapes, aligned the 16
GiB ceiling, and added explicit stale-route fail-closed coverage.

## Census and scope

The documentation records the complete 90-route graph-supported census
and attempted/blocked candidates. Larger and unsupported
routes—including encoder/seq2seq registry gaps, GPT-2 combined-cache
ABI, recurrent-state limitations, and candidates lacking an exact
immutable <=16 GiB GGUF—remain deferred. No runtime claim is inferred
from graph construction alone.

Base: `fcd5b3bb42dbc2ca7ca4bc62e9ee502e8446085a` (#641). All named
artifact, package, graph, and isolated Hub caches were deleted after
evidence generation.

---------

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 43bb31ac-c136-44bc-8cdf-70cbcedd4a42
Copilot-Session: af2b8208-9638-4f6e-9651-7d3da21c0af8
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