Fix SGLANG_GRPC_PORT overflow for high --port values#29517
Open
ajinkyajawale14499 wants to merge 3 commits into
Open
Fix SGLANG_GRPC_PORT overflow for high --port values#29517ajinkyajawale14499 wants to merge 3 commits into
ajinkyajawale14499 wants to merge 3 commits into
Conversation
When SGLANG_GRPC_PORT is unset, grpc_port was derived as port + 10000, which exceeds 65535 and raised ValueError for any --port > 55535. Fall back to port - 10000 in that case so a valid --port no longer crashes. Adds unit tests.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the gRPC port derivation logic to prevent port overflow when a high port is configured. If the derived port (port + 10000) exceeds 65535, it falls back to port - 10000. Unit tests have been added to verify this behavior. The reviewer suggested simplifying the condition self.port + 10000 <= 65535 to self.port <= 55535 for better readability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #29416. When
--portis greater than 55535, launching the server crashes withValueError: SGLANG_GRPC_PORT (...) must be between 1 and 65535, even though the user never setSGLANG_GRPC_PORT. The reported command used--port 65438.The cause is in
ServerArgs: whenSGLANG_GRPC_PORTis unset,grpc_portis derived asport + 10000, and the following range check then rejects anything above 65535.Modifications
python/sglang/srt/server_args.py: when derivinggrpc_portfrom--port, keepport + 10000, but fall back toport - 10000when that would exceed 65535.port + 10000 > 65535impliesport > 55535, soport - 10000 > 45535, which stays in range and still differs from--port. An explicitly setSGLANG_GRPC_PORTis left untouched and still validated by the existing range check.test/registered/unit/server_args/test_server_args.py: addTestGrpcPortDerivationcovering the high-port case (no longer raises, stays in range, differs from--port) and the normal case (port + 10000).Accuracy Tests
N/A. This is an argument-parsing change and does not affect model output.
Speed Tests and Profiling
N/A.
Checklist
base-a-test-cpu).The derivation was verified locally across several
--portvalues; theServerArgsconstruction test runs in CPU CI (developed on Apple Silicon, so I couldn't run the GPU suite locally).CI States
Latest PR Test (Base): ❌ Run #28294831452
Latest PR Test (Extra): ❌ Run #28294831374