File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
vllm/model_executor/models Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,10 @@ def register_model(
347347 when importing the model and thus the related error
348348 :code:`RuntimeError: Cannot re-initialize CUDA in forked subprocess`.
349349 """
350+ if not isinstance (model_arch , str ):
351+ msg = f"`model_arch` should be a string, not a { type (model_arch )} "
352+ raise TypeError (msg )
353+
350354 if model_arch in self .models :
351355 logger .warning (
352356 "Model architecture %s is already registered, and will be "
@@ -360,8 +364,18 @@ def register_model(
360364 raise ValueError (msg )
361365
362366 model = _LazyRegisteredModel (* split_str )
363- else :
367+
368+ try :
369+ model .inspect_model_cls ()
370+ except Exception as exc :
371+ msg = f"Unable to inspect model { model_cls } "
372+ raise RuntimeError (msg ) from exc
373+ elif isinstance (model_cls , type ) and issubclass (model_cls , nn .Module ):
364374 model = _RegisteredModel .from_model_cls (model_cls )
375+ else :
376+ msg = ("`model_cls` should be a string or PyTorch model class, "
377+ f"not a { type (model_arch )} " )
378+ raise TypeError (msg )
365379
366380 self .models [model_arch ] = model
367381
You can’t perform that action at this time.
0 commit comments