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 <liziyu16@huawei.com> Signed-off-by: wangxiaoteng <wangxiaoteng@huawei.com> Signed-off-by: luomin2005 <luomin2005@huawei.com> Co-authored-by: liziyu <56102866+liziyu179@users.noreply.github.com> Co-authored-by: wangxiaoteng <wangxiaoteng@huawei.com>
This commit is contained in:
2 files changed
+16
No files matched your search
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user