Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goliaro committed Nov 11, 2024
1 parent ab5aa4b commit 7d99cf7
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions python/flexflow/serve/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,20 @@ def __need_cache_refresh(
Returns:
bool: True if the weights or tokenizer need a refresh, False otherwise
"""
need_refresh = False
resource_path = self.__get_resource_path(model_name, resource_type)
if self.refresh_cache or not os.path.exists(resource_path):
need_refresh = True
else:
ff_revision, latest_revision = self.__get_revision_hashes(
self.model_name, resource_path
)
if ff_revision != latest_revision:
need_refresh = True
if need_refresh:
ff_revision, latest_revision = self.__get_revision_hashes(self.model_name, resource_path)
if self.refresh_cache or not os.path.exists(resource_path) or ff_revision != latest_revision:
print(
f"Refreshing {resource_type} in cache for model {model_name} at path {resource_path} ..."
)
if os.path.exists(resource_path):
shutil.rmtree(resource_path)
os.makedirs(resource_path, exist_ok=True)
ff_revision_file = os.path.join(resource_path, "rev_sha.txt")
with open(ff_revision_file, "w+") as f:
f.write(latest_revision)
return need_refresh
os.makedirs(resource_path, exist_ok=True)
ff_revision_file = os.path.join(resource_path, "rev_sha.txt")
with open(ff_revision_file, "w+") as f:
f.write(latest_revision)
return True
return False

def download_hf_weights_if_needed(self) -> None:
"""Check in the folder specified by the cache_path whether the LLM's model weights are available and up to date.
Expand Down

0 comments on commit 7d99cf7

Please sign in to comment.