Skip to content

Commit 3881873

Browse files
authored
Merge branch 'main' into gemma4-perlayer-fused
2 parents 3ef5750 + 47da8cb commit 3881873

18 files changed

Lines changed: 1058 additions & 53 deletions

‎.github/workflows/gpu_l4_golden_parity.yml‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ jobs:
4343
with:
4444
python-version: "3.12"
4545

46-
- name: Cache pip packages
47-
uses: actions/cache@v5
48-
with:
49-
path: ~/.cache/pip
50-
key: pip-gpu-${{ hashFiles('pyproject.toml', 'requirements/ci/requirements.txt') }}
51-
restore-keys: |
52-
pip-gpu-
53-
5446
- name: Cache HuggingFace models
5547
uses: actions/cache@v5
5648
with:
@@ -60,13 +52,14 @@ jobs:
6052
hf-gpu-
6153
6254
- name: Install PyTorch (CUDA)
63-
run: pip install torch --index-url https://download.pytorch.org/whl/cu124
55+
run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
6456

6557
- name: Install dependencies
6658
run: |
6759
pip install -r requirements/ci/requirements.txt
68-
pip install onnxruntime-gpu
60+
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
6961
pip install -e '.[testing,transformers]'
62+
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-13-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
7063
7164
- name: Check for golden test data
7265
id: check_golden

‎.github/workflows/gpu_l5_generation_e2e.yml‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ jobs:
4343
with:
4444
python-version: "3.12"
4545

46-
- name: Cache pip packages
47-
uses: actions/cache@v5
48-
with:
49-
path: ~/.cache/pip
50-
key: pip-gpu-${{ hashFiles('pyproject.toml', 'requirements/ci/requirements.txt') }}
51-
restore-keys: |
52-
pip-gpu-
53-
5446
- name: Cache HuggingFace models
5547
uses: actions/cache@v5
5648
with:
@@ -60,13 +52,14 @@ jobs:
6052
hf-gpu-
6153
6254
- name: Install PyTorch (CUDA)
63-
run: pip install torch --index-url https://download.pytorch.org/whl/cu124
55+
run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
6456

6557
- name: Install dependencies
6658
run: |
6759
pip install -r requirements/ci/requirements.txt
68-
pip install onnxruntime-gpu
60+
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
6961
pip install -e '.[testing,transformers]'
62+
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-13-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
7063
7164
- name: Run L5 generation E2E tests
7265
env:

‎.github/workflows/main.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,13 @@ jobs:
277277
restore-keys: |
278278
hf-integration-fast-
279279
- name: Install PyTorch CUDA
280-
run: pip install torch --index-url https://download.pytorch.org/whl/cu124
280+
run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
281281
- name: Install dependencies
282282
run: |
283283
pip install -r requirements/ci/requirements.txt
284-
pip install onnxruntime-gpu
284+
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
285285
pip install -e '.[testing]'
286+
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-13-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
286287
- name: Run fast integration tests
287288
env:
288289
HF_TOKEN: ${{ secrets.HF_TOKEN }}

‎.github/workflows/validation_examples_gpu.yml‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ jobs:
6767
with:
6868
python-version: "3.12"
6969

70-
- name: Cache pip packages
71-
uses: actions/cache@v5
72-
with:
73-
path: ~/.cache/pip
74-
key: pip-examples-gpu-${{ hashFiles('pyproject.toml', 'requirements/ci/requirements.txt') }}
75-
restore-keys: |
76-
pip-examples-gpu-
77-
7870
- name: Cache HuggingFace models
7971
uses: actions/cache@v5
8072
with:
@@ -84,14 +76,14 @@ jobs:
8476
hf-examples-gpu-
8577
8678
- name: Install PyTorch (CUDA)
87-
run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
79+
run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
8880

8981
- name: Install dependencies
9082
run: |
9183
pip install -r requirements/ci/requirements.txt
92-
pip install -e '.[testing,transformers,ort-genai]'
93-
pip install onnxruntime-gpu
94-
pip install soundfile librosa ml_dtypes
84+
pip install -e '.[testing,transformers]'
85+
pip install soundfile librosa ml_dtypes flatbuffers numpy packaging protobuf sympy coloredlogs
86+
pip install --pre --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-13-nightly/pypi/simple/ onnxruntime-gpu onnxruntime-genai-cuda
9587
9688
- name: Run ${{ matrix.name }}
9789
env:

‎requirements/ci/requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pytest
22
pytest-cov
33
pytest-xdist
44
coverage[toml]
5-
gguf>=0.18.0
5+
gguf>=0.19.0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
lintrunner-adapters>=0.13.0
1+
lintrunner-adapters>=0.14.0
22
# RUFF, RUFF-FIX
3-
ruff==0.15.11
3+
ruff==0.15.12

‎src/mobius/_configs.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,21 @@ def _extract_vision_config(config, parent_config, model_type: str) -> dict:
602602
image_token_id=getattr(config, "special_image_token_id", 200010),
603603
)
604604

