Skip to content
Merged
3 changes: 3 additions & 0 deletions ads/aqua/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class InferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
AQUA_VLLM_CONTAINER_FAMILY = "odsc-vllm-serving"
AQUA_TGI_CONTAINER_FAMILY = "odsc-tgi-serving"
AQUA_LLAMA_CPP_CONTAINER_FAMILY = "odsc-llama-cpp-serving"


class CustomInferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
AQUA_TEI_CONTAINER_FAMILY = "odsc-tei-serving"


Expand Down
13 changes: 12 additions & 1 deletion ads/aqua/extension/model_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from tornado.web import HTTPError

from ads.aqua.common.decorator import handle_exceptions
from ads.aqua.common.enums import (
CustomInferenceContainerTypeFamily,
)
from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
from ads.aqua.common.utils import (
get_hf_model_info,
Expand Down Expand Up @@ -163,7 +166,9 @@ def put(self, id):
raise HTTPError(400, Errors.NO_INPUT_DATA)

inference_container = input_data.get("inference_container")
inference_container_uri = input_data.get("inference_container_uri")
inference_containers = AquaModelApp.list_valid_inference_containers()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it always return a list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes , either an empty list or list of valid containers from container_index.json stored in OSS bucket

inference_containers.extend(CustomInferenceContainerTypeFamily.values())
if (
inference_container is not None
and inference_container not in inference_containers
Expand All @@ -176,7 +181,13 @@ def put(self, id):
task = input_data.get("task")
app = AquaModelApp()
self.finish(
app.edit_registered_model(id, inference_container, enable_finetuning, task)
app.edit_registered_model(
id,
inference_container,
inference_container_uri,
enable_finetuning,
task,
)
)
app.clear_model_details_cache(model_id=id)

Expand Down
57 changes: 43 additions & 14 deletions ads/aqua/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, logger
from ads.aqua.app import AquaApp
from ads.aqua.common.enums import (
CustomInferenceContainerTypeFamily,
FineTuningContainerTypeFamily,
InferenceContainerTypeFamily,
Tags,
Expand Down Expand Up @@ -377,7 +378,9 @@ def delete_model(self, model_id):
)

@telemetry(entry_point="plugin=model&action=delete", name="aqua")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why in telemetry we say delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thanks

def edit_registered_model(self, id, inference_container, enable_finetuning, task):
def edit_registered_model(
self, id, inference_container, inference_container_uri, enable_finetuning, task
):
"""Edits the default config of unverified registered model.

Parameters
Expand All @@ -386,6 +389,8 @@ def edit_registered_model(self, id, inference_container, enable_finetuning, task
The model OCID.
inference_container: str.
The inference container family name
inference_container_uri: str
The inference container uri for embedding models
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s it only for embedding models?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as per now , we accept inference container URI for embedding models only

enable_finetuning: str
Flag to enable or disable finetuning over the model. Defaults to None
task:
Expand All @@ -401,19 +406,46 @@ def edit_registered_model(self, id, inference_container, enable_finetuning, task
if ds_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM, None):
if ds_model.freeform_tags.get(Tags.AQUA_SERVICE_MODEL_TAG, None):
raise AquaRuntimeError(
f"Failed to edit model:{id}. Only registered unverified models can be edited."
"Only registered unverified models can be edited."
)
else:
custom_metadata_list = ds_model.custom_metadata_list
freeform_tags = ds_model.freeform_tags
if inference_container:
custom_metadata_list.add(
key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER,
value=inference_container,
category=MetadataCustomCategory.OTHER,
description="Deployment container mapping for SMC",
replace=True,
)
if (
inference_container
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be replaced with inference_container in CustomInferenceContainerTypeFamily.values()

in CustomInferenceContainerTypeFamily.values()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtendedEnumMeta implement the __contains__ method, that means we can do something like this:

inference_container in CustomInferenceContainerTypeFamily

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

and inference_container_uri is None
):
raise AquaRuntimeError(
"Inference container URI must be provided."
)
else:
custom_metadata_list.add(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to store this info in metadata? Can't it be extracted from MD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This metadata contains deployment container. Via edit feature , user can edit/change deployment container as well. Hence , adding updated container to metadata.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However user can update deployment from console, and in this case the container stored on the model level will not match a real one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but source of truth here should be model right , not the model deployment.
User can create multiple model deployments from a single model. What we are trying to do here is changing/updating the model config.
What if user registered a model for a particular deployment container. Now , they due to some reason want to change the deployment container config of the model.

key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER,
value=inference_container,
category=MetadataCustomCategory.OTHER,
description="Deployment container mapping for SMC",
replace=True,
)
if inference_container_uri:
if (
inference_container
in CustomInferenceContainerTypeFamily.values()
or inference_container is None
):
custom_metadata_list.add(
key=ModelCustomMetadataFields.DEPLOYMENT_CONTAINER_URI,
value=inference_container_uri,
category=MetadataCustomCategory.OTHER,
description=f"Inference container URI for {ds_model.display_name}",
replace=True,
)
else:
raise AquaRuntimeError(
f"Inference container URI can be edited only with container values: {CustomInferenceContainerTypeFamily.values()}"
)

if enable_finetuning is not None:
if enable_finetuning.lower() == "true":
custom_metadata_list.add(
Expand Down Expand Up @@ -448,9 +480,7 @@ def edit_registered_model(self, id, inference_container, enable_finetuning, task
)
AquaApp().update_model(id, update_model_details)
else:
raise AquaRuntimeError(
f"Failed to edit model:{id}. Only registered unverified models can be edited."
)
raise AquaRuntimeError("Only registered unverified models can be edited.")

def _fetch_metric_from_metadata(
self,
Expand Down Expand Up @@ -869,8 +899,7 @@ def _create_model_catalog_entry(
# only add cmd vars if inference container is not an SMC
if (
inference_container not in smc_container_set
and inference_container
== InferenceContainerTypeFamily.AQUA_TEI_CONTAINER_FAMILY
and inference_container in CustomInferenceContainerTypeFamily.values()
):
cmd_vars = generate_tei_cmd_var(os_path)
metadata.add(
Expand Down
Loading