Skip to content

Commit 010ae62

Browse files
Copilotxiaoyu-work
andauthored
Merge remote-tracking branch 'origin/main' into refactor/typed-weight-pipeline
# Conflicts: # src/mobius/_builder.py Co-authored-by: xiaoyu-work <[email protected]>
2 parents 15c0dfc + a471d34 commit 010ae62

361 files changed

Lines changed: 93075 additions & 27501 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/adding-a-new-model/SKILL.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,11 @@ See the **writing-tests** skill for full details. At minimum:
242242
- `is_representative=True` if the model has unique behaviour
243243
- `is_representative=False` if it's an alias with no special config
244244

245-
Then verify: `pytest tests/build_graph_test.py -k "my_model_type"`
245+
Then verify: `pytest tests/build_graph -k "my_model_type"`
246246

247-
2. **Add a small model to `tests/integration_test.py`** if a small
248-
checkpoint exists (< 1B parameters preferred).
247+
2. **Add a small model to the appropriate focused integration suite** if a
248+
small checkpoint exists (< 1B parameters preferred). Generic causal LMs
249+
use `TEXT_MODELS` in `tests/integration/_support.py`.
249250

250251
3. **Testing large models with random weights:** Create a reduced HF model:
251252
```python
@@ -283,7 +284,7 @@ see the [quality-checklist skill](../quality-checklist/SKILL.md).
283284
- [ ] Tiny config in `tests/_test_configs.py` (with `is_representative` flag)
284285
- [ ] L2 YAML test case in `testdata/cases/` with `test_model_id`
285286
- [ ] L3 synthetic parity passes (`tests/synthetic_parity_test.py -k "<model_type>"`)
286-
- [ ] Integration test in `tests/integration_test.py` (if small checkpoint available)
287+
- [ ] Focused integration test in `tests/integration/` (if small checkpoint available)
287288
- [ ] L4 golden file generated and committed (`testdata/golden/`)
288289
- [ ] L5 generation golden file generated and committed
289290
- [ ] Graph-derived ORT GenAI metadata is tested; downstream load/generation is

‎.agents/skills/adding-a-new-model/references/architecture-patterns.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ graphs; weight-loading may need minor adjustments:
5050
### NEVER safe as registry aliases
5151

5252
These model families have fundamentally different computation that **cannot**
53-
be represented by standard base classes, even though `build_graph_test` passes:
53+
be represented by standard base classes, even though the L1 graph suite passes:
5454

5555
| Category | Models | Why it fails |
5656
|----------|--------|-------------|

‎.agents/skills/debugging-multimodal/SKILL.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ assert_logits_close(onnx_logits, hf_logits, rtol=2e-2, atol=2e-1)
339339
> extraction, integration test patterns, tolerance guidelines, weight
340340
> loading verification, and HD multi-crop verification.
341341
342-
- **Integration tests:** `tests/integration_test.py`
343-
(`TestVLFullForward`, `TestQwen25VL3Model`),
342+
- **Integration tests:** `tests/integration/vlm_test.py`
343+
(`TestVLTextForward`, `TestQwen25VL3Model`),
344+
`tests/integration/multimodal_pipeline_test.py`,
344345
`tests/phi4mm_integration_test.py`
345346
- **ORT GenAI tests:** `tests/ort_genai_test.py`
346347
- **Example scripts:** `examples/qwen25_vl_ort_genai.py`,

‎.agents/skills/diffusion-models/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ new task in `tasks/`. Most denoisers use the standard `DenoisingTask`.
340340

341341
### 5. Add unit test
342342

343-
In `tests/build_graph_test.py`, add a tiny config:
343+
In the appropriate `tests/build_graph` domain file, add a tiny graph test:
344344

345345
```python
346346
("my_denoiser", MyDenoiser2DModel, MyDenoiserConfig(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: microsoft-managed-machine
3+
description: Applies on Microsoft-managed machines when installing Python/PyPI packages.
4+
---
5+
6+
# Microsoft-managed machine
7+
8+
Install Python packages through the Microsoft package feed proxy:
9+
10+
```bash
11+
pip install <package> --index-url https://packagefeedproxy.microsoft.io/pypi/simple
12+
```

‎.agents/skills/moe-models/SKILL.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ unpacks these into per-expert tensors and also renames
254254

255255
Integration tests use a random-weight HF model with reduced layers and
256256
experts (e.g. 4 layers, 4 experts, top-2 routing). See
257-
`test_qwen35_moe_prefill_logits_match` in `tests/integration_test.py`.
257+
`test_qwen35_moe_prefill_logits_match` in
258+
`tests/integration/architectures_test.py`.
258259

259260
## Testing MoE models
260261

‎.agents/skills/multi-agent-coordination/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Fix the Phi-2 MLP weight mismatch: replace the gated MLP (gate_proj/up_proj/down
216216
with FCMLP (fc1/fc2) in src/mobius/models/phi.py. The HF weights use fc1/fc2.
217217
218218
After changes, run:
219-
python -m pytest tests/build_graph_test.py -k "phi" -q
219+
python -m pytest tests/build_graph -k "phi" -q
220220
221221
Commit message: "fix: use FCMLP for Phi-1/2 model (HF uses fc1/fc2 not gated MLP)"
222222
Push to justinchu/fix-model-parity immediately after committing.

‎.agents/skills/multimodal-models/references/scan-pattern.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ If building manually, ensure the body graph has opset imports.
358358

359359
## Testing Scan-based code
360360

361-
Unit tests (`build_graph_test.py`) verify graph construction only. To
361+
Unit tests (`tests/build_graph/`) verify graph construction only. To
362362
verify Scan correctness at runtime, build the vision model, fill
363363
initializers with random weights, and run with ORT:
364364

‎.agents/skills/quality-checklist/SKILL.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ reason — before the PR is merged.
4949
for VLM / audio models)
5050
- [ ] `is_representative=True` if the model has unique behaviour (custom
5151
class, special attention, MoE, hybrid layers, etc.)
52-
- [ ] `python -m pytest tests/build_graph_test.py -k "<model_type>"` passes
52+
- [ ] `python -m pytest tests/build_graph -k "<model_type>"` passes
5353
- [ ] Weight-alignment test passes:
5454
`python -m pytest tests/weight_alignment_test.py -k "<model_type>"`
5555

@@ -67,8 +67,9 @@ reason — before the PR is merged.
6767
`_test_configs.py`; added automatically for text-generation models)
6868
- [ ] `python -m pytest tests/synthetic_parity_test.py -k "<model>"` passes
6969
with `atol=1e-3` / `rtol=1e-3` (or `1e-2` for multimodal)
70-
- [ ] Real-weight parity also checked via `tests/integration_test.py` (add
71-
model to `_TEXT_MODELS` or equivalent if a small checkpoint is available)
70+
- [ ] Real-weight parity also checked via a focused integration suite (add
71+
generic causal LMs to `TEXT_MODELS` in `tests/integration/_support.py`
72+
if a small checkpoint is available)
7273

7374
### 5. L4 — Golden match
7475

@@ -269,7 +270,7 @@ lintrunner f --output oneline --all-files
269270
lintrunner -a
270271

271272
# L1 – graph build
272-
python -m pytest tests/build_graph_test.py -k "<model_type>"
273+
python -m pytest tests/build_graph -k "<model_type>"
273274

274275
# L1 – weight alignment
275276
python -m pytest tests/weight_alignment_test.py -k "<model_type>"
@@ -281,7 +282,7 @@ python -m pytest tests/yaml_schema_test.py
281282
python -m pytest tests/synthetic_parity_test.py -k "<model>" -sv
282283

283284
# L3 – real-weight integration (if small checkpoint available)
284-
python -m pytest tests/integration_test.py -m integration -k "<model>" -sv
285+
python -m pytest tests/integration -m integration -k "<model>" -sv
285286

286287
# L4 – generate golden
287288
python scripts/generate_golden.py --level L4 --filter '<model>*'

‎.agents/skills/writing-tests/SKILL.md‎

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ without passing L2, or have L4 golden data without passing L3.
4444

4545
| Level | Name | What it verifies | Data source |
4646
|-------|------|-----------------|-------------|
47-
| **L1** | Graph builds | ONNX graph builds from a tiny synthetic config | `tests/_test_configs.py` + `tests/build_graph_test.py` |
47+
| **L1** | Graph builds | ONNX graph builds from a tiny synthetic config | `tests/_test_configs.py` + `tests/build_graph` |
4848
| **L2** | Config compatible | Full-size HF config produces a valid graph | `test_model_id` in YAML test case (`testdata/cases/`) |
49-
| **L3** | Synthetic parity | Random-weight forward pass matches HF numerically | `tests/integration_test.py` parametrized tests |
49+
| **L3** | Synthetic parity | Random-weight forward pass matches HF numerically | `tests/synthetic_parity_test.py` and focused integration suites |
5050
| **L4** | Golden match | Real-weight prefill logits match pre-computed reference | `testdata/golden/<cat>/<model>.json` |
5151
| **L5** | Generation verified | Full multi-token generation matches golden output | `testdata/golden/<cat>/<model>_generation.json` |
5252

@@ -60,17 +60,17 @@ models.
6060

6161
```bash
6262
# All non-integration tests (fast, no downloads)
63-
python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q \
63+
python -m pytest tests/build_graph tests/cli_test.py src/ -q \
6464
-k "not phi4mm and not apply_weights_unknown" --tb=short
6565

6666
# Representative models only (~5 seconds)
67-
python -m pytest tests/build_graph_test.py --fast
67+
python -m pytest tests/build_graph --fast
6868

6969
# Single model type
70-
python -m pytest tests/build_graph_test.py -k "phi4mm"
70+
python -m pytest tests/build_graph -k "phi4mm"
7171

7272
# Integration tests (slow, downloads models)
73-
python -m pytest tests/integration_test.py -m integration -k "qwen2.5-0.5b"
73+
python -m pytest tests/integration/text_test.py -m integration -k "qwen2.5-0.5b"
7474

7575
# L4/L5 golden tests
7676
python -m pytest tests/e2e_golden_test.py -m golden --level L4 -v
@@ -86,9 +86,20 @@ python scripts/generate_golden.py --level L4 --filter 'my-model*'
8686

8787
```
8888
tests/
89-
├── build_graph_test.py # L1: graph construction (no weights)
89+
├── build_graph/ # L1: graph construction by model domain
90+
│ ├── _support.py # shared helpers and coverage inventory
91+
│ ├── core_test.py
92+
│ ├── cache_test.py
93+
│ ├── diffusion_audio_test.py
94+
│ ├── recurrent_test.py
95+
│ ├── speech_test.py
96+
│ └── vision_language_test.py
9097
├── _test_configs.py # shared model configs for all tests
91-
├── integration_test.py # L3: real-weight numerical parity
98+
├── integration/ # focused real-weight and architecture parity suites
99+
│ ├── _support.py # shared session/feed helpers and text cases
100+
│ ├── text_test.py
101+
│ ├── generation_test.py
102+
│ └── ... # VLM, encoder/media, architecture, and heavy suites
92103
├── e2e_golden_test.py # L4 + L5: golden file comparison
93104
├── yaml_schema_test.py # YAML test case schema validation
94105
├── weight_alignment_test.py # L1: preprocess_weights correctness
@@ -132,15 +143,15 @@ CAUSAL_LM_CONFIGS: list[tuple[str, dict, bool]] = [
132143

133144
## L1: Graph build tests
134145

135-
Located in `tests/build_graph_test.py`. Uses tiny synthetic configs
146+
Located in `tests/build_graph`. Uses tiny synthetic configs
136147
(64 hidden, 2 layers, 256 vocab) — no weights, no network.
137148

138149
The framework checks: inputs exist (`input_ids`, `attention_mask`,
139150
`position_ids`), outputs exist (`logits`, KV cache), and initializers
140151
are present.
141152

142-
VLM/audio models use dedicated test methods tracked in
143-
`_SPECIALIZED_TEST_MODEL_TYPES`.
153+
Models with dedicated test methods are tracked in
154+
`tests/build_graph/_support.py::specialized_test_model_types()`.
144155

145156
### Weight alignment tests
146157

@@ -166,9 +177,10 @@ set to a real HF model ID.
166177

167178
## L3: Integration tests
168179

169-
Located in `tests/integration_test.py`. Parametrized with
170-
`(model_id, trust_remote_code)`. Prefer models ≤ 1B, publicly accessible,
171-
one per distinct model class.
180+
Located in focused `tests/integration/*_test.py` modules. The generic text
181+
suite is parametrized with `(model_id, trust_remote_code)` from
182+
`tests/integration/_support.py`. Prefer models ≤ 1B, publicly accessible, one
183+
per distinct model class.
172184

173185
> Read [`references/test-examples.md`](references/test-examples.md) for
174186
> full prefill/decode/generation code patterns.

0 commit comments

Comments
 (0)