Skip to content

feat: add Tencent Hy-MT2 series support#5029

Merged
qinxuye merged 1 commit into
xorbitsai:mainfrom
xiaoyesoso:feat/hy-mt2
Jun 15, 2026
Merged

feat: add Tencent Hy-MT2 series support#5029
qinxuye merged 1 commit into
xorbitsai:mainfrom
xiaoyesoso:feat/hy-mt2

Conversation

@xiaoyesoso

Copy link
Copy Markdown
Contributor

Register Tencent Hunyuan Hy-MT2 multilingual translation models for deployment via Transformers, vLLM, SGLang, and llama.cpp engines.

Models registered (Hy-MT2-1.8B / 7B / 30B-A3B):

  • pytorch (none, fp8) and ggufv2 specs with HF + ModelScope sources
  • 33 supported languages, 262144 context length
  • Embedded the official chat_template.jinja into llm_family.json
  • Correct stop_token_ids per model: 1.8B/7B [120020], 30B [120025,120026]

Engine adapters:

  • New transformers/hy_mt2.py adapter forces torch_dtype=bfloat16 to avoid the MPSFloatType embedding error on Apple Silicon and enables trust_remote_code for the custom HunYuanDenseV1/HYV3 modeling code.
  • vllm/core.py: add HunYuanDenseV1ForCausalLM and HYV3ForCausalLM to the vLLM (>=0.22.0) supported chat models list.
  • sglang/core.py: add the same architectures to SGLANG_SUPPORTED_CHAT_MODELS.

@XprobeBot XprobeBot added this to the v2.x milestone Jun 15, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for Tencent Hunyuan Hy-MT2 multilingual translation models (HunYuanDenseV1ForCausalLM and HYV3ForCausalLM) across SGLang, vLLM, and Transformers backends. Feedback includes adding proper type annotations and default values to pytorch_model_config in the new model's initializer, and returning a descriptive error message instead of a plain boolean when architecture matching fails in match_json.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread xinference/model/llm/transformers/hy_mt2.py
Comment thread xinference/model/llm/transformers/hy_mt2.py Outdated
@xiaoyesoso

Copy link
Copy Markdown
Contributor Author

Addressed Gemini Code Assist's review comments in f0220038:

  1. hy_mt2.py:46 — Annotated pytorch_model_config as Optional[PytorchModelConfig] = None in HyMT2PytorchModel.__init__ to match the parent PytorchChatModel signature.
  2. hy_mt2.py:72match_json now returns a descriptive (False, "Hy-MT2 transformer only supports architectures: …") tuple when the architecture does not match, consistent with the other transformer adapters in the codebase.

pre-commit run --files xinference/model/llm/transformers/hy_mt2.py passes (black/flake8/isort/mypy/codespell).

Comment thread xinference/model/llm/llm_family.json
Register Tencent Hunyuan Hy-MT2 multilingual translation models for
deployment via Transformers, vLLM, SGLang, and llama.cpp engines.

Models registered (Hy-MT2-1.8B / 7B / 30B-A3B):
- pytorch (none, fp8) and ggufv2 specs with HF + ModelScope sources
- 33 supported languages, 262144 context length
- Embedded the official chat_template.jinja into llm_family.json
- Correct stop_token_ids per model: 1.8B/7B [120020], 30B [120025,120026]

Engine adapters:
- New transformers/hy_mt2.py adapter forces torch_dtype=bfloat16 to avoid
  the MPSFloatType embedding error on Apple Silicon and enables
  trust_remote_code for the custom HunYuanDenseV1/HYV3 modeling code.
- vllm/core.py: add HunYuanDenseV1ForCausalLM and HYV3ForCausalLM to the
  vLLM (>=0.22.0) supported chat models list.
- sglang/core.py: add the same architectures to SGLANG_SUPPORTED_CHAT_MODELS.

Verified locally on macOS via the llama.cpp engine (Q4_K_M GGUF)
end-to-end translation; Transformers engine loads successfully on MPS
(bfloat16 fix confirmed) but full inference is constrained by host RAM.

Review fixups:
- Type-annotate pytorch_model_config as Optional[PytorchModelConfig] in
  HyMT2PytorchModel.__init__ to align with PytorchChatModel.
- Return a descriptive tuple from match_json when the architecture does
  not match, matching other adapters' behavior.
- Add the #sglang_dependencies# ; #engine# == "sglang" marker to the
  virtualenv packages of all three Hy-MT2 families so the SGLang engine
  passes check_engine_by_spec_parameters_with_virtual_env when virtualenv
  filtering is enabled (matches the SGLang registration in
  sglang/core.py).

@qinxuye qinxuye 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.

LGTM

@qinxuye
qinxuye merged commit 7005038 into xorbitsai:main Jun 15, 2026
4 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants