sgl-project/sglang · critical · ImportError
gRPC mode requires the smg-grpc-servicer package. If not ins
Error message
gRPC mode requires the smg-grpc-servicer package. If not installed, run: pip install smg-grpc-servicer[sglang]. If already installed, there may be a broken import due to a version mismatch — see the chained exception above for details.
What it means
Thrown by serve_grpc when importing smg_grpc_servicer.sglang.server fails, meaning the optional gRPC servicer package is absent or broken. sglang keeps the gRPC backend out of its core dependencies, so launching a gRPC server requires the extra package to be installed and importable.
Source
Thrown at python/sglang/srt/entrypoints/grpc_server.py:161
return err
return web.Response(text="Stop profiling. This will take some time.\n")
except Exception as e:
logger.exception("Failed to stop profile")
return web.Response(
status=500,
text=f"Internal error: {type(e).__name__}. Check server logs.\n",
)
app.router.add_post("/start_profile", start_profile_handler)
app.router.add_post("/stop_profile", stop_profile_handler)
async def serve_grpc(server_args, model_info=None):
"""Start the standalone gRPC server with integrated scheduler."""
try:
from smg_grpc_servicer.sglang.server import serve_grpc as _serve_grpc
except ImportError as e:
raise ImportError(
"gRPC mode requires the smg-grpc-servicer package. "
"If not installed, run: pip install smg-grpc-servicer[sglang]. "
"If already installed, there may be a broken import due to a "
"version mismatch — see the chained exception above for details."
) from e
from sglang.srt.arg_groups.overrides import resolving_view
# The integrated servicer builds an `Engine`, which validates and publishes
# on its own. Validating here would run `check_server_args` twice, and the
# LoRA normalization is not idempotent -- the second pass sees the `LoRARef`
# objects the first one declared and rejects them. So this entry reads the
# declarations for what it needs before the engine exists.
cfg = resolving_view(server_args)
sidecar_app = web.Application()
sidecar_runner = None
sidecar_port = (View on GitHub (pinned to 0132848349)
Solutions
- pip install 'smg-grpc-servicer[sglang]' (match it to your sglang version)
- If already installed, reinstall to repair the broken import: pip install --force-reinstall smg-grpc-servicer[sglang]
- Check the chained ImportError ('from e') to see which inner module failed and fix that specific mismatch
- Alternatively run the HTTP server instead of gRPC mode if the extra is not needed
Example fix
# before python -m sglang.launch_server --model ... --grpc # after pip install 'smg-grpc-servicer[sglang]' python -m sglang.launch_server --model ... --grpc
Defensive patterns
Strategy: fallback
Validate before calling
from importlib.util import find_spec
if find_spec("smg_grpc_servicer") is None:
raise SystemExit("Install first: pip install smg-grpc-servicer[sglang]") Type guard
def grpc_backend_available() -> bool:
from importlib.util import find_spec
return find_spec("smg_grpc_servicer.sglang") is not None Try / catch
try:
from smg_grpc_servicer.sglang.server import serve_grpc
except ImportError:
serve_http(server_args) # fallback to HTTP entrypoint Prevention
- Pin smg-grpc-servicer[sglang] in requirements alongside sglang
- Smoke-test the import in Docker build/CI before deploying gRPC mode
- Upgrade sglang and the servicer together to avoid version mismatch
When it happens
Trigger: Running the server with --grpc (or otherwise invoking serve_grpc/run_server in gRPC mode) when smg-grpc-servicer is not installed, partially installed, or its imports fail due to an ABI/version mismatch with the installed sglang.
Common situations: Fresh environment without the extra; upgrading sglang without upgrading smg-grpc-servicer (or vice versa); mixed conda/pip installs leaving broken package metadata.
Related errors
- Please install mooncake by following the instructions at htt
- --enable-metrics requires smg-grpc-servicer ≥ 0.5.3 (the ver
- ModelOpt is not available. Please install modelopt.
- {flashinfer_error}
- The MLX tensor bridge requires MLX >= 0.32.0
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b20916ef6c40d2c1.
Report an issue: GitHub.