sgl-project/sglang · error · ValueError
func_path should contain both module name and func name (suc
Error message
func_path should contain both module name and func name (such as 'module.func')
What it means
dynamic_import splits func_path on '.' and requires at least two parts so it can derive module_path + func_name. A bare name like 'foo' (no dot) cannot identify a module and is rejected.
Source
Thrown at python/sglang/srt/utils/common.py:3971
def __getitem__(self, key):
return self.value[key]
def __setitem__(self, key, value):
self.value[key] = value
@property
def value(self):
if self._creator is not None:
self._value = self._creator()
self._creator = None
return self._value
def dynamic_import(func_path: str):
parts = func_path.split(".")
if len(parts) < 2:
raise ValueError(
"func_path should contain both module name and func name (such as 'module.func')"
)
module_path = ".".join(parts[:-1])
func_name = parts[-1]
module = importlib.import_module(module_path)
func = getattr(module, func_name)
return func
def gc_object_counts():
import gc
g0 = len(gc.get_objects(0))
g1 = len(gc.get_objects(1))
g2 = len(gc.get_objects(2))
return g0, g1, g2
View on GitHub (pinned to 0132848349)
Solutions
- Use fully qualified 'package.module.func' form
- Validate the config string contains a '.' before passing
- Default the config to a shipped fully-qualified function
Example fix
# before
fn = dynamic_import("eplb")
# after
fn = dynamic_import("sglang.srt.eplb.eplb_manager") Defensive patterns
Strategy: validation
Validate before calling
assert "." in func_path and len(func_path.split(".")) >= 2 Type guard
def is_qualified_path(s: str) -> bool:
return isinstance(s, str) and s.count(".") >= 1 and all(s.split(".")) Prevention
- Always configure fully qualified 'module.sub.func' strings
- Validate config strings at startup
When it happens
Trigger: Passing 'mymodel', 'run', or '' to dynamic_import — any string without a '.' separator.
Common situations: Config strings for pluggable attention/workload functions where the user forgot the module qualifier, or an empty default leaked through.
Related errors
- Block sparse tensors{context} require BLOCK_SIZE_KV={base_n_
- Invalid arch format: {arch_str}
- KernelSpec.target must be 'module:attr', got {self.target!r}
- {transformer_cls_name} is not officially supported by cache-
- Dual-transformer cache-dit is only supported for {sorted(DUA
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/14340d636882e6eb.
Report an issue: GitHub.