[Mooncake] Fix silent SSD offload corruption when TP/PP ranks share ssd_offload_path (#31926)

Signed-off-by: Michele Palazzi <sysdadmin@m1k.cloud>
Co-authored-by: Teng Ma <sima.mt@alibaba-inc.com>
This commit is contained in:
Michele Palazzi
2026-09-17 10:51:03 +08:00
committed by GitHub
co-authored by Teng Ma
parent 84d7604b7e
commit 329ffc89b9
4 changed files with 221 additions and 1 deletions
@@ -745,6 +745,7 @@ class HiCacheController:
model_name=model_name,
tp_lcm_size=tp_lcm_size,
should_split_heads=should_split_heads,
dp_rank=self.dp_rank,
extra_config=storage_backend_extra_config,
)
@@ -37,6 +37,8 @@ class HiCacheStorageConfig:
model_name: Optional[str]
tp_lcm_size: Optional[int] = None
should_split_heads: bool = False
# with dp-attention, tp_rank is attention-group-local; dp_rank disambiguates
dp_rank: int = 0
extra_config: Optional[dict] = None
@@ -504,7 +504,22 @@ class MooncakeStore(HiCacheStorage, MooncakeBaseStore):
if self.config.enable_ssd_offload:
setup_kwargs["enable_ssd_offload"] = True
if self.config.ssd_offload_path is not None:
setup_kwargs["ssd_offload_path"] = self.config.ssd_offload_path
# Each rank embeds its own Mooncake client. Sharing one
# offload directory corrupts silently: bucket ids are
# generated per process and resumed from the same startup
# scan after a restart, and bucket files are opened with
# O_CREAT|O_TRUNC, so a filename collision truncates
# another rank's bucket. Give every rank a private subdir.
ssd_offload_path = self.config.ssd_offload_path
if storage_config is not None:
ssd_offload_path = os.path.join(
ssd_offload_path,
f"rank_{storage_config.dp_rank}"
f"_{storage_config.tp_rank}_{storage_config.pp_rank}"
f"_{storage_config.attn_cp_rank}",
)
os.makedirs(ssd_offload_path, exist_ok=True)
setup_kwargs["ssd_offload_path"] = ssd_offload_path
if self.config.tenant_id != DEFAULT_TENANT_ID:
setup_kwargs["tenant_id"] = self.config.tenant_id