4040
4141logger = 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" ,
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
7297def _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
0 commit comments