@@ -85,6 +85,78 @@ def write_jsonl(path: Path, rows: list[dict[str, object]]) -> None:
8585 )
8686
8787
88+ def test_single_gpu_model_loading_does_not_require_accelerate_device_map () -> None :
89+ class FakeModel :
90+ calls : list [tuple [str , dict [str , object ]]] = []
91+
92+ @classmethod
93+ def from_pretrained (cls , path : str , ** kwargs : object ) -> "FakeModel" :
94+ cls .calls .append ((path , kwargs ))
95+ return cls ()
96+
97+ def to (self , device : str ) -> "FakeModel" :
98+ self .device = device
99+ return self
100+
101+ model = runtime_common .load_model_explicit_cuda (
102+ FakeModel ,
103+ model_path = "/models/qwen" ,
104+ dtype = "bf16-sentinel" ,
105+ attn_implementation = "flash_attention_2" ,
106+ local_rank = 3 ,
107+ )
108+
109+ assert model .device == "cuda:3"
110+ assert FakeModel .calls == [
111+ (
112+ "/models/qwen" ,
113+ {
114+ "dtype" : "bf16-sentinel" ,
115+ "trust_remote_code" : True ,
116+ "local_files_only" : True ,
117+ "attn_implementation" : "flash_attention_2" ,
118+ },
119+ )
120+ ]
121+ assert "device_map" not in FakeModel .calls [0 ][1 ]
122+ assert qwen35_mod .load_model_explicit_cuda is runtime_common .load_model_explicit_cuda
123+ assert qwen3vl_mod .load_model_explicit_cuda is runtime_common .load_model_explicit_cuda
124+ assert runtime_common .explicit_cuda_placement_metadata (3 ) == {
125+ "device_map" : None ,
126+ "device_placement" : "explicit_model_to" ,
127+ "model_device" : "cuda:3" ,
128+ }
129+
130+
131+ def test_single_gpu_model_loading_keeps_torch_dtype_compatibility_retry () -> None :
132+ class LegacyModel :
133+ calls : list [dict [str , object ]] = []
134+
135+ @classmethod
136+ def from_pretrained (cls , _path : str , ** kwargs : object ) -> "LegacyModel" :
137+ cls .calls .append (kwargs )
138+ if "dtype" in kwargs :
139+ raise TypeError ("legacy model expects torch_dtype" )
140+ return cls ()
141+
142+ def to (self , device : str ) -> "LegacyModel" :
143+ self .device = device
144+ return self
145+
146+ model = runtime_common .load_model_explicit_cuda (
147+ LegacyModel ,
148+ model_path = "/models/legacy-qwen" ,
149+ dtype = "bf16-sentinel" ,
150+ attn_implementation = "flash_attention_2" ,
151+ local_rank = 0 ,
152+ )
153+
154+ assert model .device == "cuda:0"
155+ assert "device_map" not in LegacyModel .calls [0 ]
156+ assert "device_map" not in LegacyModel .calls [1 ]
157+ assert LegacyModel .calls [1 ]["torch_dtype" ] == "bf16-sentinel"
158+
159+
88160def test_scoring_video_path_prefers_eval_video_path_then_path_then_video_path () -> None :
89161 assert (
90162 runtime_common .scoring_video_path (
@@ -1104,6 +1176,7 @@ def test_runtime_example_matches_wrbench_default_d3d6_profile() -> None:
11041176
11051177 assert env ["PROMPT_MODE" ] == p25 .P25_PROMPT_MODE
11061178 assert env ["TASK_CONTEXT_MODE" ] == "none"
1179+ assert int (env ["QWEN3VL_MAX_NEW_TOKENS" ]) == qwen3vl_mod .DEFAULT_MAX_NEW_TOKENS
11071180
11081181
11091182def test_current_qwen35_profile_is_declared_without_overlay_install () -> None :
0 commit comments