Skip to content

Commit f5e1bb0

Browse files
committed
modified unit tests to include fine tuned models
1 parent deae57b commit f5e1bb0

File tree

5 files changed

+101
-9
lines changed

5 files changed

+101
-9
lines changed

ads/aqua/common/entities.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class AquaMultiModelRef(Serializable):
157157
Optional environment variables to override during deployment.
158158
artifact_location : Optional[str]
159159
Artifact path of model in the multimodel group.
160+
fine_tune_artifact : Optional[str]
161+
For fine tuned models, the artifact path of the modified model weights
160162
"""
161163

162164
model_id: str = Field(..., description="The model OCID to deploy.")
@@ -171,6 +173,9 @@ class AquaMultiModelRef(Serializable):
171173
artifact_location: Optional[str] = Field(
172174
None, description="Artifact path of model in the multimodel group."
173175
)
176+
fine_tune_artifact: Optional[str] = Field(
177+
None, description="For fine tuned models, the artifact path of the modified model weights"
178+
)
174179

175180
class Config:
176181
extra = "ignore"

ads/aqua/model/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def set_fine_tune_env_var(aqua_model: DataScienceModel, env_var: Optional[Dict[s
4848
# we add the correct artifact location when using FT in Multi Model Deployment
4949
if model:
5050
model.artifact_location = base_model_path # validated later in _create_multi method in deployment.py
51-
model.env_var.update({"FT_MODEL": f"{fine_tune_output_path}"})
51+
model.fine_tune_artifact = fine_tune_output_path
5252

5353
else:
5454
env_var.update({"FT_MODEL": f"{fine_tune_output_path}"})

ads/aqua/modeldeployment/deployment.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,8 @@ def _create_multi(
623623
if model.model_task:
624624
config_data["model_task"] = model.model_task
625625

626-
fine_tuned_model = model.env_var.get("FT_MODEL")
627-
628-
if fine_tuned_model:
629-
config_data["FT_MODEL"] = fine_tuned_model
626+
if model.fine_tune_artifact:
627+
config_data["fine_tune_path"] = model.fine_tune_artifact
630628

631629
model_config.append(config_data)
632630
model_name_list.append(model.model_name)

tests/unitary/with_extras/aqua/test_deployment.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class TestDataset:
275275
"environment_configuration_type": "OCIR_CONTAINER",
276276
"environment_variables": {
277277
"MODEL_DEPLOY_PREDICT_ENDPOINT": "/v1/completions",
278-
"MULTI_MODEL_CONFIG": '{ "models": [{ "params": "--served-model-name model_one --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_one/5be6479/artifact/", "model_task": "text_embedding"}, {"params": "--served-model-name model_two --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_two/83e9aa1/artifact/", "model_task": "image_text_to_text"}, {"params": "--served-model-name model_three --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_three/83e9aa1/artifact/", "model_task": "code_synthesis"}]}',
278+
"MULTI_MODEL_CONFIG": '{ "models": [{ "params": "--served-model-name model_one --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_one/5be6479/artifact/", "model_task": "text_embedding"}, {"params": "--served-model-name model_two --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_two/83e9aa1/artifact/", "model_task": "image_text_to_text"}, {"params": "--served-model-name model_three --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_three/83e9aa1/artifact/", "model_task": "code_synthesis", "fine_tune_path": "oci://test_bucket@test_namespace/models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>"}]}',
279279
},
280280
"health_check_port": 8080,
281281
"image": "dsmc://image-name:1.0.0.0",
@@ -487,6 +487,7 @@ class TestDataset:
487487
"model_name": "test_model_1",
488488
"model_task": "text_embedding",
489489
"artifact_location": "test_location_1",
490+
"fine_tune_artifact" : None
490491
},
491492
{
492493
"env_var": {},
@@ -495,6 +496,7 @@ class TestDataset:
495496
"model_name": "test_model_2",
496497
"model_task": "image_text_to_text",
497498
"artifact_location": "test_location_2",
499+
"fine_tune_artifact" : None
498500
},
499501
{
500502
"env_var": {},
@@ -503,12 +505,13 @@ class TestDataset:
503505
"model_name": "test_model_3",
504506
"model_task": "code_synthesis",
505507
"artifact_location": "test_location_3",
508+
"fine_tune_artifact" : "oci://test_bucket@test_namespace/models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>"
506509
},
507510
],
508511
"model_id": "ocid1.datasciencemodel.oc1.<region>.<OCID>",
509512
"environment_variables": {
510513
"MODEL_DEPLOY_PREDICT_ENDPOINT": "/v1/completions",
511-
"MULTI_MODEL_CONFIG": '{ "models": [{ "params": "--served-model-name model_one --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_one/5be6479/artifact/", "model_task": "text_embedding"}, {"params": "--served-model-name model_two --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_two/83e9aa1/artifact/", "model_task": "image_text_to_text"}, {"params": "--served-model-name model_three --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_three/83e9aa1/artifact/", "model_task": "code_synthesis"}]}',
514+
"MULTI_MODEL_CONFIG": '{ "models": [{ "params": "--served-model-name model_one --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_one/5be6479/artifact/", "model_task": "text_embedding"}, {"params": "--served-model-name model_two --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_two/83e9aa1/artifact/", "model_task": "image_text_to_text"}, {"params": "--served-model-name model_three --tensor-parallel-size 1 --max-model-len 2096", "model_path": "models/model_three/83e9aa1/artifact/", "model_task": "code_synthesis", "fine_tune_path": "oci://test_bucket@test_namespace/models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>"}]}',
512515
},
513516
"cmd": [],
514517
"console_link": "https://cloud.oracle.com/data-science/model-deployments/ocid1.datasciencemodeldeployment.oc1.<region>.<MD_OCID>?region=region-name",
@@ -969,6 +972,7 @@ class TestDataset:
969972
"model_name": "model_one",
970973
"model_task": "text_embedding",
971974
"artifact_location": "artifact_location_one",
975+
"fine_tune_artifact": None
972976
},
973977
{
974978
"env_var": {"--test_key_two": "test_value_two"},
@@ -977,6 +981,7 @@ class TestDataset:
977981
"model_name": "model_two",
978982
"model_task": "image_text_to_text",
979983
"artifact_location": "artifact_location_two",
984+
"fine_tune_artifact": None
980985
},
981986
{
982987
"env_var": {"--test_key_three": "test_value_three"},
@@ -985,6 +990,7 @@ class TestDataset:
985990
"model_name": "model_three",
986991
"model_task": "code_synthesis",
987992
"artifact_location": "artifact_location_three",
993+
"fine_tune_artifact" : "oci://test_bucket@test_namespace/models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>"
988994
},
989995
]
990996

@@ -1811,6 +1817,7 @@ def test_create_deployment_for_multi_model(
18111817
model_task="code_synthesis",
18121818
gpu_count=2,
18131819
artifact_location="test_location_3",
1820+
fine_tune_artifact= "oci://test_bucket@test_namespace/models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>"
18141821
)
18151822

18161823
result = self.app.create(

tests/unitary/with_extras/aqua/test_model.py

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,74 @@ class TestDataset:
254254
],
255255
}
256256

257+
fine_tuned_model_file_description = {
258+
"version": "1.0",
259+
"type": "modelOSSReferenceDescription",
260+
"models": [
261+
{
262+
"namespace": "test_namespace",
263+
"bucketName": "test_bucket",
264+
"prefix": "models/meta-llama/Llama-3.2-3B-Instruct",
265+
"objects": [
266+
{
267+
"name": "models/meta-llama/Llama-3.2-3B-Instruct/.gitattributes",
268+
"version": "bfbf278c-10af-4f2c-8240-11fed02e1322",
269+
"sizeInBytes": 1519,
270+
},
271+
{
272+
"name": "models/meta-llama/Llama-3.2-3B-Instruct/LICENSE.txt",
273+
"version": "4238d1e2-d826-4300-a344-0ead410afa27",
274+
"sizeInBytes": 7712,
275+
},
276+
{
277+
"name": "models/meta-llama/Llama-3.2-3B-Instruct/README.md",
278+
"version": "57382552-9ad0-4546-b38c-c96634f3b8a2",
279+
"sizeInBytes": 41744,
280+
},
281+
],
282+
},
283+
{
284+
"namespace": "test_namespace",
285+
"bucketName": "test_bucket",
286+
"prefix": "models/meta-llama/Llama-3.2-3B-Instruct",
287+
"objects": [
288+
{
289+
"name": "models/meta-llama/Llama-3.2-3B-Instruct/.gitattributes",
290+
"version": "bfbf278c-10af-4f2c-8240-11fed02e1322",
291+
"sizeInBytes": 1519,
292+
},
293+
{
294+
"name": "models/meta-llama/Llama-3.2-3B-Instruct/LICENSE.txt",
295+
"version": "4238d1e2-d826-4300-a344-0ead410afa27",
296+
"sizeInBytes": 7712,
297+
},
298+
{
299+
"name": "models/meta-llama/Llama-3.2-3B-Instruct/README.md",
300+
"version": "57382552-9ad0-4546-b38c-c96634f3b8a2",
301+
"sizeInBytes": 41744,
302+
},
303+
],
304+
},
305+
{
306+
"namespace": "test_namespace",
307+
"bucketName": "test_bucket",
308+
"prefix": "models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>",
309+
"objects": [
310+
{
311+
"name": "models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>/README.md",
312+
"version": "636b83ae-be59-445f-a8d7-da7277535ef0",
313+
"sizeInBytes": 5176
314+
},
315+
{
316+
"name": "models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>/adapter_config.json",
317+
"version": "6d6ea6c9-05e1-44d9-bab6-0ad175c924e6",
318+
"sizeInBytes": 805
319+
}
320+
]
321+
},
322+
],
323+
}
324+
257325
SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
258326
COMPARTMENT_ID = "ocid1.compartment.oc1..<UNIQUE_OCID>"
259327
SERVICE_MODEL_ID = "ocid1.datasciencemodel.oc1.iad.<OCID>"
@@ -488,9 +556,23 @@ def test_create_multimodel(
488556
mock_model.freeform_tags["task"] = "text-generation"
489557
model_info_1.model_task = "text_embedding"
490558

559+
560+
# testing requesting metadata from fine tuned model to add to model group
561+
mock_model.model_file_description = TestDataset.fine_tuned_model_file_description
562+
563+
# testing fine tuned model in model group
564+
model_info_3 = AquaMultiModelRef(
565+
model_id="test_model_id_3",
566+
gpu_count=2,
567+
model_task="image_text_to_text",
568+
env_var={"params": "--trust-remote-code --max-model-len 32000"},
569+
artifact_location="oci://test_bucket@test_namespace/models/meta-llama/Llama-3.2-3B-Instruct",
570+
fine_tune_artifact="oci://test_bucket@test_namespace/models/ft-models/meta-llama-3b/ocid1.datasciencejob.oc1.iad.<ocid>"
571+
)
572+
491573
# will create a multi-model group
492574
model = self.app.create_multi(
493-
models=[model_info_1, model_info_2],
575+
models=[model_info_1, model_info_2, model_info_3],
494576
project_id="test_project_id",
495577
compartment_id="test_compartment_id",
496578
)
@@ -503,7 +585,7 @@ def test_create_multimodel(
503585
mock_create.return_value = mock_model
504586

505587
assert model.freeform_tags == {"aqua_multimodel": "true"}
506-
assert model.custom_metadata_list.get("model_group_count").value == "2"
588+
assert model.custom_metadata_list.get("model_group_count").value == "3"
507589
assert (
508590
model.custom_metadata_list.get("deployment-container").value
509591
== "odsc-vllm-serving"

0 commit comments

Comments
 (0)