bugfix(hicache): Move exists check before key suffixing (#9749)

This commit is contained in:
hzh0425
2025-08-29 09:29:47 +08:00
committed by GitHub
parent 001f51940a
commit 38cd5fb1e0

View File

@@ -175,11 +175,12 @@ class HiCacheFile(HiCacheStorage):
target_location: Optional[Any] = None,
target_sizes: Optional[Any] = None,
) -> bool:
key = self._get_suffixed_key(key)
tensor_path = os.path.join(self.file_path, f"{key}.bin")
if self.exists(key):
logger.debug(f"Key {key} already exists. Skipped.")
return True
key = self._get_suffixed_key(key)
tensor_path = os.path.join(self.file_path, f"{key}.bin")
try:
value.contiguous().view(dtype=torch.uint8).numpy().tofile(tensor_path)
return True