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
@@ -5,9 +5,11 @@ import os
import tempfile
import unittest
from types import SimpleNamespace
from unittest import mock
import msgspec.msgpack
from sglang.srt.entrypoints import v1_loads
from sglang.srt.entrypoints.v1_loads import get_loads
from sglang.srt.managers.load_snapshot import (
HEADER_STRUCT,
@@ -91,6 +93,19 @@ class TestLoadsResponse(CustomTestCase):
self.assertEqual(response["loads"][0]["num_waiting_reqs"], 2)
class TestLoadsAcceleratorField(CustomTestCase):
def test_accelerator_reported_in_json(self):
"""Guards the response contract: the JSON envelope carries an
"accelerator" field with the detected device name."""
manager = _FakeHttpTokenizerManager([LoadSnapshot(dp_rank=0)])
with mock.patch.object(
v1_loads, "_accelerator_name", return_value="NVIDIA GB300"
):
response = asyncio.run(get_loads(tokenizer_manager=manager))
self.assertEqual(response["accelerator"], "NVIDIA GB300")
class TestGetLoads(CustomTestCase):
def test_load_snapshot_wire_format_is_msgpack_slots(self):
path = _temp_path()