diff --git a/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py b/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py index 25f22fa0b9..0511519a05 100644 --- a/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py +++ b/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py @@ -515,6 +515,22 @@ class MooncakeStore(HiCacheStorage, MooncakeBaseStore): else: client_hostname = self.config.local_hostname transfer_engine = None + # Each rank embeds its own Mooncake client process. Giving + # every rank the same local_hostname makes the master's + # preferred-segment allocation unable to tell their + # segments apart, so replicas can land on a peer rank's + # segment and the local-memcpy fast path (which requires + # same-process endpoints) silently falls back to TCP. + # Make the hostname unique per rank so own-writes land on + # the own segment and reads can use local memcpy. + if storage_config is not None: + client_hostname = ( + f"{client_hostname}" + f"-d{storage_config.dp_rank}" + f"t{storage_config.tp_rank}" + f"p{storage_config.pp_rank}" + f"c{storage_config.attn_cp_rank}" + ) setup_kwargs = {} if self.config.enable_ssd_offload: