Skip to content

Commit

Permalink
[Fix] Ignore import error (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
merrymercy authored Sep 25, 2024
1 parent 37c5899 commit 9ae1db0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/sglang/srt/model_executor/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,17 +568,25 @@ def import_model_classes():
package = importlib.import_module(package_name)
for _, name, ispkg in pkgutil.iter_modules(package.__path__, package_name + "."):
if not ispkg:
module = importlib.import_module(name)
try:
module = importlib.import_module(name)
except Exception as e:
logger.warning(f"Ignore import error when loading {name}. " f"{e}")
continue
if hasattr(module, "EntryClass"):
entry = module.EntryClass
if isinstance(
entry, list
): # To support multiple model classes in one module
for tmp in entry:
assert tmp.__name__ not in model_arch_name_to_cls
assert (
tmp.__name__ not in model_arch_name_to_cls
), f"Duplicated model implementation for {tmp.__name__}"
model_arch_name_to_cls[tmp.__name__] = tmp
else:
assert entry.__name__ not in model_arch_name_to_cls
assert (
entry.__name__ not in model_arch_name_to_cls
), f"Duplicated model implementation for {entry.__name__}"
model_arch_name_to_cls[entry.__name__] = entry

return model_arch_name_to_cls
Expand Down

0 comments on commit 9ae1db0

Please sign in to comment.