Skip to content

Commit 961aa05

Browse files
[ODSC-59694] Register model changes for 1.0.3 (#903)
2 parents 9b37700 + 5f3067c commit 961aa05

File tree

4 files changed

+49
-33
lines changed

4 files changed

+49
-33
lines changed

ads/aqua/common/enums.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
# Copyright (c) 2024 Oracle and/or its affiliates.
43
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
54

@@ -8,6 +7,7 @@
87
~~~~~~~~~~~~~~
98
This module contains the set of enums used in AQUA.
109
"""
10+
1111
from ads.common.extended_enum import ExtendedEnumMeta
1212

1313

@@ -28,6 +28,7 @@ class Tags(str, metaclass=ExtendedEnumMeta):
2828
TASK = "task"
2929
LICENSE = "license"
3030
ORGANIZATION = "organization"
31+
PLATFORM = "platform"
3132
AQUA_TAG = "OCI_AQUA"
3233
AQUA_SERVICE_MODEL_TAG = "aqua_service_model"
3334
AQUA_FINE_TUNED_MODEL_TAG = "aqua_fine_tuned_model"
@@ -48,6 +49,7 @@ class InferenceContainerType(str, metaclass=ExtendedEnumMeta):
4849
class InferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
4950
AQUA_VLLM_CONTAINER_FAMILY = "odsc-vllm-serving"
5051
AQUA_TGI_CONTAINER_FAMILY = "odsc-tgi-serving"
52+
AQUA_LLAMA_CPP_CONTAINER_FAMILY = "odsc-llama-cpp-serving"
5153

5254

5355
class InferenceContainerParamType(str, metaclass=ExtendedEnumMeta):

ads/aqua/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
DEFAULT_FT_REPLICA = 1
2222
DEFAULT_FT_BATCH_SIZE = 1
2323
DEFAULT_FT_VALIDATION_SET_SIZE = 0.1
24-
24+
ARM_CPU="arm_cpu"
25+
NVIDIA_GPU="nvidia_gpu"
2526
MAXIMUM_ALLOWED_DATASET_IN_BYTE = 52428800 # 1024 x 1024 x 50 = 50MB
2627
JOB_INFRASTRUCTURE_TYPE_DEFAULT_NETWORKING = "ME_STANDALONE"
2728
NB_SESSION_IDENTIFIER = "NB_SESSION_OCID"

ads/aqua/model/entities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class AquaModelSummary(DataClassSerializable):
7676
ready_to_deploy: bool = True
7777
ready_to_finetune: bool = False
7878
ready_to_import: bool = False
79+
platform: List[str] = field(default_factory=lambda: ["nvidia_gpu"])
7980

8081

8182
@dataclass(repr=False)

ads/aqua/model/model.py

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
# Copyright (c) 2024 Oracle and/or its affiliates.
43
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
54
import os
@@ -12,7 +11,7 @@
1211

1312
from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID
1413
from ads.aqua.app import AquaApp
15-
from ads.aqua.common.enums import Tags
14+
from ads.aqua.common.enums import Tags, InferenceContainerTypeFamily
1615
from ads.aqua.common.errors import AquaRuntimeError
1716
from ads.aqua.common.utils import (
1817
create_word_icon,
@@ -36,7 +35,7 @@
3635
AQUA_MODEL_ARTIFACT_CONFIG,
3736
AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME,
3837
AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE,
39-
AQUA_MODEL_TYPE_CUSTOM,
38+
AQUA_MODEL_TYPE_CUSTOM, ARM_CPU, NVIDIA_GPU,
4039
)
4140
from ads.aqua.model.constants import *
4241
from ads.aqua.model.entities import *
@@ -268,8 +267,7 @@ def get(self, model_id: str, load_model_card: Optional[bool] = True) -> "AquaMod
268267

269268
job_run_status = (
270269
jobrun.lifecycle_state
271-
if jobrun
272-
and not jobrun.lifecycle_state == JobRun.LIFECYCLE_STATE_DELETED
270+
if jobrun and jobrun.lifecycle_state != JobRun.LIFECYCLE_STATE_DELETED
273271
else (
274272
JobRun.LIFECYCLE_STATE_SUCCEEDED
275273
if self.if_artifact_exist(ds_model.id)
@@ -540,7 +538,7 @@ def clear_model_list_cache(
540538
dict with the key used, and True if cache has the key that needs to be deleted.
541539
"""
542540
res = {}
543-
logger.info(f"Clearing _service_models_cache")
541+
logger.info("Clearing _service_models_cache")
544542
with self._cache_lock:
545543
if ODSC_MODEL_COMPARTMENT_OCID in self._service_models_cache.keys():
546544
self._service_models_cache.pop(key=ODSC_MODEL_COMPARTMENT_OCID)
@@ -561,6 +559,7 @@ def _create_model_catalog_entry(
561559
verified_model: DataScienceModel,
562560
compartment_id: Optional[str],
563561
project_id: Optional[str],
562+
is_gguf_model: bool,
564563
) -> DataScienceModel:
565564
"""Create model by reference from the object storage path
566565
@@ -583,9 +582,13 @@ def _create_model_catalog_entry(
583582
Tags.AQUA_SERVICE_MODEL_TAG: verified_model.id,
584583
}
585584
if verified_model
586-
else {Tags.AQUA_TAG: "active", Tags.BASE_MODEL_CUSTOM: "true"}
585+
else {
586+
Tags.AQUA_TAG: "active",
587+
Tags.BASE_MODEL_CUSTOM: "true",
588+
}
587589
)
588590
tags.update({Tags.BASE_MODEL_CUSTOM: "true"})
591+
tags.update({Tags.PLATFORM: ARM_CPU if is_gguf_model else NVIDIA_GPU})
589592

590593
# Remove `ready_to_import` tag that might get copied from service model.
591594
tags.pop(Tags.READY_TO_IMPORT, None)
@@ -615,8 +618,8 @@ def _create_model_catalog_entry(
615618
)
616619
else:
617620
logger.warn(
618-
f"Proceeding with model registration without the fine-tuning container information. "
619-
f"This model will not be available for fine tuning."
621+
"Proceeding with model registration without the fine-tuning container information. "
622+
"This model will not be available for fine tuning."
620623
)
621624

622625
metadata.add(
@@ -693,24 +696,26 @@ def register(
693696
The registered model as a AquaModel object.
694697
"""
695698
verified_model_details: DataScienceModel = None
696-
699+
model_config = None
697700
if not import_model_details:
698701
import_model_details = ImportModelDetails(**kwargs)
699-
700-
try:
701-
model_config = load_config(
702-
file_path=import_model_details.os_path,
703-
config_file_name=AQUA_MODEL_ARTIFACT_CONFIG,
704-
)
705-
except Exception as ex:
706-
logger.error(
707-
f"Exception occurred while loading config file from {import_model_details.os_path}"
708-
f"Exception message: {ex}"
709-
)
710-
raise AquaRuntimeError(
711-
f"The model path {import_model_details.os_path} does not contain the file config.json. "
712-
f"Please check if the path is correct or the model artifacts are available at this location."
713-
)
702+
is_gguf_model = import_model_details.inference_container == InferenceContainerTypeFamily.AQUA_LLAMA_CPP_CONTAINER_FAMILY
703+
platform = ARM_CPU if is_gguf_model else NVIDIA_GPU
704+
if not is_gguf_model:
705+
try:
706+
model_config = load_config(
707+
file_path=import_model_details.os_path,
708+
config_file_name=AQUA_MODEL_ARTIFACT_CONFIG,
709+
)
710+
except Exception as ex:
711+
logger.error(
712+
f"Exception occurred while loading config file from {import_model_details.os_path}"
713+
f"Exception message: {ex}"
714+
)
715+
raise AquaRuntimeError(
716+
f"The model path {import_model_details.os_path} does not contain the file config.json. "
717+
f"Please check if the path is correct or the model artifacts are available at this location."
718+
)
714719

715720
model_service_id = None
716721
# If OCID of a model is passed, we need to copy the defaults for Tags and metadata from the service model.
@@ -770,6 +775,7 @@ def register(
770775
verified_model=verified_model_details,
771776
compartment_id=import_model_details.compartment_id,
772777
project_id=import_model_details.project_id,
778+
is_gguf_model=is_gguf_model,
773779
)
774780
# registered model will always have inference and evaluation container, but
775781
# fine-tuning container may be not set
@@ -798,17 +804,23 @@ def register(
798804
inference_container=inference_container,
799805
finetuning_container=finetuning_container,
800806
evaluation_container=evaluation_container,
807+
platform=platform,
801808
)
802809

803810
if verified_model_details:
804811
telemetry_model_name = model_name
812+
elif (
813+
model_config is not None
814+
and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME in model_config
815+
):
816+
telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME]}"
817+
elif (
818+
model_config is not None
819+
and AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config
820+
):
821+
telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE]}"
805822
else:
806-
if AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME in model_config:
807-
telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME]}"
808-
elif AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE in model_config:
809-
telemetry_model_name = f"{AQUA_MODEL_TYPE_CUSTOM}_{model_config[AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE]}"
810-
else:
811-
telemetry_model_name = AQUA_MODEL_TYPE_CUSTOM
823+
telemetry_model_name = AQUA_MODEL_TYPE_CUSTOM
812824

813825
self.telemetry.record_event_async(
814826
category="aqua/model",

0 commit comments

Comments
 (0)