Skip to content

Commit 53fb00a

Browse files
authored
Merge branch 'main' into justinchuby-patch-1
2 parents ba986ba + 970cd41 commit 53fb00a

368 files changed

Lines changed: 2557 additions & 1051 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/reusable-components/SKILL.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ Model-specific compound blocks (e.g. `_TimestepEmbedding`, `_DiTBlock`,
6060

6161
```python
6262
from onnxscript import nn
63-
from onnxscript._internal import builder
63+
from onnxscript import OpBuilder
6464

6565

6666
class MyComponent(nn.Module):
6767
def __init__(self, hidden_size: int):
6868
super().__init__()
6969
self.weight = nn.Parameter([hidden_size])
7070

71-
def forward(self, op: builder.OpBuilder, hidden_states):
71+
def forward(self, op: OpBuilder, hidden_states):
7272
return op.Mul(hidden_states, self.weight)
7373
```
7474

‎.agents/skills/writing-tests/references/test-examples.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ Guidelines for choosing models:
111111
Categories match task types: `causal-lm`, `encoder`, `seq2seq`, `audio`,
112112
`vision`, `vision-language`, `diffusion`.
113113

114-
**Required fields:**
114+
**Required fields** (enforced by `testdata/cases/schema.json`; `tests/yaml_schema_test.py` validates every YAML on every PR):
115115

116116
```yaml
117117
model_id: "Qwen/Qwen2.5-1.5B-Instruct" # HuggingFace model ID
118+
model_type: "qwen2" # HF config.model_type — must match a key in mobius._registry
118119
revision: "main" # Git revision / commit SHA
119120
task_type: "text-generation" # Task type string
120121
dtype: "float32" # "float32", "float16", or "bfloat16"
@@ -125,6 +126,8 @@ inputs:
125126
- "Here is my poem:" # Text prompt(s); use this default
126127
```
127128
129+
`model_type` is the value the registry lookup uses (see `_create_default_registry()` in `src/mobius/_registry.py`). It is **also** what `tests/model_coverage_test.py` keys on — every registered `model_type` must either appear in some YAML's `model_type` field or be added to `_COVERAGE_SKIP` with a reason. Omit it and the schema test fails; provide a value the registry doesn't know and the coverage test still flags it.
130+
128131
For image models, use `images:` instead of (or alongside) `prompts:`:
129132

130133
```yaml
@@ -209,8 +212,11 @@ Golden files must be committed alongside new test case YAML files.
209212

210213
**L2 — Config compatible:**
211214
1. Create `testdata/cases/<category>/my-model.yaml`.
212-
2. Set `test_model_id: "org/my-model-id"`.
215+
2. Fill in all required fields, including `model_type` (must match the
216+
key registered in `src/mobius/_registry.py`) and `test_model_id`.
213217
3. Run schema validation: `python -m pytest tests/yaml_schema_test.py`.
218+
4. Run coverage check: `python -m pytest tests/model_coverage_test.py` —
219+
fails if any registered `model_type` lacks a YAML or `_COVERAGE_SKIP` entry.
214220

215221
**L3 — Synthetic parity:**
216222
1. Add `pytest.param("org/my-model", False, id="my-model")` to the

‎.github/workflows/main.yml‎

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ on:
1010
- v*
1111
pull_request:
1212

13-
# Allows you to run this workflow manually from the Actions tab
14-
workflow_dispatch:
15-
1613
concurrency:
17-
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
14+
group: ${{ github.workflow }}-${{ github.ref }}
1815
cancel-in-progress: true
1916

2017
jobs:
@@ -33,7 +30,6 @@ jobs:
3330
detect-affected:
3431
name: Detect affected models
3532
runs-on: ubuntu-latest
36-
if: github.event_name == 'pull_request'
3733
outputs:
3834
affected: ${{ steps.detect.outputs.affected }}
3935
run_all: ${{ steps.detect.outputs.run_all }}
@@ -46,8 +42,27 @@ jobs:
4642
id: changed
4743
env:
4844
BASE_REF: ${{ github.base_ref }}
45+
BEFORE: ${{ github.event.before }}
46+
SHA: ${{ github.sha }}
4947
run: |
50-
git diff --name-only origin/"$BASE_REF"...HEAD > changed_files.txt
48+
if [ "${{ github.event_name }}" = "pull_request" ]; then
49+
git diff --name-only origin/"$BASE_REF"...HEAD > changed_files.txt
50+
elif [ "${{ github.event_name }}" = "push" ] && \
51+
[ -n "$BEFORE" ] && \
52+
[ "$BEFORE" != "0000000000000000000000000000000000000000" ]; then
53+
# Push with a known previous commit: use the full push range so
54+
# multi-commit pushes don't silently miss changed files.
55+
git diff --name-only "$BEFORE"..."$SHA" > changed_files.txt
56+
else
57+
# workflow_dispatch, new-branch push (before=0000...), or unknown
58+
# event: fall back to HEAD~1 when it exists, or diff-tree for the
59+
# root commit of a new repository.
60+
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
61+
git diff --name-only HEAD~1...HEAD > changed_files.txt
62+
else
63+
git diff-tree --root --no-commit-id --name-only -r HEAD > changed_files.txt
64+
fi
65+
fi
5166
echo "Changed files:"
5267
cat changed_files.txt
5368
- name: Detect affected models
@@ -109,8 +124,7 @@ jobs:
109124
if: >-
110125
always() && !cancelled() &&
111126
(needs.detect-affected.result == 'failure' ||
112-
needs.detect-affected.outputs.has_affected == 'true' ||
113-
github.event_name != 'pull_request')
127+
needs.detect-affected.outputs.has_affected == 'true')
114128
steps:
115129
- uses: actions/checkout@v6
116130
- name: Setup Python
@@ -140,8 +154,7 @@ jobs:
140154
exit 0
141155
fi
142156
if [ "${{ needs.detect-affected.result }}" = "failure" ] || \
143-
[ "${{ needs.detect-affected.outputs.run_all }}" = "true" ] || \
144-
[ "${{ github.event_name }}" != "pull_request" ]; then
157+
[ "${{ needs.detect-affected.outputs.run_all }}" = "true" ]; then
145158
echo "Running all synthetic parity tests"
146159
pytest tests/synthetic_parity_test.py -v --tb=short -n auto \
147160
--cov=src --cov-report=xml --cov-branch --junitxml junit.xml
@@ -177,8 +190,7 @@ jobs:
177190
if: >-
178191
always() && !cancelled() &&
179192
(needs.detect-affected.result == 'failure' ||
180-
needs.detect-affected.outputs.has_affected == 'true' ||
181-
github.event_name != 'pull_request')
193+
needs.detect-affected.outputs.has_affected == 'true')
182194
uses: ./.github/workflows/gpu_l4_golden_parity.yml
183195
with:
184196
affected_models: ${{ needs.detect-affected.outputs.affected }}
@@ -192,8 +204,7 @@ jobs:
192204
if: >-
193205
always() && !cancelled() &&
194206
(needs.detect-affected.result == 'failure' ||
195-
needs.detect-affected.outputs.has_affected == 'true' ||
196-
github.event_name != 'pull_request')
207+
needs.detect-affected.outputs.has_affected == 'true')
197208
uses: ./.github/workflows/gpu_l5_generation_e2e.yml
198209
with:
199210
affected_models: ${{ needs.detect-affected.outputs.affected }}

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ pytest tests/integration_test.py -m integration -k "qwen2.5-0.5b"
3434

3535
```python
3636
# Good
37-
from onnxscript import nn
38-
from onnxscript._internal import builder
37+
from onnxscript import nn, OpBuilder
3938

4039
class MyLayer(nn.Module):
4140
def __init__(self):
4241
self.param = nn.Parameter([64], name="weight")
4342

44-
def forward(self, op: builder.OpBuilder, x):
43+
def forward(self, op: OpBuilder, x):
4544
...
4645

4746
# Bad

‎docs/module-architecture.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ same `forward()` signature as `DecoderLayer`:
137137
```python
138138
# In models/my_arch.py
139139
from onnxscript import nn
140-
from onnxscript._internal import builder
140+
from onnxscript import OpBuilder
141141
from mobius._configs import ArchitectureConfig
142142
from mobius.components import Attention, MLP, RMSNorm
143143

@@ -156,7 +156,7 @@ class MyDecoderLayer(nn.Module):
156156

157157
def forward(
158158
self,
159-
op: builder.OpBuilder,
159+
op: OpBuilder,
160160
hidden_states,
161161
attention_bias,
162162
position_embeddings: tuple,
@@ -220,7 +220,7 @@ All decoder layers **must** use the explicit typed signature:
220220
```python
221221
def forward(
222222
self,
223-
op: builder.OpBuilder,
223+
op: OpBuilder,
224224
hidden_states, # [batch, seq_len, hidden_size]
225225
attention_bias, # attention mask/bias tensor
226226
position_embeddings: tuple, # (cos, sin) from RoPE

‎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

‎scripts/detect_affected_models.py‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@
3535
_SRC_ROOT = _PROJECT_ROOT / "src" / "mobius"
3636

3737
# ----------------------------------------------------------------
38-
# Shared infrastructure paths — any change triggers run_all
38+
# Shared infrastructure paths — any change triggers run_all.
39+
# Currently empty: core infra files (e.g. _configs.py, _registry.py)
40+
# are NOT under _TRACEABLE_PREFIXES and therefore classify as "other",
41+
# triggering no model tests. Add entries here to re-enable run_all for
42+
# specific paths when broader regression coverage is needed.
3943
# ----------------------------------------------------------------
40-
_SHARED_INFRA_PATTERNS = (
41-
"src/mobius/_configs.py",
42-
"src/mobius/_registry.py",
43-
"src/mobius/_builder.py",
44-
"src/mobius/_weight_loading.py",
45-
"src/mobius/_model_package.py",
46-
"src/mobius/_exporter.py",
47-
# Re-export hub for all model classes — any change here affects all models
48-
"src/mobius/models/__init__.py",
49-
)
44+
_SHARED_INFRA_PATTERNS: tuple[str, ...] = ()
5045

5146
_SHARED_INFRA_PREFIXES: tuple[str, ...] = ()
5247

‎scripts/detect_affected_models_test.py‎

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class TestClassifyFile:
4040
def test_model_file(self):
4141
assert classify_file("src/mobius/models/falcon.py") == "model"
4242

43-
def test_model_init_is_shared_infra(self):
44-
"""models/__init__.py is the re-export hub — classify as shared_infra."""
45-
assert classify_file("src/mobius/models/__init__.py") == "shared_infra"
43+
def test_model_init_is_model(self):
44+
"""models/__init__.py classifies as model (shared_infra disabled)."""
45+
assert classify_file("src/mobius/models/__init__.py") == "model"
4646

4747
def test_component_file(self):
4848
assert classify_file("src/mobius/components/_attention.py") == "traceable"
@@ -51,16 +51,16 @@ def test_task_file(self):
5151
assert classify_file("src/mobius/tasks/_causal_lm.py") == "traceable"
5252

5353
def test_configs_file(self):
54-
assert classify_file("src/mobius/_configs.py") == "shared_infra"
54+
assert classify_file("src/mobius/_configs.py") == "other"
5555

5656
def test_registry_file(self):
57-
assert classify_file("src/mobius/_registry.py") == "shared_infra"
57+
assert classify_file("src/mobius/_registry.py") == "other"
5858

5959
def test_builder_file(self):
60-
assert classify_file("src/mobius/_builder.py") == "shared_infra"
60+
assert classify_file("src/mobius/_builder.py") == "other"
6161

6262
def test_exporter_file(self):
63-
assert classify_file("src/mobius/_exporter.py") == "shared_infra"
63+
assert classify_file("src/mobius/_exporter.py") == "other"
6464

6565
def test_test_file_in_src(self):
6666
assert classify_file("src/mobius/models/_models_test.py") == "test"
@@ -194,9 +194,11 @@ def test_task_change_does_not_trigger_run_all(self):
194194
assert result["run_all"] is False
195195
assert result["affected"] == []
196196

197-
def test_configs_change_triggers_run_all(self):
197+
def test_configs_change_no_run_all(self):
198+
"""_configs.py no longer triggers run_all (shared_infra disabled)."""
198199
result = detect_affected_models(["src/mobius/_configs.py"])
199-
assert result["run_all"] is True
200+
assert result["run_all"] is False
201+
assert result["affected"] == []
200202

201203
def test_unrelated_file_no_affected(self):
202204
result = detect_affected_models(["README.md"])
@@ -249,20 +251,21 @@ def test_mixed_model_and_unrelated(self):
249251
assert result["run_all"] is False
250252
assert "falcon" in result["affected"]
251253

252-
def test_shared_infra_overrides_model(self):
253-
"""If any shared infra changes, run_all even with model files."""
254+
def test_infra_does_not_override_model(self):
255+
"""Infra files no longer trigger run_all (shared_infra disabled)."""
254256
result = detect_affected_models(
255257
[
256258
"src/mobius/models/falcon.py",
257259
"src/mobius/_configs.py",
258260
]
259261
)
260-
assert result["run_all"] is True
262+
assert result["run_all"] is False
263+
assert "falcon" in result["affected"]
261264

262-
def test_models_init_triggers_run_all(self):
263-
"""models/__init__.py is the re-export hub — must trigger run_all."""
265+
def test_models_init_no_run_all(self):
266+
"""models/__init__.py no longer triggers run_all (shared_infra disabled)."""
264267
result = detect_affected_models(["src/mobius/models/__init__.py"])
265-
assert result["run_all"] is True
268+
assert result["run_all"] is False
266269

267270
def test_deleted_model_file_triggers_run_all(self):
268271
"""A model file that doesn't exist on disk triggers run_all."""
@@ -281,21 +284,18 @@ def test_component_common_affects_many_models(self):
281284
# _common.py defines Linear, Embedding, LayerNorm — used everywhere
282285
assert len(result["affected"]) > 10
283286

284-
def test_shared_infra_still_triggers_run_all(self):
285-
"""True shared_infra files (_configs, _registry, etc.) still trigger run_all."""
287+
def test_former_shared_infra_no_run_all(self):
288+
"""Former shared_infra files no longer trigger run_all."""
286289
for path in [
287290
"src/mobius/_configs.py",
288291
"src/mobius/_registry.py",
289292
"src/mobius/_builder.py",
290293
"src/mobius/_weight_loading.py",
291294
"src/mobius/_model_package.py",
292-
"src/mobius/_exporter.py",
293295
"src/mobius/models/__init__.py",
294-
"tests/conftest.py",
295-
"tests/_test_configs.py",
296296
]:
297297
result = detect_affected_models([path])
298-
assert result["run_all"] is True, f"{path} should trigger run_all but didn't"
298+
assert result["run_all"] is False, f"{path} should NOT trigger run_all"
299299

300300
def test_traceable_and_model_combined(self):
301301
"""A component + model file change returns union of affected types."""
@@ -310,15 +310,16 @@ def test_traceable_and_model_combined(self):
310310
# _attention.py dependents should also be included
311311
assert len(result["affected"]) > 2
312312

313-
def test_traceable_overridden_by_shared_infra(self):
314-
"""If both traceable and shared_infra change, run_all wins."""
313+
def test_traceable_and_infra_no_run_all(self):
314+
"""Component + infra files no longer trigger run_all."""
315315
result = detect_affected_models(
316316
[
317317
"src/mobius/components/_attention.py",
318318
"src/mobius/_configs.py",
319319
]
320320
)
321-
assert result["run_all"] is True
321+
assert result["run_all"] is False
322+
assert len(result["affected"]) > 0
322323

323324
def test_deleted_traceable_file_triggers_run_all(self):
324325
"""A deleted component file triggers run_all (conservative)."""

‎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)

0 commit comments

Comments
 (0)