bugfix: fix initialization error for mooncake in k8s (#2541)

### What this PR does / why we need it?
The detail has been clarified in that issue :
https://github.com/vllm-project/vllm-ascend/issues/2557

### Does this PR introduce _any_ user-facing change?
NO

### How was this patch tested?
easy to test beacause we just need to echo the variable


- vLLM version: v0.10.1.1
- vLLM main:
6997a25ac6

---------

Signed-off-by: zzy-ContiLearn <1831242919@qq.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: LCAIZJ <leichao139636@163.com>
This commit is contained in:
zhiyuanzhang
2025-09-03 22:25:08 +08:00
committed by GitHub
parent 41b028aa5f
commit 07d44ade19
4 changed files with 25 additions and 3 deletions

View File

@@ -1094,6 +1094,7 @@ class MockTransferEngine:
class MockEnvsAscend:
MOONCAKE_CONNECTOR_PROTOCOL = "mock_protocol"
PHYSICAL_DEVICES = "10,11"
def mock_get_tensor_model_parallel_rank():
@@ -1122,7 +1123,7 @@ class TestMooncakeConnectorWorker(unittest.TestCase):
self.mock_transfer_engine.register_memory.return_value = 0
self.patches = [
patch('os.getenv', return_value="0,1"),
patch('os.getenv', return_value="10,11"),
patch('torch.Tensor.size', return_value=(10, 16, 8, 16)),
patch('torch.Tensor.element_size', return_value=4),
patch('torch.Tensor.data_ptr', return_value=0x1000),
@@ -1191,6 +1192,12 @@ class TestMooncakeConnectorWorker(unittest.TestCase):
self.assertTrue(worker.use_mla)
self.assertEqual(len(worker.block_len), 2)
def test_device_id_selection_with_physical_devices(self):
# Test with physical devices set
worker = MooncakeConnectorWorker(self.vllm_config, self.engine_id)
# Default tp_rank is 0, so device_id should be 10
self.assertEqual(worker.device_id, 10)
if __name__ == '__main__':
unittest.main()