Skip to content

feat(model): add HY4-A49B (hy_v4) model support - #897

Merged
Andrewxu313 merged 6 commits into
mainfrom
tairan/hy4-a49b-model-clean
Dec 4, 2026
Merged

Andrewxu313 merged 6 commits into
mainfrom
tairan/hy4-a49b-model-clean

Conversation

@Andrewxu313

Copy link
Copy Markdown
Contributor

Description

Add end-to-end BatchGen model support for tencent/Hy4 (hy_v4_vl text backbone):

  • Configuration (config.py) with fail-loud HF resolution and validation for the 78-layer MLA + DSA sparse indexer, 256 routed experts (top-8) + 1 shared expert, 4-channel iHC carrier (hc_mult=4), gated MLA output, learnable sinks, clamped SwiGLU (limit=10), and fp32 lm_head.
  • Tokenizer (tokenizer.py) with vendored upstream assets, md5 provenance verification, pinned added-token gates, Jinja chat-template rendering, and non-special <think:opensource> / <tool_call:opensource> output parsing.
  • Checkpoint tensor map (weight_map.py), eager weight loader (weights.py), manifest-driven served-only conversion and publication (hy_v4_publication.py, convert_checkpoint.py), parameter server (hy_v4_parameter_server.py), initializer (hy_v4_initializer.py), parallel strategy manager (Parallel_Strategy_Manager.py, including all Phase E2-a model lifecycle hooks), and native phase assembly (hy_v4_native.py).
  • Serving fast paths: packed prefill and paged sparse/dense MLA (serving_attn.py), unified dynamic per-head FP8 indexer Q quantization with folded head gates (serving_indexer.py), whole-model decode CUDA graphs with hybrid EP collectives and side-stream shared-expert overlap (decode_cuda_graph.py), Triton fused ops and vendored iHC kernels (fused_ops.py, vendor/vllm_0_35/nvidia/triton_ihc.py), TP sharding and MoE resharding (tp_weight_sharding.py, moe_tp_reshard.py), and wrappers reading ModelPhaseState (wrappers.py).
  • Registration seam wiring in batchgen/get_initializer.py and batchgen/get_parallel_strategy_manager.py (exact-name dispatch only), plus full unit test coverage under tests/unit/models/hy_v4/ and tests/unit/test_model_hooks_contract.py.

Motivation

Enables serving tencent/Hy4 in BatchGen within the model change-type allowlist (PR_MERGE_POLICY.md §2.5–§2.6). Core runtime prerequisites landed in #884 and kernel primitives landed in #894.

Milestone (optional)

HY4 A49B Model Support

