Skip to content

Commit a62ee0b

Browse files
feat: add GET /profile_status endpoint (#918)
Returns {"status": "in_progress"} while profiling is active, {"status": "idle"} otherwise. Enables CI workflows to poll for profiling completion without side effects. Co-authored-by: prayer <prayer@primatrix.ai>
1 parent 5475a97 commit a62ee0b

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

python/sgl_jax/srt/entrypoints/http_server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ async def stop_profile_async():
403403
)
404404

405405

406+
@app.api_route("/profile_status", methods=["GET"])
407+
async def profile_status_async():
408+
"""Get profiling status. Returns {"status": "in_progress"} or {"status": "idle"}."""
409+
result = await _global_state.tokenizer_manager.get_profile_status()
410+
return ORJSONResponse(content={"status": result.message})
411+
412+
406413
@app.api_route("/start_trace", methods=["GET", "POST"])
407414
async def start_trace_async(obj: StartTraceReqInput | None = None):
408415
"""Start precision tracing."""

python/sgl_jax/srt/managers/io_struct.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ class ProfileReqInput:
661661
class ProfileReqType(Enum):
662662
START_PROFILE = 1
663663
STOP_PROFILE = 2
664+
GET_STATUS = 3
664665

665666

666667
@dataclass

python/sgl_jax/srt/managers/scheduler_profiler_mixing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,5 +333,14 @@ def profile(self, recv_req: ProfileReq):
333333
recv_req.python_tracer_level,
334334
recv_req.profile_id,
335335
)
336+
elif recv_req.type == ProfileReqType.GET_STATUS:
337+
return self.get_profile_status()
336338
else:
337339
return self.stop_profile()
340+
341+
def get_profile_status(self) -> ProfileReqOutput:
342+
in_progress = self.profile_in_progress or self._profile_manager.is_configured
343+
return ProfileReqOutput(
344+
success=True,
345+
message="in_progress" if in_progress else "idle",
346+
)

python/sgl_jax/srt/managers/tokenizer_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ async def stop_profile(self):
660660
req = ProfileReq(type=ProfileReqType.STOP_PROFILE)
661661
return await self._execute_profile(req)
662662

663+
async def get_profile_status(self):
664+
self.auto_create_handle_loop()
665+
req = ProfileReq(type=ProfileReqType.GET_STATUS)
666+
return await self._execute_profile(req)
667+
663668
async def _execute_profile(self, req: ProfileReq):
664669
result = (await self.profile_communicator(req))[0]
665670
if not result.success:

0 commit comments

Comments
 (0)