Skip to content

Commit 71e98c1

Browse files
fix(vllm): generate protobuf 6 compatible stubs (#10944)
Pin vLLM protogen to grpcio-tools 1.78.0 so its generated code remains importable by protobuf 6.33.x, and remove stale generated artifacts before regeneration. Closes #10940 Assisted-by: Codex:gpt-5 [Codex] Co-authored-by: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com>
1 parent 1021194 commit 71e98c1

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

backend/python/common/libbackend.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,18 @@ function runProtogen() {
407407
# protobuf runtime lower (vLLM pins it to 6.33.6), crashing the backend with
408408
# "grpc service not ready" before it ever loads a model. Pinning
409409
# grpcio-tools to the installed grpcio version keeps the gencode in step with
410-
# the runtime. Falls back to unpinned when grpcio isn't installed yet.
410+
# the runtime. Backends whose protobuf runtime trails grpcio can set
411+
# GRPCIO_TOOLS_VERSION to the newest generator their runtime accepts. Falls
412+
# back to unpinned when grpcio isn't installed yet.
411413
# See mudler/LocalAI#10718.
412414
local grpcio_tools_spec="grpcio-tools"
413415
local grpcio_version
414-
grpcio_version="$(python -c 'import importlib.metadata as m; print(m.version("grpcio"))' 2>/dev/null || true)"
415-
if [ -n "${grpcio_version}" ]; then
416+
if [ -n "${GRPCIO_TOOLS_VERSION:-}" ]; then
417+
grpcio_tools_spec="grpcio-tools==${GRPCIO_TOOLS_VERSION}"
418+
else
419+
grpcio_version="$(python -c 'import importlib.metadata as m; print(m.version("grpcio"))' 2>/dev/null || true)"
420+
fi
421+
if [ "${grpcio_tools_spec}" = "grpcio-tools" ] && [ -n "${grpcio_version}" ]; then
416422
grpcio_tools_spec="grpcio-tools==${grpcio_version}"
417423
fi
418424

@@ -422,6 +428,7 @@ function runProtogen() {
422428
uv pip install "${grpcio_tools_spec}"
423429
fi
424430
pushd "${EDIR}" >/dev/null
431+
rm -f backend_pb2.py backend_pb2.pyi backend_pb2_grpc.py
425432
# use the venv python (ensures correct interpreter & sys.path)
426433
python -m grpc_tools.protoc -I../../ -I./ --python_out=. --grpc_python_out=. backend.proto
427434
popd >/dev/null

backend/python/vllm/install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ set -e
33

44
EXTRA_PIP_INSTALL_FLAGS="--no-build-isolation"
55

6+
# grpcio 1.82 bundles protoc 7.x, while vLLM's resolved protobuf runtime is
7+
# still 6.33.x. Generate the backend stubs with the newest grpcio-tools release
8+
# that emits protobuf 6.x gencode; the newer grpcio runtime can consume those
9+
# stubs, but protobuf 6.x cannot import 7.x gencode.
10+
export GRPCIO_TOOLS_VERSION="1.78.0"
11+
612
# Avoid to overcommit the CPU during build
713
# https://github.com/vllm-project/vllm/issues/20079
814
# https://docs.vllm.ai/en/v0.8.3/serving/env_vars.html

0 commit comments

Comments
 (0)