{"record":{"id":"b20916ef6c40d2c1","repo":"sgl-project/sglang","slug":"grpc-mode-requires-the-smg-grpc-servicer-package","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/entrypoints/grpc_server.py","lineNumber":161,"sourceCode":"                return err\n            return web.Response(text=\"Stop profiling. This will take some time.\\n\")\n        except Exception as e:\n            logger.exception(\"Failed to stop profile\")\n            return web.Response(\n                status=500,\n                text=f\"Internal error: {type(e).__name__}. Check server logs.\\n\",\n            )\n\n    app.router.add_post(\"/start_profile\", start_profile_handler)\n    app.router.add_post(\"/stop_profile\", stop_profile_handler)\n\n\nasync def serve_grpc(server_args, model_info=None):\n    \"\"\"Start the standalone gRPC server with integrated scheduler.\"\"\"\n    try:\n        from smg_grpc_servicer.sglang.server import serve_grpc as _serve_grpc\n    except ImportError as e:\n        raise ImportError(\n            \"gRPC mode requires the smg-grpc-servicer package. \"\n            \"If not installed, run: pip install smg-grpc-servicer[sglang]. \"\n            \"If already installed, there may be a broken import due to a \"\n            \"version mismatch — see the chained exception above for details.\"\n        ) from e\n\n    from sglang.srt.arg_groups.overrides import resolving_view\n\n    # The integrated servicer builds an `Engine`, which validates and publishes\n    # on its own. Validating here would run `check_server_args` twice, and the\n    # LoRA normalization is not idempotent -- the second pass sees the `LoRARef`\n    # objects the first one declared and rejects them. So this entry reads the\n    # declarations for what it needs before the engine exists.\n    cfg = resolving_view(server_args)\n\n    sidecar_app = web.Application()\n    sidecar_runner = None\n    sidecar_port = (","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/grpc_server.py#L143-L179","documentation":"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.","triggerScenarios":"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.","commonSituations":"Fresh environment without the extra; upgrading sglang without upgrading smg-grpc-servicer (or vice versa); mixed conda/pip installs leaving broken package metadata.","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"],"exampleFix":"# before\npython -m sglang.launch_server --model ... --grpc\n# after\npip install 'smg-grpc-servicer[sglang]'\npython -m sglang.launch_server --model ... --grpc","handlingStrategy":"fallback","validationCode":"from importlib.util import find_spec\nif find_spec(\"smg_grpc_servicer\") is None:\n    raise SystemExit(\"Install first: pip install smg-grpc-servicer[sglang]\")","typeGuard":"def grpc_backend_available() -> bool:\n    from importlib.util import find_spec\n    return find_spec(\"smg_grpc_servicer.sglang\") is not None","tryCatchPattern":"try:\n    from smg_grpc_servicer.sglang.server import serve_grpc\nexcept ImportError:\n    serve_http(server_args)  # fallback to HTTP entrypoint","preventionTips":["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"],"tags":["grpc","dependency","import-error","installation","sglang"],"backgroundTag":"missing-optional-dependency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}