Skip to content

Commit

Permalink
Resolve merge conflicts with main
Browse files Browse the repository at this point in the history
  • Loading branch information
VipulMascarenhas committed Oct 29, 2024
2 parents 7c7d774 + c5bb94e commit cf81e28
Show file tree
Hide file tree
Showing 35 changed files with 1,769 additions and 536 deletions.
16 changes: 0 additions & 16 deletions ads/aqua/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,3 @@ def get_evaluation_service_config(
.get(ContainerSpec.CONTAINER_SPEC, {})
.get(container, {})
)


# TODO: move this to global config.json in object storage
def get_finetuning_config_defaults():
"""Generate and return the fine-tuning default configuration dictionary."""
return {
"shape": {
"VM.GPU.A10.1": {"batch_size": 1, "replica": "1-10"},
"VM.GPU.A10.2": {"batch_size": 1, "replica": "1-10"},
"BM.GPU.A10.4": {"batch_size": 1, "replica": 1},
"BM.GPU4.8": {"batch_size": 4, "replica": 1},
"BM.GPU.L40S-NC.4": {"batch_size": 4, "replica": 1},
"BM.GPU.A100-v2.8": {"batch_size": 6, "replica": 1},
"BM.GPU.H100.8": {"batch_size": 6, "replica": 1},
}
}
38 changes: 0 additions & 38 deletions ads/aqua/config/deployment_config_defaults.json

This file was deleted.

9 changes: 0 additions & 9 deletions ads/aqua/config/resource_limit_names.json

This file was deleted.

1 change: 1 addition & 0 deletions ads/aqua/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
LIFECYCLE_DETAILS_MISSING_JOBRUN = "The associated JobRun resource has been deleted."
READY_TO_DEPLOY_STATUS = "ACTIVE"
READY_TO_FINE_TUNE_STATUS = "TRUE"
PRIVATE_ENDPOINT_TYPE = "MODEL_DEPLOYMENT"
AQUA_GA_LIST = ["id19sfcrra6z"]
AQUA_MODEL_TYPE_SERVICE = "service"
AQUA_MODEL_TYPE_CUSTOM = "custom"
Expand Down
3 changes: 1 addition & 2 deletions ads/aqua/extension/finetune_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

Expand All @@ -9,8 +8,8 @@
from tornado.web import HTTPError

from ads.aqua.common.decorator import handle_exceptions
from ads.aqua.extension.errors import Errors
from ads.aqua.extension.base_handler import AquaAPIhandler
from ads.aqua.extension.errors import Errors
from ads.aqua.extension.utils import validate_function_parameters
from ads.aqua.finetuning import AquaFineTuningApp
from ads.aqua.finetuning.entities import CreateFineTuningDetails
Expand Down
25 changes: 22 additions & 3 deletions ads/aqua/extension/ui_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

Expand All @@ -10,8 +9,9 @@

from ads.aqua.common.decorator import handle_exceptions
from ads.aqua.common.enums import Tags
from ads.aqua.extension.errors import Errors
from ads.aqua.constants import PRIVATE_ENDPOINT_TYPE
from ads.aqua.extension.base_handler import AquaAPIhandler
from ads.aqua.extension.errors import Errors
from ads.aqua.extension.utils import validate_function_parameters
from ads.aqua.model.entities import ImportModelDetails
from ads.aqua.ui import AquaUIApp
Expand Down Expand Up @@ -72,6 +72,8 @@ def get(self, id=""):
return self.list_vcn()
elif paths.startswith("aqua/subnets"):
return self.list_subnets()
elif paths.startswith("aqua/privateendpoints"):
return self.list_private_endpoints()
elif paths.startswith("aqua/shapes/limit"):
return self.get_shape_availability()
elif paths.startswith("aqua/bucket/versioning"):
Expand Down Expand Up @@ -175,15 +177,31 @@ def list_subnets(self, **kwargs):
)
)

def list_private_endpoints(self, **kwargs):
"""Lists the private endpoints in the specified compartment."""
compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
resource_type = self.get_argument(
"resource_type", default=PRIVATE_ENDPOINT_TYPE
)
return self.finish(
AquaUIApp().list_private_endpoints(
compartment_id=compartment_id, resource_type=resource_type, **kwargs
)
)

def get_shape_availability(self, **kwargs):
"""For a given compartmentId, resource limit name, and scope, returns the number of available resources associated
with the given limit."""
compartment_id = self.get_argument("compartment_id", default=COMPARTMENT_OCID)
instance_shape = self.get_argument("instance_shape")
limit_name = self.get_argument("limit_name")