605+
# HunYuan VL-MoT has a flat config.json with no vision_config sub-object.
606+
# The vision encoder params are hardcoded (InternViT-style ViT).
607+
if model_type == "hunyuan_vl_mot" and not vision_fields.get("hidden_size"):
608+
vision_fields.update(
609+
hidden_size=1152,
610+
intermediate_size=4304,
611+
num_hidden_layers=27,
612+
num_attention_heads=16,
613+
image_size=2048,
614+
patch_size=16,
615+
norm_eps=1e-6,
616+
spatial_merge_size=2,
617+
image_token_id=getattr(vision_source, "mask_init_id", 12),
618+
)
619+
605620
# InternVL2 doesn't expose image_token_id in its config — default to
606621
# the Qwen2 <IMG_CONTEXT> token id used by InternVL2-* models.
607622
parent_model_type = getattr(vision_source, "model_type", None)

‎src/mobius/_registry.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
GraniteMoECausalLMModel,
5454
HunYuanMoEV1CausalLMModel,
5555
HunYuanV1DenseCausalLMModel,
56+
HunYuanVLMoTModel,
5657
InternLM2CausalLMModel,
5758
LayerNormCausalLMModel,
5859
Llama4CausalLMModel,
@@ -473,6 +474,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
473474
"glm4v_moe_text": ModelRegistration(Glm4MoECausalLMModel),
474475
"glm4v_text": ModelRegistration(Glm4CausalLMModel),
475476
"got_ocr2": ModelRegistration(LLaVAModel, task="vision-language"),
477+
"hunyuan_vl_mot": ModelRegistration(HunYuanVLMoTModel, task="hunyuan-vl-mot"),
476478
"idefics2": ModelRegistration(LLaVAModel, task="vision-language"),
477479
"idefics3": ModelRegistration(LLaVAModel, task="vision-language"),
478480
"instructblip": ModelRegistration(LLaVAModel, task="vision-language"),
@@ -835,6 +837,7 @@ def _create_default_registry() -> ModelRegistry:
835837
"glm4v_moe_text": "THUDM/glm-4v-9b",
836838
"glm4v_text": "THUDM/glm-4v-9b",
837839
"got_ocr2": "stepfun-ai/GOT-OCR2_0",
840+
"hunyuan_vl_mot": "tencent/HY-Embodied-0.5-X",
838841
"instructblipvideo": "Salesforce/instructblip-flan-t5-xl",
839842
"internvl": "OpenGVLab/InternVL2-1B",
840843
"internvl_chat": "OpenGVLab/InternVL-Chat-V1-5",

‎src/mobius/_weight_utils.py‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,21 @@ def tie_word_embeddings(
368368
embed_key: str = "model.embed_tokens.weight",
369369
head_key: str = "lm_head.weight",
370370
) -> None:
371-
"""Ensure both embedding and LM head weights are present (tied).
372-
373-
If one of the two keys is missing, copies the other. This handles
374-
the common HuggingFace ``tie_word_embeddings=True`` pattern where
375-
only one of the two weights is stored in the checkpoint.
371+
"""Ensure both embedding and LM head weights are present and tied.
372+
373+
When HuggingFace saves a model with ``tie_word_embeddings=True``, only
374+
one of the two weights (embedding or LM head) is stored in the
375+
checkpoint. This function fills in the missing key by assigning it
376+
to **the same Python tensor object** as the existing key.
377+
378+
This identity relationship is what enables true ONNX weight sharing
379+
downstream: :func:`~mobius._weight_loading.apply_weights` detects
380+
that two state-dict entries share the same underlying storage (via
381+
``data_ptr()``), creates a **single** ONNX initializer for the first
382+
occurrence, and redirects all graph uses of the second initializer to
383+
point at the first one. The result is one copy of the embedding
384+
table in the ONNX file, used by both the Gather (embedding lookup)
385+
and MatMul (LM head projection) nodes.
376386
377387
Mutates *state_dict* in place.
378388
@@ -385,6 +395,12 @@ def tie_word_embeddings(
385395
state_dict[head_key] = state_dict[embed_key]
386396
elif embed_key not in state_dict and head_key in state_dict:
387397
state_dict[embed_key] = state_dict[head_key]
398+
elif embed_key not in state_dict and head_key not in state_dict:
399+
raise ValueError(
400+
f"tie_word_embeddings: neither '{embed_key}' nor '{head_key}' "
401+
f"found in state_dict. Check that the key names match the "
402+
f"weight dictionary after any prefix stripping."
403+
)
388404

389405

390406
def vlm_decoder_weights(

‎src/mobius/_weight_utils_test.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,13 @@ def test_both_present_no_change(self):
227227
assert sd["model.embed_tokens.weight"].data_ptr() == t1.data_ptr()
228228
assert sd["lm_head.weight"].data_ptr() == t2.data_ptr()
229229

230-
def test_neither_present_no_change(self):
231-
"""If neither present, no change."""
230+
def test_neither_present_raises(self):
231+
"""Raise ValueError if neither key is found (catches key mismatches)."""
232+
import pytest
233+
232234
sd = {"other.weight": torch.randn(4)}
233-
tie_word_embeddings(sd)
234-
assert list(sd.keys()) == ["other.weight"]
235+
with pytest.raises(ValueError, match=r"neither.*found"):
236+
tie_word_embeddings(sd)
235237

236238
def test_custom_keys(self):
237239
"""Custom embed/head keys."""

0 commit comments

Comments
 (0)