Skip to content

Add Tencent Hy-MT2-1.8B support (L4/L5 golden + parity example) - #374

Merged
justinchuby merged 2 commits into
mainfrom
justinchu/hy-mt2-1.8b
Jun 26, 2026
Merged

justinchuby merged 2 commits into
mainfrom
justinchu/hy-mt2-1.8b

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

Adds support + verification for tencent/Hy-MT2-1.8B, the newer (2026.5) multilingual translation checkpoint in the HunYuanDenseV1 family (model_type: hunyuan_v1_dense).

The architecture is already supported by HunYuanV1DenseCausalLMModel (GQA 16/4 heads, head_dim 128, per-head QK-norm, tied embeddings, dynamic-NTK RoPE with alpha=1000 via DynamicNTKRope). No model/registry code changes were needed — this PR adds the test coverage and a runnable demo that prove it works end-to-end on the real weights.

Changes

  • testdata/cases/causal-lm/hy-mt2-1_8b.yaml — L4+L5 case, pinned to the model revision, with the Hy-MT chat-template-formatted translation prompt.
  • testdata/golden/causal-lm/hy-mt2-1_8b.json + ...-1_8b_generation.json — L4 prefill-logits and L5 greedy-generation goldens (generated against HF transformers).
  • examples/hy_mt2.py — builds the ONNX export, runs greedy generation through ONNX Runtime and HuggingFace, and asserts the two produce identical token sequences.

Validation

  • pytest tests/e2e_golden_test.py -m "golden or generation" -k hy_mt2 → 2 passed (L4 prefill logits + L5 greedy generation match HF).
  • examples/hy_mt2.py reproduces HF token-for-token:
    source : 黄河之水天上来
    ONNX   : The waters of the Yellow River come from the sky
    HF     : The waters of the Yellow River come from the sky
    ✅ PASS: ONNX and HuggingFace produced identical 11 tokens.
    
  • hunyuan_v1_dense unit tests pass; lint clean.

Co-authored-by: Copilot [email protected]

The HunYuanDenseV1 architecture (model_type hunyuan_v1_dense) is already
supported by HunYuanV1DenseCausalLMModel; Hy-MT2-1.8B is the newer (2026.5)
translation checkpoint in that family. This adds verification + a runnable
demo:

- testdata/cases/causal-lm/hy-mt2-1_8b.yaml: L4+L5 case pinned to the model
  revision, with the Hy-MT chat-template-formatted translation prompt.
- testdata/golden/causal-lm/hy-mt2-1_8b{,_generation}.json: L4 prefill-logits
  and L5 greedy-generation golden references (generated against HF).
- examples/hy_mt2.py: builds the ONNX export, runs greedy generation through
  ONNX Runtime AND HuggingFace, and asserts identical token sequences.

Verified: L4+L5 e2e_golden_test pass; the example reproduces HF token-for-token
("The waters of the Yellow River come from the sky").

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

github-actions Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing f51ad25 → 9008d6d

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 60 60 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 68 68 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 107 107 +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 62 62 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 58 58 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 98 98 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 60 60 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 62 62 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 58 58 +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 275 275 +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 129 129 +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 413 413 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +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

Adds end-to-end (L4/L5) golden coverage and a runnable parity demo for the HuggingFace model tencent/Hy-MT2-1.8B (HunYuanDenseV1), validating that the existing hunyuan_v1_dense support works on real weights without requiring new model/registry code.

Changes:

  • Add a new L4+L5 YAML case pinned to a specific model revision, including a chat-template-formatted translation prompt.
  • Add L4 prefill-logits and L5 greedy-generation golden JSON artifacts for Hy-MT2-1.8B.
  • Add an example script that builds ONNX, runs greedy generation via ORT and HuggingFace, and checks token-level parity.

Reviewed changes

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

File Description
testdata/cases/causal-lm/hy-mt2-1_8b.yaml New L4+L5 test case spec for Hy-MT2-1.8B (prompt + generation settings).
testdata/golden/causal-lm/hy-mt2-1_8b.json New L4 golden (prefill logits summary + top-k) for Hy-MT2-1.8B.
testdata/golden/causal-lm/hy-mt2-1_8b_generation.json New L5 golden (greedy generation tokens/text) for Hy-MT2-1.8B.
examples/hy_mt2.py New runnable ORT-vs-HF token-parity demo for Hy-MT2-1.8B.

Comment thread examples/hy_mt2.py Resolved
Comment thread examples/hy_mt2.py Resolved
@codecov

codecov Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mobius/_testing/generation.py 0.00% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

OnnxGenerator allocated all past_key_values / recurrent-state buffers as
float32, so feeding them into an f16/bf16 ONNX export raised an ORT input
dtype mismatch — breaking the half-precision CUDA path advertised by the
Hy-MT2 example. Resolve each cache input's dtype from the session
(get_input_dtype, which maps bf16 via ml_dtypes) and allocate the zero
buffers accordingly, falling back to float32 when unknown.

Validated: examples/hy_mt2.py --dtype f16 now runs and matches HuggingFace
token-for-token; the f32 path is unchanged.

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

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing f51ad25 → 9008d6d

Model Sub-model Changes Status

No architecture changes detected. ✅


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

@justinchuby
justinchuby requested a review from titaiwangms June 23, 2026 23:36
@justinchuby
justinchuby enabled auto-merge (squash) June 23, 2026 23:36
@justinchuby
justinchuby disabled auto-merge June 26, 2026 20:38
@justinchuby
justinchuby merged commit 4748441 into main Jun 26, 2026
21 of 23 checks passed
@justinchuby
justinchuby deleted the justinchu/hy-mt2-1.8b branch June 26, 2026 20:39
justinchuby added a commit that referenced this pull request Aug 15, 2026
Add an authoritative graph target manifest, PEFT safetensors ingestion with rank and alpha patterns, optional provenance-preserving .onnx_adapter declarations, aligned N-adapter catalogs, and paged-lifecycle reference accounting. Cover PR #318 and #374 migration semantics without freezing the pending ONNX GenAI #828 schema field names.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
justinchuby added a commit that referenced this pull request Aug 20, 2026
Add an authoritative graph target manifest, PEFT safetensors ingestion with rank and alpha patterns, optional provenance-preserving .onnx_adapter declarations, aligned N-adapter catalogs, and paged-lifecycle reference accounting. Cover PR #318 and #374 migration semantics without freezing the pending ONNX GenAI #828 schema field names.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
justinchuby added a commit that referenced this pull request Aug 20, 2026
Add an authoritative graph target manifest, PEFT safetensors ingestion with rank and alpha patterns, optional provenance-preserving .onnx_adapter declarations, aligned N-adapter catalogs, and paged-lifecycle reference accounting. Cover PR #318 and #374 migration semantics without freezing the pending ONNX GenAI #828 schema field names.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
justinchuby added a commit that referenced this pull request Aug 21, 2026
Add an authoritative graph target manifest, PEFT safetensors ingestion with rank and alpha patterns, optional provenance-preserving .onnx_adapter declarations, aligned N-adapter catalogs, and paged-lifecycle reference accounting. Cover PR #318 and #374 migration semantics without freezing the pending ONNX GenAI #828 schema field names.

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