[Tracing] Remove the deprecated tracing code from mini_lb (#19409)
This commit is contained in:
@@ -184,17 +184,6 @@ class RequestStage:
|
|||||||
metrics_is_observed=True,
|
metrics_is_observed=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# mini lb
|
|
||||||
MINI_LB_LAUNCH = RequestStageConfig(
|
|
||||||
"mini_lb_launch",
|
|
||||||
level=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
WAIT_PD_FINISH = RequestStageConfig(
|
|
||||||
"wait_pd_finish",
|
|
||||||
level=2,
|
|
||||||
)
|
|
||||||
|
|
||||||
# other
|
# other
|
||||||
ANONYMOUS = RequestStageConfig("")
|
ANONYMOUS = RequestStageConfig("")
|
||||||
|
|
||||||
|
|||||||
@@ -19,21 +19,6 @@ 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
|
||||||
|
|
||||||
try:
|
|
||||||
from sglang.srt.tracing.trace import (
|
|
||||||
process_tracing_init,
|
|
||||||
trace_get_remote_propagate_context,
|
|
||||||
trace_req_finish,
|
|
||||||
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__)
|
||||||
|
|
||||||
AIOHTTP_STREAM_READ_CHUNK_SIZE = (
|
AIOHTTP_STREAM_READ_CHUNK_SIZE = (
|
||||||
@@ -62,14 +47,6 @@ 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
|
|
||||||
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
|
|
||||||
|
|
||||||
self.test_external_dp_routing = router_args.test_external_dp_routing
|
self.test_external_dp_routing = router_args.test_external_dp_routing
|
||||||
self.prefill_dp_size = None
|
self.prefill_dp_size = None
|
||||||
self.decode_dp_size = None
|
self.decode_dp_size = None
|
||||||
@@ -95,9 +72,6 @@ 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)
|
||||||
|
|
||||||
async def _ensure_dp_sizes(self):
|
async def _ensure_dp_sizes(self):
|
||||||
@@ -157,33 +131,12 @@ class MiniLoadBalancer:
|
|||||||
total=self.timeout
|
total=self.timeout
|
||||||
) # Add timeout for request reliability
|
) # Add timeout for request reliability
|
||||||
) as session:
|
) as session:
|
||||||
headers = {}
|
|
||||||
bootstrap_room_list = []
|
|
||||||
if self.enable_trace:
|
|
||||||
bootstrap_room_list = (
|
|
||||||
modified_request["bootstrap_room"]
|
|
||||||
if isinstance(modified_request["bootstrap_room"], list)
|
|
||||||
else [modified_request["bootstrap_room"]]
|
|
||||||
)
|
|
||||||
trace_context = trace_get_remote_propagate_context(bootstrap_room_list)
|
|
||||||
headers = {"trace_context": trace_context}
|
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
session.post(
|
session.post(f"{prefill_server}/{endpoint}", json=prefill_req),
|
||||||
f"{prefill_server}/{endpoint}",
|
session.post(f"{decode_server}/{endpoint}", json=decode_req),
|
||||||
json=prefill_req,
|
|
||||||
headers=headers,
|
|
||||||
),
|
|
||||||
session.post(
|
|
||||||
f"{decode_server}/{endpoint}",
|
|
||||||
json=decode_req,
|
|
||||||
headers=headers,
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for bootstrap_room in bootstrap_room_list:
|
|
||||||
trace_slice_end("mini_lb_launch", bootstrap_room, auto_next_anon=True)
|
|
||||||
|
|
||||||
# Wait for both responses to complete. Prefill should end first.
|
# Wait for both responses to complete. Prefill should end first.
|
||||||
prefill_response, decode_response = await asyncio.gather(*tasks)
|
prefill_response, decode_response = await asyncio.gather(*tasks)
|
||||||
|
|
||||||
@@ -202,14 +155,6 @@ class MiniLoadBalancer:
|
|||||||
else:
|
else:
|
||||||
ret_json = await decode_response.json()
|
ret_json = await decode_response.json()
|
||||||
|
|
||||||
for bootstrap_room in bootstrap_room_list:
|
|
||||||
trace_slice_end(
|
|
||||||
"wait_PD_finish",
|
|
||||||
bootstrap_room,
|
|
||||||
thread_finish_flag=True,
|
|
||||||
)
|
|
||||||
trace_req_finish(bootstrap_room)
|
|
||||||
|
|
||||||
if expected_decode_dp_rank is not None:
|
if expected_decode_dp_rank is not None:
|
||||||
actual = ret_json.get("meta_info", {}).get("dp_rank")
|
actual = ret_json.get("meta_info", {}).get("dp_rank")
|
||||||
if actual != expected_decode_dp_rank:
|
if actual != expected_decode_dp_rank:
|
||||||
@@ -241,36 +186,11 @@ class MiniLoadBalancer:
|
|||||||
) # Add timeout for request reliability
|
) # Add timeout for request reliability
|
||||||
) as session:
|
) as session:
|
||||||
# Create the tasks for both prefill and decode requests
|
# Create the tasks for both prefill and decode requests
|
||||||
headers = {}
|
|
||||||
bootstrap_room_list = []
|
|
||||||
if self.enable_trace:
|
|
||||||
bootstrap_room_list = (
|
|
||||||
modified_request["bootstrap_room"]
|
|
||||||
if isinstance(modified_request["bootstrap_room"], list)
|
|
||||||
else [modified_request["bootstrap_room"]]
|
|
||||||
)
|
|
||||||
trace_context = trace_get_remote_propagate_context(
|
|
||||||
bootstrap_room_list
|
|
||||||
)
|
|
||||||
headers = {"trace_context": trace_context}
|
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
session.post(
|
session.post(f"{prefill_server}/{endpoint}", json=modified_request),
|
||||||
f"{prefill_server}/{endpoint}",
|
session.post(f"{decode_server}/{endpoint}", json=modified_request),
|
||||||
json=modified_request,
|
|
||||||
headers=headers,
|
|
||||||
),
|
|
||||||
session.post(
|
|
||||||
f"{decode_server}/{endpoint}",
|
|
||||||
json=modified_request,
|
|
||||||
headers=headers,
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for bootstrap_room in bootstrap_room_list:
|
|
||||||
trace_slice_end(
|
|
||||||
"mini_lb_launch", bootstrap_room, auto_next_anon=True
|
|
||||||
)
|
|
||||||
# Wait for both responses to complete. Since this is streaming, they return immediately.
|
# Wait for both responses to complete. Since this is streaming, they return immediately.
|
||||||
prefill_response, decode_response = await asyncio.gather(*tasks)
|
prefill_response, decode_response = await asyncio.gather(*tasks)
|
||||||
|
|
||||||
@@ -310,14 +230,6 @@ class MiniLoadBalancer:
|
|||||||
):
|
):
|
||||||
yield chunk
|
yield chunk
|
||||||
|
|
||||||
for bootstrap_room in bootstrap_room_list:
|
|
||||||
trace_slice_end(
|
|
||||||
"wait_PD_finish",
|
|
||||||
bootstrap_room,
|
|
||||||
thread_finish_flag=True,
|
|
||||||
)
|
|
||||||
trace_req_finish(bootstrap_room)
|
|
||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
stream_results(),
|
stream_results(),
|
||||||
media_type="text/event-stream",
|
media_type="text/event-stream",
|
||||||
@@ -520,11 +432,7 @@ async def handle_completion_request(request_data: dict):
|
|||||||
|
|
||||||
|
|
||||||
def _generate_bootstrap_room():
|
def _generate_bootstrap_room():
|
||||||
bootstrap_room = random.randint(0, 2**63 - 1)
|
return random.randint(0, 2**63 - 1)
|
||||||
if lb.enable_trace:
|
|
||||||
trace_req_start(bootstrap_room, bootstrap_room, role="router")
|
|
||||||
trace_slice_start("mini_lb_launch", bootstrap_room)
|
|
||||||
return bootstrap_room
|
|
||||||
|
|
||||||
|
|
||||||
# We may utilize `GenerateReqInput`'s logic later
|
# We may utilize `GenerateReqInput`'s logic later
|
||||||
|
|||||||
Reference in New Issue
Block a user