Type of Change

  • model — add/extend model support (models/** + registration seam + model kernels only)
  • kernel — add/optimize a compute kernel (batchgen_kernels/** + in-tree kernel dirs)
  • core — change scheduling/serving/runtime scaffolding (the only type that may)
  • fix — narrow bug fix (+ a regression test)
  • infra — build / CI / packaging / scripts / Docker
  • docs — documentation only

File changes

File Δ Note
batchgen/get_initializer.py mod Register exact tencent/hy4, tencent/hy4-fp8, hy4-a49b initializer dispatch
batchgen/get_parallel_strategy_manager.py mod Register exact tencent/hy4, tencent/hy4-fp8, hy4-a49b strategy manager dispatch
batchgen/models/hy/__init__.py add HY model family package marker
batchgen/models/hy/hy_v4/__init__.py add hy_v4 package exports
batchgen/models/hy/hy_v4/Parallel_Strategy_Manager.py add Multi-node DP/TP/EP layout declaration, phase planning, and E2-a model lifecycle hooks
batchgen/models/hy/hy_v4/assets/UPSTREAM_SOURCE.json add Provenance and md5 manifest for vendored tokenizer assets
batchgen/models/hy/hy_v4/assets/chat_template.jinja add Upstream Jinja chat template
batchgen/models/hy/hy_v4/assets/generation_config.json add Upstream generation config
batchgen/models/hy/hy_v4/assets/tokenizer.json add Upstream BPE tokenizer
batchgen/models/hy/hy_v4/assets/tokenizer_config.json add Upstream tokenizer config
batchgen/models/hy/hy_v4/config.py add Fail-loud HyV4Config and checkpoint config loader
batchgen/models/hy/hy_v4/convert_checkpoint.py add Served-only manifest-driven checkpoint conversion driver
batchgen/models/hy/hy_v4/decode_cuda_graph.py add Whole-model dense/sparse decode CUDA graph capture and replay
batchgen/models/hy/hy_v4/fused_ops.py add Triton fused router, RoPE/KV write, sink+sigmoid gate, and SiLU*up kernels
batchgen/models/hy/hy_v4/hy_v4_initializer.py add Model initializer, phase assembly, and resident weight bindings
batchgen/models/hy/hy_v4/hy_v4_native.py add Native weight publication and phase transitions
batchgen/models/hy/hy_v4/hy_v4_parameter_server.py add Parameter server weight loading and skeleton construction
batchgen/models/hy/hy_v4/hy_v4_publication.py add Publication manifest builder and validator
batchgen/models/hy/hy_v4/model.py add HyV4ForCausalLM, MLA with sink/gate, iHC carrier, MoE, and DSA indexer
batchgen/models/hy/hy_v4/moe_tp_reshard.py add TP/EP row all-gather and scatter helpers
batchgen/models/hy/hy_v4/serving_attn.py add Packed dense/sparse prefill MLA and absorbed decode helpers
batchgen/models/hy/hy_v4/serving_indexer.py add Page-split FP8 index key writer and unified dynamic FP8 Q quantization + top-k
batchgen/models/hy/hy_v4/tokenizer.py add HyV4Tokenizer with md5/pinned-token gates and think/tool parsers
batchgen/models/hy/hy_v4/tp_weight_sharding.py add TP attention/MLP weight sharding and indexer RoPE permutation helpers
batchgen/models/hy/hy_v4/vendor/__init__.py add Vendored kernels package marker
batchgen/models/hy/hy_v4/vendor/vllm_0_35/__init__.py add Vendored vLLM 0.35 package marker
batchgen/models/hy/hy_v4/vendor/vllm_0_35/nvidia/__init__.py add Vendored CUDA kernels package marker
batchgen/models/hy/hy_v4/vendor/vllm_0_35/nvidia/triton_ihc.py add Vendored Triton iHC pre/post kernels with inplace valid-token masking
batchgen/models/hy/hy_v4/weight_map.py add Executable checkpoint tensor partition and deferred-group classification
batchgen/models/hy/hy_v4/weights.py add Eager weight loader with full-coverage validation
batchgen/models/hy/hy_v4/wrappers.py add Serving attention and expert wrappers over paged GPU/host KV
tests/unit/models/hy_v4/__init__.py add Unit test package marker
tests/unit/models/hy_v4/conftest.py add Shared checkpoint and publication pytest fixtures
tests/unit/models/hy_v4/fixtures/indexer/gen_indexer_oracle.py add Indexer reference oracle generator
tests/unit/models/hy_v4/fixtures/indexer/vectors.json add Indexer oracle reference vectors
tests/unit/models/hy_v4/fixtures/indexer/verify_indexer_transformers.py add Indexer transformers cross-check helper
tests/unit/models/hy_v4/hf_config_tencent_hy4.json add Release HF config test fixture
tests/unit/models/hy_v4/test_hy_v4_attn_seam.py add Attention wrapper seam unit tests
tests/unit/models/hy_v4/test_hy_v4_config.py add Config resolution and dispatch isolation tests
tests/unit/models/hy_v4/test_hy_v4_convert_checkpoint.py add Checkpoint conversion driver tests
tests/unit/models/hy_v4/test_hy_v4_decode_cuda_graph.py add Whole-model decode CUDA graph unit tests
tests/unit/models/hy_v4/test_hy_v4_fp32_ops.py add FP32 internal math precision regression tests
tests/unit/models/hy_v4/test_hy_v4_host_construction.py add Initializer and PSM host construction tests
tests/unit/models/hy_v4/test_hy_v4_indexer_scores.py add DSA indexer scoring, dynamic Q quantization, and iHC valid-token tests
tests/unit/models/hy_v4/test_hy_v4_native_publication.py add Native weight publication manifest tests
tests/unit/models/hy_v4/test_hy_v4_paged_kv.py add Paged GPU/host KV decode equivalence tests
tests/unit/models/hy_v4/test_hy_v4_parameter_server.py add Parameter server sharding and deferred-tensor tests
tests/unit/models/hy_v4/test_hy_v4_phase_assembly.py add Phase assembly and host-lease lifecycle tests
tests/unit/models/hy_v4/test_hy_v4_serving_moe.py add Serving MoE prefill and decode forward tests
tests/unit/models/hy_v4/test_hy_v4_skeleton_under_server_init.py add Subprocess skeleton shape test under server init patch
tests/unit/models/hy_v4/test_hy_v4_tokenizer.py add Tokenizer md5, pinned tokens, Jinja template, parser, and routing tests
tests/unit/models/hy_v4/test_hy_v4_tp8_resident_ep_layout.py add TP8 resident-EP layout declaration unit tests
tests/unit/models/hy_v4/test_hy_v4_tp_and_absorbed_math.py add TP sharding and absorbed MLA math unit tests
tests/unit/models/hy_v4/test_hy_v4_wrappers.py add Attention and expert wrapper equivalence tests
tests/unit/test_model_hooks_contract.py mod Register HyV4ParallelStrategyManager in model lifecycle hook contract test

Checklist

  • I have read the CONTRIBUTING guide and the PR Merge Policy Contract.
  • I have updated the tests (if applicable).
  • I have updated the documentation (if applicable).
  • If README.md changed, I ran python3 scripts/check_readme_update.py --base-ref origin/main and preserved all News history.

Add full BatchGen model package for tencent/Hy4 (hy_v4_vl text backbone: 78 layers, 256 routed experts top-8 + 1 shared expert, MLA with DSA sparse indexer, learnable sinks, output gate, 4-channel iHC carrier, clamped SwiGLU, fp32 lm_head, vendored tokenizer and Jinja template with md5 load gates, manifest-driven conversion and publication, eager/paged KV wrappers, and comprehensive unit tests).
Add HY4 serving attention, FP8 DSA indexer, Triton iHC kernels, fused router/RoPE/sink-gate ops, DP x TP x EP whole-model decode CUDA graphs with direct PyNccl collectives and FA3 auto-split for small buckets, and migrate wrapper phase-state reads to ModelPhaseState.
Fork TP-sharded shared-expert GEMMs onto a side CUDA stream synchronized via events inside captured HY4 decode graphs so they overlap with the inter-node EP all_gather.
Share dynamic per-(token, head) FP8 Q quantization with folded head gates across packed prefill, eager fast decode, and CUDA-graph decode, enforce num_valid_tokens inplace contract in iHC post, and update tokenizer routing tests.
Add the nine required model lifecycle hooks to HyV4ParallelStrategyManager so integrated startup passes verify_manager_model_hooks, and register it in test_model_hooks_contract.py.
Satisfy pr-lint-gate F401/F841 checks on serving_attn.py and test_hy_v4_tp8_resident_ep_layout.py.
@Andrewxu313
Andrewxu313 merged commit 3849310 into main Dec 4, 2026
1 check passed
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.

1 participant