return self.finish(
AquaUIApp().get_shape_availability(
compartment_id=compartment_id, instance_shape=instance_shape, **kwargs
compartment_id=compartment_id,
instance_shape=instance_shape,
limit_name=limit_name,
**kwargs,
)
)

Expand Down Expand Up @@ -244,6 +262,7 @@ def post(self, *args, **kwargs):
("job/shapes/?([^/]*)", AquaUIHandler),
("vcn/?([^/]*)", AquaUIHandler),
("subnets/?([^/]*)", AquaUIHandler),
("privateendpoints/?([^/]*)", AquaUIHandler),
("shapes/limit/?([^/]*)", AquaUIHandler),
("bucket/versioning/?([^/]*)", AquaUIHandler),
("containers/?([^/]*)", AquaUIHandler),
Expand Down
9 changes: 5 additions & 4 deletions ads/aqua/finetuning/entities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
from dataclasses import dataclass, field
Expand All @@ -14,16 +13,18 @@ class AquaFineTuningParams(DataClassSerializable):
epochs: int
learning_rate: Optional[float] = None
sample_packing: Optional[bool] = "auto"
batch_size: Optional[
int
] = None # make it batch_size for user, but internally this is micro_batch_size
batch_size: Optional[int] = (
None # make it batch_size for user, but internally this is micro_batch_size
)
sequence_len: Optional[int] = None
pad_to_sequence_len: Optional[bool] = None
lora_r: Optional[int] = None
lora_alpha: Optional[int] = None
lora_dropout: Optional[float] = None
lora_target_linear: Optional[bool] = None
lora_target_modules: Optional[List] = None
early_stopping_patience: Optional[int] = None
early_stopping_threshold: Optional[float] = None


@dataclass(repr=False)
Expand Down
21 changes: 13 additions & 8 deletions ads/aqua/finetuning/finetuning.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

import json
import os
from dataclasses import asdict, fields, MISSING
from dataclasses import MISSING, asdict, fields
from typing import Dict

from oci.data_science.models import (
Expand All @@ -14,7 +13,7 @@
UpdateModelProvenanceDetails,
)

from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, logger
from ads.aqua import logger
from ads.aqua.app import AquaApp
from ads.aqua.common.enums import Resource, Tags
from ads.aqua.common.errors import AquaFileExistsError, AquaValueError
Expand All @@ -31,7 +30,6 @@
UNKNOWN,
UNKNOWN_DICT,
)
from ads.aqua.config.config import get_finetuning_config_defaults
from ads.aqua.data import AquaResourceIdentifier
from ads.aqua.finetuning.constants import *
from ads.aqua.finetuning.entities import *
Expand Down Expand Up @@ -132,7 +130,7 @@ def create(
or create_fine_tuning_details.validation_set_size >= 1
):
raise AquaValueError(
f"Fine tuning validation set size should be a float number in between [0, 1)."
"Fine tuning validation set size should be a float number in between [0, 1)."
)

if create_fine_tuning_details.replica < DEFAULT_FT_REPLICA:
Expand Down Expand Up @@ -394,7 +392,7 @@ def create(
)
# track shapes that were used for fine-tune creation
self.telemetry.record_event_async(
category=f"aqua/service/finetune/create/shape/",
category="aqua/service/finetune/create/shape/",
action=f"{create_fine_tuning_details.shape_name}x{create_fine_tuning_details.replica}",
**telemetry_kwargs,
)
Expand Down Expand Up @@ -533,6 +531,12 @@ def _build_oci_launch_cmd(
oci_launch_cmd += f"--num_{key} {value} "
elif key == "lora_target_modules":
oci_launch_cmd += f"--{key} {','.join(str(k) for k in value)} "
elif key == "early_stopping_patience":
if value != 0:
oci_launch_cmd += f"--{key} {value} "
elif key == "early_stopping_threshold":
if "early_stopping_patience" in oci_launch_cmd:
oci_launch_cmd += f"--{key} {value} "
else:
oci_launch_cmd += f"--{key} {value} "

Expand All @@ -558,8 +562,9 @@ def get_finetuning_config(self, model_id: str) -> Dict:

config = self.get_config(model_id, AQUA_MODEL_FINETUNING_CONFIG)
if not config:
logger.info(f"Fetching default fine-tuning config for model: {model_id}")
config = get_finetuning_config_defaults()
logger.debug(
f"Fine-tuning config for custom model: {model_id} is not available."
)
return config

@telemetry(
Expand Down
Loading

0 comments on commit cf81e28

Please sign in to comment.