Skip to content

Add exact Hunyuan V3 GGUF graph support - #679

Merged
justinchuby merged 10 commits into
mainfrom
justinchuby-implement-hunyuan-v3-gguf
Aug 27, 2026
Merged

justinchuby merged 10 commits into
mainfrom
justinchuby-implement-hunyuan-v3-gguf

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • add dedicated hy_v3 trunk and NextN graph/task implementations from authoritative Tencent Transformers and llama.cpp semantics rather than aliasing a neighboring architecture
  • implement full attention, per-head Q/K RMSNorm, ordinary pre-norm residual blocks (the official model has no hyper-connections), a contiguous dense prefix, and selection-biased sigmoid routed SwiGLU experts with an always-on ungated shared expert
  • emit one independently cached MTP block for combined artifacts while accepting llama.cpp target-only split artifacts without a sidecar; reject static cache only when the physical MTP head is present
  • enforce exact tensor/shape closure, fused and split QKV/expert layouts, explicit-float router/norm/correction tensors, and fail-closed quantized-import classification
  • update GGUF route census, pinned llama.cpp capability evidence, generated docs, registry coverage, and revision-neutral routing

Evidence

Authoritative semantics were checked against Tencent's official HyV3 Transformers implementation and pinned llama.cpp source. The official checkpoint is approximately 600 GiB (112 shards near 5.36 GiB each), so no representative artifact under the 16 GiB policy limit exists and no payload was pinned or downloaded.

  • focused GGUF suite: 3407 passed, 1 skipped
  • focused HyV3 graph/parity/registry selection: 5 passed, 1 skipped
  • broad serial non-integration suite: 8641 passed, 64 skipped, 12 deselected
  • post-review builder/MTP/HyV3 regression selection: 558 passed
  • formatter/linter: clean
  • targeted mypy for the three new production modules: clean
  • independent final review: no high-confidence findings

Deferred evidence / waivers

  • real-weight L3 parity is unavailable because no immutable representative artifact is within 16 GiB; bounded header/source evidence is used instead
  • L4 golden and L5 generation, ORT GenAI downstream runtime, CUDA, Foundry Local, and Olive validation remain runtime-deferred pending an admissible artifact and runtime resources
  • quantized preservation is intentionally rejected because the separate selection/mixing scores and required tensor transforms cannot be represented exactly by the current quantized ABI
  • repository-wide mypy remains blocked by unrelated pre-existing diagnostics; the new HyV3 model, task, and exact validator modules pass targeted strict checking

Production routing does not pin, default, reject, or special-case Hugging Face revisions by model ID: revision=None remains normal and arbitrary explicit revisions continue to forward.

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 27, 2026 16:19
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing e8f1ad0 → afe234e

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

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing e8f1ad0 → afe234e

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

Adds first-class Hunyuan-V3 (“hy_v3”) GGUF graph import support to mobius, including an independently cached NextN/MTP head sidecar and strict fail-closed GGUF tensor/metadata validation. This extends the GGUF importer/registry so HYV3 is no longer aliased to a neighboring architecture and can be selected/routed explicitly.

Changes:

  • Introduces HYV3 model/config/task implementations (dense-prefix + routed/shared MoE trunk; one-layer NextN/MTP head with independent KV cache).
  • Adds strict HYV3 GGUF tensor-closure + shape + storage-type validation and integrates it into GGUF build/arch registry and MTP wiring (including target-only split handling).
  • Adds dedicated unit/synthetic and GGUF end-to-end tests plus updates route census + docs + registry hooks.

Reviewed changes

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

