-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: sglang V4 (DeepSeek-V4) compatibility for decode handler #8678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,13 +66,30 @@ def __init__( | |
| generate_endpoint, | ||
| shutdown_event, | ||
| ) | ||
| # H20 patch: set use_sglang_tokenizer from config | ||
| self.use_sglang_tokenizer = False # disagg mode | ||
| if self.serving_mode == DisaggregationMode.DECODE: | ||
| logging.info( | ||
| "Decode worker handler initialized (disaggregated decode mode)" | ||
| ) | ||
| else: | ||
| logging.info("Decode worker handler initialized (aggregated mode)") | ||
|
|
||
| @staticmethod | ||
| def _get_guided_decoding_params(guided_decoding=None): | ||
| """Stub for guided decoding - not needed for E2E test.""" | ||
| return {} | ||
|
|
||
| @staticmethod | ||
| def _resolve_lora(request): | ||
| """Stub for LoRA resolution.""" | ||
| return {} | ||
|
|
||
| @staticmethod | ||
| def _session_kwargs(request): | ||
| """Stub for session kwargs.""" | ||
| return {} | ||
|
Comment on lines
+78
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n components/src/dynamo/sglang/request_handlers/llm/decode_handler.py | head -120Repository: ai-dynamo/dynamo Length of output: 4903 🏁 Script executed: # Check if there's a parent class definition in the file
rg "class.*\(" components/src/dynamo/sglang/request_handlers/llm/decode_handler.py -A 3Repository: ai-dynamo/dynamo Length of output: 214 🏁 Script executed: # Look for imports to understand inheritance
rg "^from|^import" components/src/dynamo/sglang/request_handlers/llm/decode_handler.py | head -20Repository: ai-dynamo/dynamo Length of output: 589 🏁 Script executed: # Find and examine the parent class BaseWorkerHandler
find . -name "handler_base.py" -path "*/sglang/*" | head -5Repository: ai-dynamo/dynamo Length of output: 124 🏁 Script executed: # Search for the parent class and its method implementations
rg "def _get_guided_decoding_params|def _resolve_lora|def _session_kwargs" --type py -B 2 -A 5Repository: ai-dynamo/dynamo Length of output: 4948 🏁 Script executed: # Search for calls to these stub methods to understand expected contract
rg "_get_guided_decoding_params|_resolve_lora|_session_kwargs" --type py -B 2 -A 2Repository: ai-dynamo/dynamo Length of output: 8601 🏁 Script executed: # Get more context from the base class implementation
sed -n '1,250p' components/src/dynamo/sglang/request_handlers/handler_base.py | grep -A 20 "_resolve_lora"Repository: ai-dynamo/dynamo Length of output: 42 🏁 Script executed: # Check the full implementations in base class
sed -n '1,400p' components/src/dynamo/sglang/request_handlers/handler_base.py | grep -A 15 "def _session_kwargs"Repository: ai-dynamo/dynamo Length of output: 42 🏁 Script executed: # Check the full implementation of _get_guided_decoding_params in base
sed -n '1,400p' components/src/dynamo/sglang/request_handlers/handler_base.py | grep -A 15 "def _get_guided_decoding_params"Repository: ai-dynamo/dynamo Length of output: 42 🏁 Script executed: # Get the size and read the handler_base.py file
wc -l components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 127 🏁 Script executed: # Read the handler_base.py file to find the method implementations
cat components/src/dynamo/sglang/request_handlers/handler_base.py | head -500Repository: ai-dynamo/dynamo Length of output: 18776 🏁 Script executed: # Search for the implementations of these methods in handler_base.py
grep -n "def _resolve_lora\|def _session_kwargs\|def _get_guided_decoding_params" components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 256 🏁 Script executed: # Get the implementation of _resolve_lora method starting from the line
sed -n '780,810p' components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 1122 🏁 Script executed: # Get the implementation of _session_kwargs method
sed -n '810,850p' components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 1647 🏁 Script executed: # Get the implementation of _get_guided_decoding_params method
sed -n '850,900p' components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 2241 🏁 Script executed: # Get the actual implementations starting from the correct line numbers
sed -n '302,320p' components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 759 🏁 Script executed: # Get _session_kwargs implementation
sed -n '1044,1070p' components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 1334 🏁 Script executed: # Get _get_guided_decoding_params implementation
sed -n '1057,1080p' components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 1036 🏁 Script executed: # Verify the calls to these methods in DecodeWorkerHandler and check if they're used correctly
sed -n '78,300p' components/src/dynamo/sglang/request_handlers/llm/decode_handler.py | grep -A 5 "_resolve_lora\|_session_kwargs\|_get_guided_decoding_params"Repository: ai-dynamo/dynamo Length of output: 1061 🏁 Script executed: # Check return type annotations and what lora_path is used for
grep -n "lora_path" components/src/dynamo/sglang/request_handlers/llm/decode_handler.py | head -20Repository: ai-dynamo/dynamo Length of output: 312 🏁 Script executed: # Check if DecodeWorkerHandler uses LoraMixin
grep -n "class DecodeWorkerHandler\|LoraMixin\|_init_lora_tracking" components/src/dynamo/sglang/request_handlers/llm/decode_handler.pyRepository: ai-dynamo/dynamo Length of output: 109 🏁 Script executed: # Check BaseWorkerHandler class definition and its mixins
sed -n '1100,1150p' components/src/dynamo/sglang/request_handlers/handler_base.py | grep -A 20 "class BaseWorkerHandler"Repository: ai-dynamo/dynamo Length of output: 42 🏁 Script executed: # Search for BaseWorkerHandler class definition in the full file
grep -n "^class BaseWorkerHandler" components/src/dynamo/sglang/request_handlers/handler_base.pyRepository: ai-dynamo/dynamo Length of output: 153 Remove these method stubs—they return incorrect types and break LoRA resolution. The stubs override working parent methods from LoraMixin and BaseGenerativeHandler. Specifically:
Delete these three methods to inherit the parent implementations. 🤖 Prompt for AI Agents |
||
|
|
||
| def cleanup(self) -> None: | ||
| """Shutdown the engine and cleanup resources.""" | ||
| super().cleanup() | ||
|
|
@@ -308,7 +325,7 @@ async def generate( | |
| **input_param, | ||
| sampling_params=sampling_params, | ||
| stream=True, | ||
| return_routed_experts=return_routed_experts, | ||
| # return_routed_experts=return_routed_experts, | ||
| bootstrap_host=bootstrap_info["bootstrap_host"], | ||
| bootstrap_port=bootstrap_info["bootstrap_port"], | ||
| bootstrap_room=bootstrap_info["bootstrap_room"], | ||
|
|
@@ -346,7 +363,7 @@ async def generate( | |
| video_data=video_data, | ||
| sampling_params=sampling_params, | ||
| stream=True, | ||
| return_routed_experts=return_routed_experts, | ||
| # return_routed_experts=return_routed_experts, | ||
| external_trace_header=trace_header, | ||
| rid=trace_id, | ||
| data_parallel_rank=dp_rank, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't hard-code
use_sglang_tokenizeraftersuper().__init__().BaseWorkerHandler.__init__()already used the config value to build request-parsing state, so forcing this field toFalsehere makes the handler internally inconsistent and bypasses the new flag for aggregated serving. If decode mode truly needs a fixed tokenizer setting, apply it beforesuper().__init__()or rebuild the dependent state afterward.🛠️ Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents