Add the ability to enable and disable the Profiler via HTTP API. (#1626)

This commit is contained in:
科英
2024-10-11 17:34:25 +08:00
committed by GitHub
parent b503881bd2
commit bbd72bfc86
4 changed files with 73 additions and 0 deletions

View File

@@ -145,6 +145,28 @@ async def flush_cache():
)
@app.get("/start_profile")
@app.post("/start_profile")
async def start_profile():
"""Start profiling."""
tokenizer_manager.start_profile()
return Response(
content="Start profiling.\n",
status_code=200,
)
@app.get("/stop_profile")
@app.post("/stop_profile")
async def stop_profile():
"""Stop profiling."""
tokenizer_manager.stop_profile()
return Response(
content="Stop profiling. This will take some time.\n",
status_code=200,
)
@app.post("/update_weights")
async def update_weights(obj: UpdateWeightReqInput, request: Request):
"""Update the weights inplace without re-launching the server."""