Show a summary per file
File Description
tests/synthetic_parity_test.py Skips generic synthetic parity for hy_v3 and points to dedicated router parity tests.
tests/build_graph_test.py Adds HyV3MtpModel to the “bespoke IO contract” coverage list.
tests/_test_configs.py Adds a tiny hy_v3 config for graph-build test coverage.
src/mobius/tasks/_hy_v3_mtp.py New task defining the HYV3 MTP sidecar I/O contract and independent KV cache.
src/mobius/tasks/init.py Exposes HyV3MtpTask and registers the “hy-v3-mtp” task key.
src/mobius/models/hy_v3.py New HYV3 trunk + MoE/router + MTP head module implementations.
src/mobius/models/hy_v3_test.py New graph + executable synthetic-reference tests (router correctness, weight preprocessing, MTP cache shape).
src/mobius/models/init.py Exports HyV3CausalLMModel and HyV3MtpModel.
src/mobius/integrations/gguf/_upstream_data/llamacpp_pin.json Updates pinned llama.cpp census to list hy_v3 as a supported sidecar architecture.
src/mobius/integrations/gguf/_tensor_mapping.py Adds hy_v3-specific tensor mapping extras for import.
src/mobius/integrations/gguf/_route_census.py Updates route census dependency listings (removes hy_v3 from the prior dependency set).
src/mobius/integrations/gguf/_route_census_test.py Updates expected category counts after route changes.
src/mobius/integrations/gguf/_mtp.py Extends MTP validation/mapping/config derivation/build to support hy_v3 sidecar semantics.
src/mobius/integrations/gguf/_mtp_test.py Updates pinned loader/converter union expectations to include hy_v3 sidecars.
src/mobius/integrations/gguf/_hy_v3.py New fail-closed HYV3 GGUF validator (metadata, tensor closure, shapes, explicit-float auxiliaries).
src/mobius/integrations/gguf/_hy_v3_test.py New HYV3 GGUF contract + end-to-end build tests (combined + target-only split).
src/mobius/integrations/gguf/_config_mapping.py Adds hy_v3 config postprocess to restore exact semantics and handles target-only split MTP metadata.
src/mobius/integrations/gguf/_builder.py Integrates HYV3 validation and relaxes static_cache rejection when MTP is metadata-only (target-only split).
src/mobius/integrations/gguf/_arch_registry.py Marks hy_v3 graph-importable with explicit tensor map recipe, postprocessor, and quantized-import rejection.
src/mobius/integrations/gguf/_arch_registry_test.py Updates importable architecture counts and includes hy_v3 in promoted conventional decoders.
src/mobius/_registry.py Registers hy_v3 backbone and HyV3MtpModel fallback registrations.
src/mobius/_configs/_base.py Adds HyV3Config and HyV3MtpConfig, including from_transformers logic for dense-prefix schedule.
src/mobius/_configs/init.py Exports HyV3Config and HyV3MtpConfig.
docs/api/build_from_gguf.md Updates generated support/census tables and hy_v3 architecture status.

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

Comment thread src/mobius/integrations/gguf/_hy_v3.py Resolved
@justinchuby
justinchuby force-pushed the justinchuby-implement-hunyuan-v3-gguf branch 3 times, most recently from 8c69a13 to b9b26cc Compare August 27, 2026 20:05
justinchuby and others added 9 commits August 27, 2026 13:52
Implement authoritative HyV3 metadata and tensor closure, full-attention trunk and independently cached NextN graphs, Q/K normalization, dense-prefix and sigmoid routed/shared MoE behavior, and fail-closed storage handling. Cover fused and split expert layouts, target-only and combined artifacts, synthetic routing parity, route census, and generated documentation.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Apply the formatter from current main and retain explicit fail-closed float-storage checks under the updated lint configuration.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Drop dead validator code identified during pull request review so the exact tensor closure remains straightforward to audit.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Normalize official Tencent checkpoint names before MoE expansion with collision detection. Add native payload-free parity, exact coverage metadata, and a discriminating llama.cpp router-floor regression.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
Document why the four GGUF-specialized MoE graph variants use dedicated L1 and contract coverage instead of native Hugging Face L2 configuration loading.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
Fail closed on auxiliary and compute-only GGUF types for all model tensors while allowing valid float, F64, and quantized weight storage. Keep normalization and routing tensors restricted to explicit floating-point storage.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
Keep the official expert-selection correction bias in float32 through FP16 and BF16 graph construction so near-boundary top-k choices match the source model. Add trunk and MTP initializer checks plus an executable selection regression that diverges after float16 rounding.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
Compare executable FP32 and FP16 correction-bias graphs with strictly different near-boundary expert scores, avoiding any dependency on TopK tie ordering.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
Retain the promoted text-cohort coverage entries from main and remove the duplicate pre-rebase variants so repository lint stays fail-closed after the HyV3 rebase.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-implement-hunyuan-v3-gguf branch from eab1db0 to 4a13b39 Compare August 27, 2026 21:02
Include the routing normalization floor in HyV3 route identities because it changes expert mixing semantics, while regression tests preserve byte-identical fingerprints for legacy and unrelated consumers.

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

Copilot-Session: 4d631b7b-5551-4cbd-bd00-4e53f18bf75e
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby merged commit 2605d6d into main Aug 27, 2026
22 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-implement-hunyuan-v3-gguf branch August 27, 2026 21:18
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