Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
1e90fe2e
"examples/svm_c_ex.cpp" did not exist on "03ec260cb30ac707c0379995dd32ff244eb5ca65"
Unverified
Commit
1e90fe2e
authored
Oct 29, 2025
by
Feng Su
Committed by
GitHub
Oct 29, 2025
Browse files
[Bug fix] trace: fix import error in mini_lb if sgl-router image does not install sglang (#12338)
parent
caa5d296
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
sgl-router/py_src/sglang_router/launch_router.py
sgl-router/py_src/sglang_router/launch_router.py
+0
-9
sgl-router/py_src/sglang_router/mini_lb.py
sgl-router/py_src/sglang_router/mini_lb.py
+26
-9
No files found.
sgl-router/py_src/sglang_router/launch_router.py
View file @
1e90fe2e
...
@@ -38,15 +38,6 @@ def launch_router(args: argparse.Namespace) -> Optional[Router]:
...
@@ -38,15 +38,6 @@ def launch_router(args: argparse.Namespace) -> Optional[Router]:
router_args
=
args
router_args
=
args
if
router_args
.
mini_lb
:
if
router_args
.
mini_lb
:
if
router_args
.
enable_trace
:
from
sglang.srt.tracing.trace
import
(
process_tracing_init
,
trace_set_thread_info
,
)
process_tracing_init
(
router_args
.
otlp_traces_endpoint
,
"sglang"
)
trace_set_thread_info
(
"Mini lb"
)
mini_lb
=
MiniLoadBalancer
(
router_args
)
mini_lb
=
MiniLoadBalancer
(
router_args
)
mini_lb
.
start
()
mini_lb
.
start
()
else
:
else
:
...
...
sgl-router/py_src/sglang_router/mini_lb.py
View file @
1e90fe2e
...
@@ -18,13 +18,20 @@ from fastapi import FastAPI, HTTPException
...
@@ -18,13 +18,20 @@ from fastapi import FastAPI, HTTPException
from
fastapi.responses
import
ORJSONResponse
,
Response
,
StreamingResponse
from
fastapi.responses
import
ORJSONResponse
,
Response
,
StreamingResponse
from
sglang_router.router_args
import
RouterArgs
from
sglang_router.router_args
import
RouterArgs
from
sglang.srt.tracing.trace
import
(
try
:
trace_get_remote_propagate_context
,
from
sglang.srt.tracing.trace
import
(
trace_req_finish
,
process_tracing_init
,
trace_req_start
,
trace_get_remote_propagate_context
,
trace_slice_end
,
trace_req_finish
,
trace_slice_start
,
trace_req_start
,
)
trace_set_thread_info
,
trace_slice_end
,
trace_slice_start
,
)
trace_package_imported
=
True
except
ImportError
:
trace_package_imported
=
False
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -54,7 +61,13 @@ class MiniLoadBalancer:
...
@@ -54,7 +61,13 @@ class MiniLoadBalancer:
self
.
prefill_urls
=
[
url
[
0
]
for
url
in
router_args
.
prefill_urls
]
self
.
prefill_urls
=
[
url
[
0
]
for
url
in
router_args
.
prefill_urls
]
self
.
prefill_bootstrap_ports
=
[
url
[
1
]
for
url
in
router_args
.
prefill_urls
]
self
.
prefill_bootstrap_ports
=
[
url
[
1
]
for
url
in
router_args
.
prefill_urls
]
self
.
decode_urls
=
router_args
.
decode_urls
self
.
decode_urls
=
router_args
.
decode_urls
self
.
otlp_traces_endpoint
=
router_args
.
otlp_traces_endpoint
self
.
enable_trace
=
router_args
.
enable_trace
self
.
enable_trace
=
router_args
.
enable_trace
if
self
.
enable_trace
and
not
trace_package_imported
:
logger
.
warning
(
"Tracing is not supported in this environment. Please install sglang."
)
self
.
enable_trace
=
False
def
_validate_router_args
(
self
,
router_args
:
RouterArgs
):
def
_validate_router_args
(
self
,
router_args
:
RouterArgs
):
logger
.
warning
(
logger
.
warning
(
...
@@ -77,6 +90,9 @@ class MiniLoadBalancer:
...
@@ -77,6 +90,9 @@ class MiniLoadBalancer:
def
start
(
self
):
def
start
(
self
):
global
lb
global
lb
lb
=
self
lb
=
self
if
self
.
enable_trace
:
process_tracing_init
(
self
.
otlp_traces_endpoint
,
"sglang"
)
trace_set_thread_info
(
"Mini lb"
)
uvicorn
.
run
(
app
,
host
=
self
.
host
,
port
=
self
.
port
)
uvicorn
.
run
(
app
,
host
=
self
.
host
,
port
=
self
.
port
)
def
select_pair
(
self
):
def
select_pair
(
self
):
...
@@ -441,8 +457,9 @@ async def handle_completion_request(request_data: dict):
...
@@ -441,8 +457,9 @@ async def handle_completion_request(request_data: dict):
def
_generate_bootstrap_room
():
def
_generate_bootstrap_room
():
bootstrap_room
=
random
.
randint
(
0
,
2
**
63
-
1
)
bootstrap_room
=
random
.
randint
(
0
,
2
**
63
-
1
)
trace_req_start
(
bootstrap_room
,
bootstrap_room
,
role
=
"router"
)
if
lb
.
enable_trace
:
trace_slice_start
(
"mini_lb_launch"
,
bootstrap_room
)
trace_req_start
(
bootstrap_room
,
bootstrap_room
,
role
=
"router"
)
trace_slice_start
(
"mini_lb_launch"
,
bootstrap_room
)
return
bootstrap_room
return
bootstrap_room
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment