Report accelerator type in /v1/loads (#32348)

Co-authored-by: Yinghai Lu <yinghai@meta.com>
This commit is contained in:
cctry
2026-07-24 17:31:28 -07:00
committed by GitHub
co-authored by Yinghai Lu
parent 1ef2b85ef7
commit ce705bb6dc
2 changed files with 25 additions and 1 deletions
+10 -1
View File
@@ -20,16 +20,24 @@ metrics for load balancing, monitoring, and capacity planning.
import time
from datetime import datetime, timezone
from functools import lru_cache
from typing import Optional
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import Response
from sglang.srt.utils import get_device_name
from sglang.version import __version__
router = APIRouter()
@lru_cache(maxsize=1)
def _accelerator_name() -> Optional[str]:
"""Accelerator marketing name (e.g. "NVIDIA GB300"), None if unavailable."""
return get_device_name()
def _get_tokenizer_manager():
"""Dependency to get tokenizer_manager from global state."""
from sglang.srt.entrypoints.http_server import get_global_state
@@ -87,7 +95,7 @@ async def get_loads(
format: Response format - 'json' (default) or 'prometheus'
Returns:
JSON response with timestamp, version, and per-DP-rank loads
JSON response with timestamp, version, accelerator, and per-DP-rank loads
"""
include_list = [s.strip() for s in include.split(",")] if include else None
@@ -119,5 +127,6 @@ async def get_loads(
return {
"timestamp": datetime.now(timezone.utc).isoformat(),
"version": __version__,
"accelerator": _accelerator_name(),
"loads": loads,
}