[router][grpc] Fix proto3 default value mismatches and cleanup unused fields#11283
[router][grpc] Fix proto3 default value mismatches and cleanup unused fields#11283
Conversation
- Remove unused fields: `lora_path`, `token_healing` - Make Rust always set explicit defaults (temperature=1.0, top_p=1.0, etc.) - Fix Python conversion to trust proto values directly (no defensive checks) - Fix temperature=0.0 bug from `or` operator override - Convert empty repeated fields to None for `stop`/`stop_token_ids` - Add missing conversions: `logit_bias`, `custom_params`, `stream_interval`, `no_stop_trim` - Make `stream_interval` optional, renumber proto fields 1-23
Summary of ChangesHello @CatherineSue, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical issue concerning the handling of default values for sampling parameters in the gRPC interface between the Rust client and Python server. Previously, the implicit numeric defaults of Proto3 (e.g., 0) clashed with the explicit semantic defaults expected by the Python Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a critical issue with default value mismatches between Protobuf and Python for sampling parameters. The approach of making Rust the single source of truth for defaults and removing defensive checks in Python is sound. The changes in the .proto files and the Rust client are well-executed and include helpful comments and tests.
I've found one issue in the Python gRPC server where optional fields are not handled correctly, which could lead to incorrect default values being used. My review includes a suggestion to fix this, ensuring the defaults from SGLSamplingParams are correctly applied when parameters are not explicitly set.
Motivation
Problem Identified
Proto3 numeric defaults (0) don't match Python
SamplingParamssemantic defaults (temperature=1.0, top_p=1.0, top_k=-1, repetition_penalty=1.0, etc.), which could cause incorrect behavior if proto fields are used directly.Design Philosophy Chosen
Single source of truth: Rust constructs proto messages with proper defaults → Python trusts and uses values directly (no defensive checks)
Modifications
1. Proto Field Design (sglang_scheduler.proto)
max_new_tokensandstream_interval(semantically optional)lora_path,token_healing2. Rust Client (sgl-router/src/grpc_client/sglang_scheduler.rs)
temperature: 1.0,top_p: 1.0,top_k: -1,repetition_penalty: 1.0skip_special_tokens: true,spaces_between_special_tokens: truen: 1min_new_tokens: 0,ignore_eos: false,no_stop_trim: false3. Python Server (grpc_server.py)
temperature=grpc_params.temperature or 1.0(breaks when temperature=0.0 for greedy sampling)temperature=grpc_params.temperatureAccuracy Tests
Benchmarking and Profiling
Checklist