From 3cc8bf15da7c182f05fdadb3d2cb071812d7ac67 Mon Sep 17 00:00:00 2001 From: luomin2005 Date: Sat, 28 Feb 2026 14:17:12 +0800 Subject: [PATCH] Support platform.get_device_uuid function (#6777) ### What this PR does / why we need it? Support platform.get_device_uuid function. currently, the pytorch.npu.get_device_properties return uuid as full zero, vllm-ascend implement the interface at first, once the pytorch.npu.get_device_properties return the real uuid, vllm-ascend will support without modification. more details see https://github.com/vllm-project/vllm-ascend/issues/6669 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - vLLM version: v0.15.0 - vLLM main: https://github.com/vllm-project/vllm/commit/9562912cead1f11e8540fb91306c5cbda66f0007 root@localhost:/workspace/l00614971/vllm_test# python vllm_test.py INFO 02-24 09:43:48 [__init__.py:43] Available plugins for group vllm.platform_plugins: INFO 02-24 09:43:48 [__init__.py:45] - ascend -> vllm_ascend:register INFO 02-24 09:43:48 [__init__.py:48] All plugins in this group will be loaded. Set `VLLM_PLUGINS` to control which plugins to load. INFO 02-24 09:43:48 [__init__.py:217] Platform plugin ascend is activated device_uuid = 00000000-0000-0000-0000-000000000000 --------- Signed-off-by: liziyu Signed-off-by: wangxiaoteng Signed-off-by: luomin2005 Co-authored-by: liziyu <56102866+liziyu179@users.noreply.github.com> Co-authored-by: wangxiaoteng --- tests/ut/test_platform.py | 9 +++++++++ vllm_ascend/platform.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/tests/ut/test_platform.py b/tests/ut/test_platform.py index 06cc14c4..0f91ca4d 100644 --- a/tests/ut/test_platform.py +++ b/tests/ut/test_platform.py @@ -110,6 +110,15 @@ class TestNPUPlatform(TestBase): self.assertEqual(self.platform.get_device_name(device_id), device_name) mock_get_device_name.assert_called_once_with(0) + @patch("torch.npu.get_device_properties") + def test_get_device_uuid(self, mock_get_device_properties): + device_id = 0 + device_properties = MagicMock() + device_properties.uuid = "01020304-0000-0000-0000-01020304" + mock_get_device_properties.return_value = device_properties + self.assertEqual(self.platform.get_device_uuid(device_id), device_properties.uuid) + mock_get_device_properties.assert_called_once_with(0) + @patch("torch.inference_mode") def test_inference_mode(self, mock_inference_mode): mock_inference_mode.return_value = None diff --git a/vllm_ascend/platform.py b/vllm_ascend/platform.py index c0af4d00..d3c926b6 100644 --- a/vllm_ascend/platform.py +++ b/vllm_ascend/platform.py @@ -162,6 +162,13 @@ class NPUPlatform(Platform): def get_device_name(cls, device_id: int = 0) -> str: return torch.npu.get_device_name(device_id) + @classmethod + def get_device_uuid(cls, device_id: int = 0) -> str: + device_props = torch.npu.get_device_properties(device_id) + if not hasattr(device_props, "uuid") or device_props.uuid is None: + raise RuntimeError(f"Device {device_id} does not have a valid UUID.") + return device_props.uuid + @classmethod def inference_mode(cls): return torch.inference_mode()