Skip to content

Added cli to convert legacy fine tuned model to v2. #1241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 6, 2025

Conversation

lu-ohai
Copy link
Member

@lu-ohai lu-ohai commented Aug 4, 2025

Added cli to convert legacy fine tuned model to v2.

  • Added convert_fine_tune to convert legacy fine tuned model to v2.

Integration

  • Convert legacy fine tuned model to v2 via cli
Screenshot 2025-08-04 at 3 31 23 PM
  • Fine tuned model v2 will have tag fine_tune_model_version and only fine tune artifacts in model_file_description.json
Screenshot 2025-08-04 at 3 08 38 PM

Unit

============================================= test session starts =============================================
platform darwin -- Python 3.13.2, pytest-8.3.5, pluggy-1.5.0 -- /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
cachedir: .pytest_cache
rootdir: /Users/Downloads/fix_logic/accelerated-data-science
configfile: pytest.ini
plugins: anyio-4.9.0, langsmith-0.3.15, mock-3.14.0, xdist-3.6.1
collected 35 items                                                                                            

tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_create_model PASSED                   [  2%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_create_multimodel PASSED              [  5%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_get_foundation_models[service] PASSED [  8%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_get_foundation_models[verified] PASSED [ 11%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_get_model_fine_tuned PASSED           [ 14%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_convert_fine_tune PASSED              [ 17%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_verified_model[True-True-True] PASSED [ 20%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_verified_model[True-False-True] PASSED [ 22%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_verified_model[False-True-False] PASSED [ 25%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_verified_model[False-False-True] PASSED [ 28%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_any_model_no_containers_specified PASSED [ 31%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_project_compartment_override[True] PASSED [ 34%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_project_compartment_override[False] PASSED [ 37%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_missing_config[True-True] PASSED [ 40%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_missing_config[True-False] PASSED [ 42%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_missing_config[False-True] PASSED [ 45%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_missing_config[False-False] PASSED [ 48%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_missing_config[None-False] PASSED [ 51%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_missing_config[None-True] PASSED [ 54%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_any_model_smc_container PASSED [ 57%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_tei_model_byoc[True] PASSED    [ 60%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_tei_model_byoc[False] PASSED   [ 62%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_model_with_input_tags PASSED   [ 65%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data0-ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --cleanup_model_cache False --inference_container odsc-vllm-serving] PASSED [ 68%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data1-ads aqua model register --model ocid1.datasciencemodel.oc1.iad.<OCID> --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --cleanup_model_cache False] PASSED [ 71%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data2-ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf False --cleanup_model_cache False] PASSED [ 74%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data3-ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --cleanup_model_cache False --model_file test_model_file] PASSED [ 77%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data4-ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --cleanup_model_cache False --inference_container odsc-tei-serving --inference_container_uri <region>.ocir.io/<your_tenancy>/<your_image>] PASSED [ 80%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data5-ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --cleanup_model_cache False --inference_container odsc-vllm-serving --freeform_tags {"ftag1": "fvalue1", "ftag2": "fvalue2"} --defined_tags {"dtag1": "dvalue1", "dtag2": "dvalue2"}] PASSED [ 82%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_import_cli[data6-ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --cleanup_model_cache True --inference_container odsc-vllm-serving --ignore_model_artifact_check True] PASSED [ 85%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_load_license PASSED                   [ 88%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_list_service_models PASSED            [ 91%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_list_custom_models PASSED             [ 94%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_build_search_text_0 PASSED            [ 97%]
tests/unitary/with_extras/aqua/test_model.py::TestAquaModel::test_build_search_text_1_This_is_a_description_ PASSED [100%]

============================================= 35 passed in 20.12s =============================================

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 4, 2025
or legacy_tags.get(Tags.AQUA_FINE_TUNE_MODEL_VERSION, UNKNOWN).lower()
== AQUA_FINE_TUNE_MODEL_VERSION
):
raise AquaValueError(
Copy link
Member

Choose a reason for hiding this comment

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

raise AquaValueError(
            f"Model '{model_id}' is not eligible for conversion. Only legacy AQUA fine-tuned models "
            f"without the 'fine_tune_model_version={AQUA_FINE_TUNE_MODEL_VERSION}' tag are supported."
        )

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

.create(model_by_reference=True)
)

logger.info(
Copy link
Member

Choose a reason for hiding this comment

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

     f"Successfully created version '{AQUA_FINE_TUNE_MODEL_VERSION}' fine-tuned model: '{fine_tune_model_v2.id}' "
     f"based on legacy model '{model_id}'. This model is now ready for deployment."
 )```

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

)

if not legacy_fine_tuned_model.model_file_description:
raise AquaValueError(
Copy link
Member

Choose a reason for hiding this comment

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

raise AquaValueError(
        f"Model '{model_id}' is missing required metadata and cannot be converted. "
        "This may indicate the model was not created properly or is not a supported legacy AQUA fine-tuned model."
    )

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@@ -645,6 +646,80 @@ def edit_registered_model(
else:
raise AquaRuntimeError("Only registered unverified models can be edited.")

def convert_fine_tune(
Copy link
Member

Choose a reason for hiding this comment

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

We need to add one more validation, in case if model is already converted to V2, we should inform user about this and say:

logger.info(
        f"Model '{model_id}' is already a fine-tuned model in version '{AQUA_FINE_TUNE_MODEL_VERSION}'. "
        "No conversion is necessary."
    )

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Let's make it more explicit. I mean for this use case let's show the dedicated message that I've posted above. Otherwise users might think that something wrong with their model.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@mrDzurb mrDzurb merged commit d852209 into feature/model_group Aug 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants