Skip to content

Commit 45ddf6a

Browse files
authored
Merge branch 'main' into refactor-configs-2-extractor-registry
Signed-off-by: Justin Chu <[email protected]>
2 parents b08b183 + 5d592c6 commit 45ddf6a

5 files changed

Lines changed: 145 additions & 21 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
model_id: "tencent/Hy-MT1.5-1.8B-2bit"
2+
model_type: "hunyuan_v1_dense"
3+
revision: "f89fcdc2b27e5a3c742789b909371971de8c042c"
4+
task_type: "text-generation"
5+
dtype: "float32"
6+
7+
inputs:
8+
prompts:
9+
- "<|hy_begin▁of▁sentence|><|hy_User|>Translate the following Chinese text to English: 黄河之水天上来<|hy_Assistant|>"
10+
11+
level: "L4+L5"
12+
13+
generation:
14+
max_new_tokens: 16
15+
do_sample: false
16+
eos_token_id: 120020 # <|hy_place▁holder▁no▁2|>, the HF generation_config EOS
17+
18+
notes: |
19+
Tencent Hy-MT1.5 1.8B translation model. Same architecture as the
20+
existing tiny-random hunyuan-v1-dense case, but with real weights so
21+
L4 prefill logits and L5 generation are meaningful. The repo name is
22+
"*-2bit" but it ships a full BF16 safetensors checkpoint alongside
23+
the 2-bit GGUF variant.
24+
25+
The prompt is pre-formatted with the Hy-MT chat template
26+
(<|hy_User|>...<|hy_Assistant|>) because generate_golden.py does
27+
not apply chat templates for causal-lm cases — feeding the raw
28+
instruction directly causes the model to hallucinate.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"top1_id": 628,
3+
"top2_id": 20543,
4+
"top10_ids": [
5+
628,
6+
20543,
7+
507,
8+
27420,
9+
1,
10+
76441,
11+
51,
12+
25209,
13+
5950,
14+
54
15+
],
16+
"top10_logits": [
17+
"0x1.f74b900000000p+3",
18+
"0x1.7076660000000p+3",
19+
"0x1.5f08520000000p+3",
20+
"0x1.5d26700000000p+3",
21+
"0x1.5996980000000p+3",
22+
"0x1.58200a0000000p+3",
23+
"0x1.4c169e0000000p+3",
24+
"0x1.39e5680000000p+3",
25+
"0x1.31ef820000000p+3",
26+
"0x1.1cbe5c0000000p+3"
27+
],
28+
"logits_summary": [
29+
"0x1.f74b900000000p+3",
30+
"-0x1.0b011e0000000p+3",
31+
"-0x1.4f6c421606072p+0",
32+
"0x1.5410b606fbc8bp+0"
33+
],
34+
"input_ids": [
35+
120000,
36+
120006,
37+
26403,
38+
252,
39+
1873,
40+
8251,
41+
2602,
42+
287,
43+
4717,
44+
25,
45+
206,
46+
25209,
47+
109554,
48+
1088,
49+
33839,
50+
120007
51+
]
52+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"model_id": "tencent/Hy-MT1.5-1.8B-2bit",
3+
"prompt": "<\uff5chy_begin\u2581of\u2581sentence\uff5c><\uff5chy_User\uff5c>Translate the following Chinese text to English: \u9ec4\u6cb3\u4e4b\u6c34\u5929\u4e0a\u6765<\uff5chy_Assistant\uff5c>",
4+
"generated_tokens": [
5+
628,
6+
16284,
7+
279,
8+
252,
9+
32075,
10+
10630,
11+
3899,
12+
562,
13+
252,
14+
63562,
15+
13,
16+
120020
17+
],
18+
"generated_text": "The waters of the Yellow River come from the heavens."
19+
}

‎tests/arch_validation_test.py‎

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,20 @@
4040

4141
logger = logging.getLogger(__name__)
4242

43-
# Build parametrized test cases from registry entries that have a test_model_id
44-
_KNOWN_XFAILS: dict[str, str] = {
45-
"phi3small": "gegelu activation not implemented (gated GELU variant)",
43+
# Build parametrized test cases from registry entries that have a test_model_id.
44+
#
45+
# We split known failures by which subset of tests they apply to:
46+
#
47+
# * ``_PARSE_AND_GRAPH_XFAILS`` — config loads successfully *and* would build
48+
# a graph successfully if not for a known limitation. xfail all three
49+
# sub-tests (currently empty; phi3small previously lived here but starts
50+
# passing once gegelu is implemented and was XPASS-ing across all three).
51+
# * ``_GRAPH_ONLY_XFAILS`` — config parses fine; only the full-graph build
52+
# and shape-consistency tests fail. This is the common case for VL models
53+
# whose vision sub-config requires ``trust_remote_code=True``.
54+
_PARSE_AND_GRAPH_XFAILS: dict[str, str] = {}
55+
56+
_GRAPH_ONLY_XFAILS: dict[str, str] = {
4657
# VL models with missing/incomplete vision_config when loaded without
4758
# trust_remote_code — the HF config JSON doesn't expose vision fields.
4859
"deepseek_vl": "VisionConfig.hidden_size missing without trust_remote_code",
@@ -55,18 +66,32 @@
5566
"ovis2": "VisionConfig missing without trust_remote_code",
5667
}
5768

58-
_ARCH_PARAMS = [
59-
pytest.param(
60-
model_type,
61-
registration.test_model_id,
62-
id=model_type,
63-
marks=[pytest.mark.xfail(reason=_KNOWN_XFAILS[model_type], strict=False)]
64-
if model_type in _KNOWN_XFAILS
65-
else [],
66-
)
67-
for model_type in sorted(registry.architectures())
68-
if (registration := registry.get_registration(model_type)).test_model_id is not None
69-
]
69+
70+
def _build_arch_params(extra_xfails: dict[str, str]):
71+
"""Build the pytest.param list, applying xfail marks from both dicts."""
72+
params = []
73+
for model_type in sorted(registry.architectures()):
74+
registration = registry.get_registration(model_type)
75+
if registration.test_model_id is None:
76+
continue
77+
reason = _PARSE_AND_GRAPH_XFAILS.get(model_type) or extra_xfails.get(model_type)
78+
marks = [pytest.mark.xfail(reason=reason, strict=True)] if reason is not None else []
79+
params.append(
80+
pytest.param(
81+
model_type,
82+
registration.test_model_id,
83+
id=model_type,
84+
marks=marks,
85+
)
86+
)
87+
return params
88+
89+
90+
# Parse test sees only the always-failing models; VL graph-only failures are
91+
# expected to PARSE cleanly.
92+
_PARSE_PARAMS = _build_arch_params({})
93+
# Graph tests see both always-failing and graph-only failures.
94+
_GRAPH_PARAMS = _build_arch_params(_GRAPH_ONLY_XFAILS)
7095

7196

7297
def _load_hf_config(model_id: str):
@@ -151,7 +176,7 @@ class TestArchValidation:
151176
that the graph has a reasonable structure.
152177
"""
153178

154-
@pytest.mark.parametrize("model_type,model_id", _ARCH_PARAMS)
179+
@pytest.mark.parametrize("model_type,model_id", _PARSE_PARAMS)
155180
def test_config_downloads_and_parses(self, model_type: str, model_id: str):
156181
"""Verify config.json can be downloaded and parsed."""
157182
hf_config = _load_hf_config(model_id)
@@ -162,7 +187,7 @@ def test_config_downloads_and_parses(self, model_type: str, model_id: str):
162187
# The config must have a model_type
163188
assert hasattr(hf_config, "model_type"), f"Config for {model_id} missing model_type"
164189

165-
@pytest.mark.parametrize("model_type,model_id", _ARCH_PARAMS)
190+
@pytest.mark.parametrize("model_type,model_id", _GRAPH_PARAMS)
166191
def test_full_graph_builds(self, model_type: str, model_id: str):
167192
"""Build full-size ONNX graph from real HF config (no weights).
168193
@@ -183,7 +208,7 @@ def test_full_graph_builds(self, model_type: str, model_id: str):
183208

184209
del pkg
185210

186-
@pytest.mark.parametrize("model_type,model_id", _ARCH_PARAMS)
211+
@pytest.mark.parametrize("model_type,model_id", _GRAPH_PARAMS)
187212
def test_graph_shapes_consistent(self, model_type: str, model_id: str):
188213
"""Validate structural consistency in the full-size graph.
189214

‎tests/yaml_schema_test.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
def _load_schema() -> dict[str, Any]:
31-
with open(_SCHEMA_PATH) as f:
31+
with open(_SCHEMA_PATH, encoding="utf-8") as f:
3232
return json.load(f)
3333

3434

@@ -53,7 +53,7 @@ def _all_yaml_files() -> list[Path]:
5353
)
5454
def test_yaml_validates_against_schema(yaml_path: Path) -> None:
5555
"""Each YAML test case must conform to testdata/cases/schema.json."""
56-
with open(yaml_path) as f:
56+
with open(yaml_path, encoding="utf-8") as f:
5757
data = yaml.safe_load(f)
5858

5959
errors = sorted(_VALIDATOR.iter_errors(data), key=lambda e: e.json_path)
@@ -97,7 +97,7 @@ def test_all_yaml_task_types_are_in_schema() -> None:
9797
schema_task_types: set[str] = set(_SCHEMA["properties"]["task_type"]["enum"])
9898
missing: list[str] = []
9999
for yaml_path in _YAML_FILES:
100-
with open(yaml_path) as f:
100+
with open(yaml_path, encoding="utf-8") as f:
101101
data = yaml.safe_load(f)
102102
task_type = data.get("task_type") if isinstance(data, dict) else None
103103
if task_type and task_type not in schema_task_types:

0 commit comments

Comments
 (0)