sgl-project/sglang · error · ValueError
_load_function expects 'pkg.module.symbol', got {path!r} (mi
Error message
_load_function expects 'pkg.module.symbol', got {path!r} (missing dotted prefix) What it means
Raised by the internal _load_function helper when the path argument has no dotted module prefix, i.e. rpartition('.') finds no '.' so module_path is empty. The helper requires a fully qualified 'pkg.module.symbol' string so it can importlib.import_module the module and getattr the symbol. A bare name like 'foo' cannot be resolved to any module.
Source
Thrown at python/sglang/srt/debug_utils/dumper.py:1582
s.connect(("2001:4860:4860::8888", 80)) # Doesn't need to be reachable
return s.getsockname()[0]
except Exception:
_log("Can not get local ip by remote")
return None
def _load_function(path: str) -> Callable:
"""Resolve a fully-qualified Python path 'pkg.module.symbol' to its object.
Copied (verbatim, minus the function-registry branch) from
miles.utils.misc.load_function — kept inline so dumper.py has no
cross-package dependency.
"""
import importlib
module_path, _, attr = path.rpartition(".")
if not module_path:
raise ValueError(
f"_load_function expects 'pkg.module.symbol', got {path!r} "
f"(missing dotted prefix)"
)
module = importlib.import_module(module_path)
return getattr(module, attr)
def _init_custom_process_group(
*,
backend: str,
init_method: str,
world_size: int,
rank: int,
group_name: str,
timeout=None,
):
"""Build a fresh torch.distributed process group, separate from the default
one and any other custom groups (e.g. RLHF weight-update groups). Used byView on GitHub (pinned to 0132848349)
Solutions
- Use the fully qualified path including package and module, e.g. 'sglang.srt.layers.mymodule.myfunc'
- Verify the module imports cleanly in a REPL before configuring it (python -c "import pkg.module")
- If loading from config, print/validate the path at config load time to catch typos early
Example fix
# before
_load_function('capture_dump')
# after
_load_function('sglang.srt.debug_utils.hooks.capture_dump') Defensive patterns
Strategy: validation
Validate before calling
def is_valid_load_path(path: str) -> bool:
return bool(path) and '.' in path and path.rpartition('.')[0].isidentifier() is not None
assert is_valid_load_path(path), f"path must be 'pkg.module.symbol', got {path!r}" Type guard
def is_qualified_symbol_path(path: str) -> bool:
parts = path.split('.')
return len(parts) >= 2 and all(p.isidentifier() for p in parts) and not path.startswith('.') and not path.endswith('.') Try / catch
try:
fn = _load_function(path)
except ValueError:
raise ConfigError(f'hook path {path!r} must be pkg.module.symbol') from None Prevention
- Always write hook paths fully qualified including the package
- Validate configured paths at startup, not at first use
- Test that the module imports in the target environment
When it happens
Trigger: Calling _load_function('myfunc') or _load_function('') — any string without a dot. Typical when a debug/dump hook path is configured via SGLANG_DEBUG env vars or YAML config and the user gave just the function name instead of the full dotted path.
Common situations: Misconfigured debug hook paths in environment variables or patch YAML files; refactoring moved a function to a new module and someone shortened the path; copy-paste from docs that omitted the package prefix.
Related errors
- DeepSeekV4 only supports interleave CP strategy, got {cfg.cp
- HiSparse requires one of {HISPARSE_KV_CACHE_DTYPES} KV cache
- MiniCPM does not support DP attention
- TensorRT-LLM MLA backend only supports kv-cache-dtype of fp8
- tokenspeed_mla backend requires kv-cache-dtype=fp8_e4m3, got
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/28797d8b7e2ae65b.
Report an issue: GitHub.