Skip to content

Commit 1e418db

Browse files
Resolve merge conflicts and ruff update
2 parents 32b73f3 + bc2e0b7 commit 1e418db

File tree

5 files changed

+106
-20
lines changed

5 files changed

+106
-20
lines changed

ads/aqua/extension/deployment_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ class AquaDeploymentParamsHandler(AquaAPIhandler):
215215
def get(self, model_id):
216216
"""Handle GET request."""
217217
instance_shape = self.get_argument("instance_shape")
218+
gpu_count = self.get_argument("gpu_count", default=None)
218219
return self.finish(
219220
AquaDeploymentApp().get_deployment_default_params(
220-
model_id=model_id, instance_shape=instance_shape
221+
model_id=model_id, instance_shape=instance_shape, gpu_count=gpu_count
221222
)
222223
)
223224

ads/aqua/modeldeployment/deployment.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ def get_deployment_default_params(
808808
self,
809809
model_id: str,
810810
instance_shape: str,
811+
gpu_count: int = None,
811812
) -> List[str]:
812813
"""Gets the default params set in the deployment configs for the given model and instance shape.
813814
@@ -819,6 +820,9 @@ def get_deployment_default_params(
819820
instance_shape: (str).
820821
The shape of the instance used for deployment.
821822
823+
gpu_count: (int, optional).
824+
The number of GPUs used by the Aqua model. Defaults to None.
825+
822826
Returns
823827
-------
824828
List[str]:
@@ -827,6 +831,7 @@ def get_deployment_default_params(
827831
828832
"""
829833
default_params = []
834+
config_params = {}
830835
model = DataScienceModel.from_id(model_id)
831836
try:
832837
container_type_key = model.custom_metadata_list.get(
@@ -843,12 +848,28 @@ def get_deployment_default_params(
843848
and container_type_key in InferenceContainerTypeFamily.values()
844849
):
845850
deployment_config = self.get_deployment_config(model_id)
846-
config_params = (
847-
deployment_config.get("configuration", UNKNOWN_DICT)
848-
.get(instance_shape, UNKNOWN_DICT)
849-
.get("parameters", UNKNOWN_DICT)
850-
.get(get_container_params_type(container_type_key), UNKNOWN)
851-
)
851+
852+
instance_shape_config = deployment_config.get(
853+
"configuration", UNKNOWN_DICT
854+
).get(instance_shape, UNKNOWN_DICT)
855+
856+
if "multi_model_deployment" in instance_shape_config and gpu_count:
857+
gpu_params = instance_shape_config.get(
858+
"multi_model_deployment", UNKNOWN_DICT
859+
)
860+
861+
for gpu_config in gpu_params:
862+
if gpu_config["gpu_count"] == gpu_count:
863+
config_params = gpu_config.get("parameters", UNKNOWN_DICT).get(
864+
get_container_params_type(container_type_key), UNKNOWN
865+
)
866+
break
867+
868+
else:
869+
config_params = instance_shape_config.get(
870+
"parameters", UNKNOWN_DICT
871+
).get(get_container_params_type(container_type_key), UNKNOWN)
872+
852873
if config_params:
853874
params_list = get_params_list(config_params)
854875
restricted_params_set = get_restricted_params_by_container(

tests/unitary/with_extras/aqua/test_data/deployment/deployment_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"configuration": {
3-
"VM.GPU.A10.1": {
3+
"VM.GPU.A10.4": {
44
"parameters": {
55
"TGI_PARAMS": "--max-stop-sequences 6",
66
"VLLM_PARAMS": "--max-model-len 4096"
@@ -24,7 +24,7 @@
2424
}
2525
},
2626
"shape": [
27-
"VM.GPU.A10.1",
27+
"VM.GPU.A10.4",
2828
"VM.Standard.A1.Flex"
2929
]
3030
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"shape": [
3+
"VM.GPU.A10.1",
4+
"VM.GPU.A10.2",
5+
"BM.GPU.A10.4",
6+
"BM.GPU.L40S-NC.4"
7+
],
8+
"configuration": {
9+
"VM.GPU.A10.2": {
10+
"parameters": {
11+
"VLLM_PARAMS": "--trust-remote-code --max-model-len 60000"
12+
},
13+
"multi_model_deployment": [
14+
{
15+
"gpu_count": 1
16+
}
17+
]
18+
},
19+
"BM.GPU.A10.4": {
20+
"parameters": {
21+
"VLLM_PARAMS": "--trust-remote-code --max-model-len 60000"
22+
},
23+
"multi_model_deployment": [
24+
{
25+
"gpu_count": 1
26+
},
27+
{
28+
"gpu_count": 2
29+
}
30+
]
31+
},
32+
"BM.GPU.L40S-NC.4": {
33+
"parameters": {
34+
"VLLM_PARAMS": "--trust-remote-code --max-model-len 60000"
35+
},
36+
"multi_model_deployment": [
37+
{
38+
"gpu_count": 2
39+
}
40+
]
41+
}
42+
}
43+
}

tests/unitary/with_extras/aqua/test_deployment.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class TestDataset:
4040
MODEL_DEPLOYMENT_URL = "https://modeldeployment.customer-oci.com/ocid1.datasciencemodeldeployment.oc1.<region>.<MD_OCID>"
4141
MODEL_ID = "ocid1.datasciencemodeldeployment.oc1.<region>.<MODEL_OCID>"
4242
DEPLOYMENT_IMAGE_NAME = "dsmc://image-name:1.0.0.0"
43-
DEPLOYMENT_SHAPE_NAME = "VM.GPU.A10.1"
43+
DEPLOYMENT_SHAPE_NAME = "BM.GPU.A10.4"
44+
DEPLOYMENT_GPU_COUNT = 1
45+
DEPLOYMENT_GPU_COUNT_B = 2
4446
DEPLOYMENT_SHAPE_NAME_CPU = "VM.Standard.A1.Flex"
4547

4648
model_deployment_object = [
@@ -908,24 +910,28 @@ def test_create_deployment_for_tei_byoc_embedding_model(
908910
(
909911
"VLLM_PARAMS",
910912
"odsc-vllm-serving",
913+
2,
911914
["--max-model-len 4096", "--seed 42", "--trust-remote-code"],
912915
["--max-model-len 4096", "--trust-remote-code"],
913916
),
914917
(
915918
"VLLM_PARAMS",
916919
"odsc-vllm-serving",
917-
[],
918-
[],
920+
None,
921+
["--max-model-len 4096"],
922+
["--max-model-len 4096"],
919923
),
920924
(
921925
"TGI_PARAMS",
922926
"odsc-tgi-serving",
923-
["--sharded true", "--trust-remote-code", "--max-stop-sequences"],
924-
["--max-stop-sequences"],
927+
1,
928+
[],
929+
[],
925930
),
926931
(
927932
"CUSTOM_PARAMS",
928933
"custom-container-key",
934+
None,
929935
["--max-model-len 4096", "--seed 42", "--trust-remote-code"],
930936
["--max-model-len 4096", "--seed 42", "--trust-remote-code"],
931937
),
@@ -936,21 +942,34 @@ def test_get_deployment_default_params(
936942
self,
937943
container_params_field,
938944
container_type_key,
945+
gpu_count,
939946
params,
940947
allowed_params,
941948
mock_from_id,
942949
):
943950
"""Test for fetching config details for a given deployment."""
944951

945952
config_json = os.path.join(
946-
self.curr_dir, "test_data/deployment/deployment_config.json"
953+
self.curr_dir, "test_data/deployment/deployment_gpu_config.json"
947954
)
948955
with open(config_json, "r") as _file:
949956
config = json.load(_file)
950957
# update config params for testing
951-
config["configuration"][TestDataset.DEPLOYMENT_SHAPE_NAME]["parameters"][
952-
container_params_field
953-
] = " ".join(params)
958+
if gpu_count:
959+
# build field for multi_model_deployment
960+
config["configuration"][TestDataset.DEPLOYMENT_SHAPE_NAME][
961+
"multi_model_deployment"
962+
] = [
963+
{
964+
"gpu_count": gpu_count,
965+
"parameters": {container_params_field: " ".join(params)},
966+
}
967+
]
968+
else:
969+
# build field for normal deployment
970+
config["configuration"][TestDataset.DEPLOYMENT_SHAPE_NAME]["parameters"][
971+
container_params_field
972+
] = " ".join(params)
954973

955974
mock_model = MagicMock()
956975
custom_metadata_list = ModelCustomMetadata()
@@ -961,10 +980,12 @@ def test_get_deployment_default_params(
961980
mock_from_id.return_value = mock_model
962981

963982
self.app.get_deployment_config = MagicMock(return_value=config)
983+
964984
result = self.app.get_deployment_default_params(
965-
TestDataset.MODEL_ID, TestDataset.DEPLOYMENT_SHAPE_NAME
985+
TestDataset.MODEL_ID, TestDataset.DEPLOYMENT_SHAPE_NAME, gpu_count
966986
)
967-
if container_params_field == "CUSTOM_PARAMS":
987+
988+
if container_params_field in ("CUSTOM_PARAMS", "TGI_PARAMS"):
968989
assert result == []
969990
else:
970991
assert result == allowed_params

0 commit comments

Comments
 (0)