1
1
import json as json_lib
2
+ import logging
2
3
import os
3
4
from collections .abc import Iterable
4
5
from typing import List , Optional , Set , Tuple
27
28
)
28
29
from sglang .srt .utils import add_prefix
29
30
31
+ logger = logging .getLogger (__name__ )
32
+
30
33
31
34
class Llama4ForConditionalGeneration (nn .Module ):
32
35
packed_modules_mapping = {
@@ -46,6 +49,11 @@ def __init__(
46
49
47
50
# Check if this is a text-only model (modelopt fp8 llama4 has no vision components)
48
51
self .has_vision = self ._has_vision_weights (config )
52
+ if not self .has_vision :
53
+ logger .warning (
54
+ "No vision weights found in checkpoint. Model will run in text-only mode. "
55
+ "Multimodal capabilities (image processing) will be unavailable."
56
+ )
49
57
50
58
if self .has_vision :
51
59
self .vision_model = Llama4VisionModel (config .vision_config )
@@ -225,12 +233,10 @@ def load_weights(self, weights: Iterable[Tuple[str, torch.Tensor]]) -> Set[str]:
225
233
)
226
234
227
235
for name , loaded_weight in weights :
228
- if not self ._should_load_weight (name ):
236
+ if self ._should_skip_weight (name ):
229
237
continue
230
238
231
239
name = self ._transform_weight_name (name )
232
- if name is None :
233
- continue
234
240
235
241
if "vision" not in name :
236
242
name , loaded_weight = self .permute_qk_weight_for_rotary (
@@ -252,9 +258,9 @@ def load_weights(self, weights: Iterable[Tuple[str, torch.Tensor]]) -> Set[str]:
252
258
253
259
self ._handle_default_weight (name , loaded_weight , params_dict )
254
260
255
- def _should_load_weight (self , name : str ) -> bool :
256
- """Check if we should load this weight."""
257
- return not ( "vision" in name and not self .has_vision )
261
+ def _should_skip_weight (self , name : str ) -> bool :
262
+ """Check if we should skip loading this weight."""
263
+ return "vision" in name and not self .has_vision
258
264
259
265
def _transform_weight_name (self , name : str ) -> str :
260
266
"""Transform weight name by adding language_model prefix if needed."""
0 commit comments