[Core] Support offline use of local cache for models (#4374)

Signed-off-by: Prashant Gupta <prashantgupta@us.ibm.com>
Co-authored-by: Travis Johnson <tjohnson31415@gmail.com>
This commit is contained in:
Prashant Gupta
2024-04-27 09:59:55 -07:00
committed by GitHub
co-authored by Travis Johnson
parent 81661da7b2
commit d6e520e170
4 changed files with 68 additions and 26 deletions
+4 -1
View File
@@ -5,6 +5,7 @@ import os
from abc import ABC, abstractmethod
from typing import Any, Dict, Generator, List, Optional, Tuple, Type
import huggingface_hub
import torch
from torch import nn
@@ -131,7 +132,9 @@ class DefaultModelLoader(BaseModelLoader):
model_path = snapshot_download(
model_id=model,
cache_dir=self.load_config.download_dir,
revision=revision)
local_files_only=huggingface_hub.constants.HF_HUB_OFFLINE,
revision=revision,
)
else:
model_path = model
return model_path