Skip to content

feat: bailian grpc server#846

Closed
xinfei-shi wants to merge 1 commit intomainfrom
develop/bailian
Closed

feat: bailian grpc server#846
xinfei-shi wants to merge 1 commit intomainfrom
develop/bailian

Conversation

@xinfei-shi
Copy link
Copy Markdown
Collaborator

No description provided.

@xinfei-shi xinfei-shi requested a review from LLLLKKKK as a code owner March 31, 2026 08:17
@LLLLKKKK
Copy link
Copy Markdown
Collaborator

LLLLKKKK commented Apr 1, 2026

Code Review: PR #846 — feat: bailian grpc server

Author: xinfei-shi
Review version: v1
Head SHA: 75bf929
Verdict: P1

Summary

为 RTP-LLM 添加 Bailian gRPC 服务(predict_v2 协议),主要变更:

  1. Bailian gRPC 服务: 新增 rtp_llm/bailian/ 模块,实现 GRPCInferenceService.ModelStreamInfer(服务端流式),支持 real(走引擎推理)和 fake(mock 联调)两种模式
  2. Proto 文件: 引入 predict_v2.proto(~1699 行)和 model_config.proto(~1978 行),来自 Triton 标准协议
  3. 端口布局变更: worker_info_port_num 默认值从 8 改为 9,为 Bailian gRPC 预留 base + 8 端口
  4. BailianGrpcConfig: C++ 侧新增配置类,支持 JSON 解析和 pybind pickle
  5. Frontend 集成: 在 FastAPI startup 中自动拉起 Bailian gRPC(后台线程),shutdown 时优雅停止
  6. 日志改进: streamLogTag() 替代 streamId(),日志中同时包含 stream ID 和 trace ID
  7. GrpcConfig 增强: 新增 max_server_pollers 支持
  8. 测试: 新增 request 解析测试和 response/server 测试(~500 行)
  9. 文档: 完整的使用说明、breaking changes 文档

P1 Issues

1. worker_info_port_num 默认值 8→9 是 Breaking Change

Files: server_group_args.py, py_config_modules.py

多 rank 部署中,rank >= 1 的端口基址会偏移(start_port + rank * 8start_port + rank * 9)。虽然文档中已详细说明(breaking-changes.md),但这个变更会影响所有未显式设置 worker_info_port_num 的多 rank 部署。

建议:考虑是否可以在不改变默认值的情况下,让 Bailian gRPC 使用独立的端口配置参数,避免影响现有部署。

2. Proto 文件体量过大(~3677 行),包含大量未使用的 message 定义

Files: predict_v2.proto (1699 行), model_config.proto (1978 行)

这两个 proto 文件来自 Triton 标准协议,包含大量 RTP-LLM 不会使用的 message(如 ModelEnsemblingCudaSharedMemory*ModelRepositoryAgents 等)。建议:

  • 如果需要与 Triton 客户端兼容,保留完整 proto 但添加注释说明哪些是实际使用的
  • 如果只需要 ModelStreamInfer,考虑裁剪 proto 减少维护负担

3. _start_bailian_grpc_server_frontend_worker 访问使用 getattr 检查

File: frontend_app.py

if getattr(self.frontend_server, "_frontend_worker", None) is not None:
    self._bailian_grpc_backend_visitor = (
        self.frontend_server._frontend_worker.backend_rpc_server_visitor
    )

访问私有属性 _frontend_worker 是脆弱的。如果 FrontendServer 的内部实现变更,这里会静默降级为 fake 模式而不报错。建议在 FrontendServer 上暴露一个公开方法来获取 backend visitor。

P2 Suggestions

4. bailian_start.sh 中的模型路径解析逻辑复杂

_bailian_resolve_checkpoint 函数通过 find 遍历目录树寻找最深的 config.json + weights 组合。这个启发式逻辑在模型目录结构不规范时可能选错路径。建议添加 MODEL_PATH 环境变量作为显式覆盖。

5. streamLogTag() 改动范围大但与 Bailian 功能无关

日志格式从 stream [%ld] 改为 stream [%s](包含 trace_id)的改动涉及 ~20 处,与 Bailian gRPC 功能正交。建议拆分为独立 PR,减少 review 负担和合并冲突风险。

P3 Nits

6. @app.on_event("shutdown") 已被 FastAPI 标记为 deprecated

建议使用 lifespan context manager 替代。

@LLLLKKKK LLLLKKKK closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants