[1/n][CI] Load models in CI from S3 instead of HF (#13205)
Signed-off-by: <> Co-authored-by: EC2 Default User <ec2-user@ip-172-31-20-117.us-west-2.compute.internal>
This commit is contained in:
co-authored by
EC2 Default User
parent
fd84857f64
commit
d5d214ac7f
+2
-1
@@ -409,7 +409,8 @@ class ModelConfig:
|
||||
if is_s3(model) or is_s3(tokenizer):
|
||||
if is_s3(model):
|
||||
s3_model = S3Model()
|
||||
s3_model.pull_files(model, allow_pattern=["*config.json"])
|
||||
s3_model.pull_files(
|
||||
model, allow_pattern=["*.model", "*.py", "*.json"])
|
||||
self.model_weights = self.model
|
||||
self.model = s3_model.dir
|
||||
|
||||
|
||||
@@ -1327,6 +1327,7 @@ class RunaiModelStreamerLoader(BaseModelLoader):
|
||||
"""Prepare weights for the model.
|
||||
|
||||
If the model is not local, it will be downloaded."""
|
||||
|
||||
is_s3_path = is_s3(model_name_or_path)
|
||||
is_local = os.path.isdir(model_name_or_path)
|
||||
safetensors_pattern = "*.safetensors"
|
||||
@@ -1340,7 +1341,6 @@ class RunaiModelStreamerLoader(BaseModelLoader):
|
||||
revision,
|
||||
ignore_patterns=self.load_config.ignore_patterns,
|
||||
))
|
||||
|
||||
if is_s3_path:
|
||||
hf_weights_files = s3_glob(path=hf_folder,
|
||||
allow_pattern=[safetensors_pattern])
|
||||
|
||||
@@ -27,6 +27,8 @@ from vllm.model_executor.layers.quantization import (QuantizationConfig,
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.utils import PlaceholderModule
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
try:
|
||||
from runai_model_streamer import SafetensorsStreamer
|
||||
except (ImportError, OSError):
|
||||
@@ -37,8 +39,6 @@ except (ImportError, OSError):
|
||||
SafetensorsStreamer = runai_model_streamer.placeholder_attr(
|
||||
"SafetensorsStreamer")
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
# use system-level temp directory for file locks, so that multiple users
|
||||
# can share the same lock without error.
|
||||
# lock files in the temp directory will be automatically deleted when the
|
||||
|
||||
@@ -144,7 +144,6 @@ def file_exists(
|
||||
revision: Optional[str] = None,
|
||||
token: Union[str, bool, None] = None,
|
||||
) -> bool:
|
||||
|
||||
file_list = list_repo_files(repo_id,
|
||||
repo_type=repo_type,
|
||||
revision=revision,
|
||||
@@ -498,7 +497,7 @@ def get_sentence_transformer_tokenizer_config(model: str,
|
||||
if encoder_dict:
|
||||
break
|
||||
|
||||
if not encoder_dict:
|
||||
if not encoder_dict and not model.startswith("/"):
|
||||
try:
|
||||
# If model is on HuggingfaceHub, get the repo files
|
||||
repo_files = list_repo_files(model,
|
||||
|
||||
@@ -46,6 +46,8 @@ def glob(s3=None,
|
||||
"""
|
||||
if s3 is None:
|
||||
s3 = boto3.client("s3")
|
||||
if not path.endswith("/"):
|
||||
path = path + "/"
|
||||
bucket_name, _, paths = list_files(s3,
|
||||
path=path,
|
||||
allow_pattern=allow_pattern)
|
||||
@@ -109,6 +111,7 @@ class S3Model:
|
||||
for sig in (signal.SIGINT, signal.SIGTERM):
|
||||
existing_handler = signal.getsignal(sig)
|
||||
signal.signal(sig, self._close_by_signal(existing_handler))
|
||||
|
||||
self.dir = tempfile.mkdtemp()
|
||||
|
||||
def __del__(self):
|
||||
@@ -140,6 +143,9 @@ class S3Model:
|
||||
ignore_pattern: A list of patterns of which files not to pull.
|
||||
|
||||
"""
|
||||
if not s3_model_path.endswith("/"):
|
||||
s3_model_path = s3_model_path + "/"
|
||||
|
||||
bucket_name, base_dir, files = list_files(self.s3, s3_model_path,
|
||||
allow_pattern,
|
||||
ignore_pattern)
|
||||
@@ -147,8 +153,9 @@ class S3Model:
|
||||
return
|
||||
|
||||
for file in files:
|
||||
destination_file = os.path.join(self.dir,
|
||||
file.removeprefix(base_dir))
|
||||
destination_file = os.path.join(
|
||||
self.dir,
|
||||
file.removeprefix(base_dir).lstrip("/"))
|
||||
local_dir = Path(destination_file).parent
|
||||
os.makedirs(local_dir, exist_ok=True)
|
||||
self.s3.download_file(bucket_name, file, destination_file)
|
||||
|
||||
Reference in New Issue
Block a user