Model Group

Multimodel Serving (MMS) introduces a new capability where you can deploy and manage several machine learning models as a group through a construct called a Model Group.

Model Group is a resource representing collection of models in the Model Store. You can deploy and manage up to 500 models (limited by shape) in a single model deployment. Using it simplifies operations by reducing the overhead of managing several individual model deployments. This represents a significant evolution from traditional single-model deployments to a more dynamic model management and cost aware inferencing.

The key capabilities of the Model Group resource is as follows:

  • Model Group Lifecycle Management - Model Groups support immutability and versioning, providing robust lifecycle tracking, reproducibility and safe iteration of deployments.
  • Inference Keys - You can use SaaS friendly names instead of model OCIDs for inferencing calls. Inference keys are an alias to model OCIDs.
  • Custom Metadata – list of key-value pairs passed to inference container and model specific variables in a Model Group. This feature helps several LLMs to be pinned to GPU cards.

To use Model Groups, you need to have applied the Model Group Policies.

Key Concepts

Model Group

  • A Model Group is a logical resource that holds several models.
  • When deployed, each model in a model group is identified by its model OCID and inference key (optional).
  • The following types are supported:
    Homogeneous
    A group of models of the same type deployed together in a shared runtime environment. These models operate independently but use the same compute and memory resources for efficient infrastructure usage.
    Stacked
    An extension of the Homogeneous Group, designed for large language models (LLMs) with a base model and several fine-tuned weights.
    Heterogeneous
    The Model Group consists of models built on different ML frameworks, such as PyTorch, TensorFlow, or ONNX. This group type lets the deployment of diverse model architectures in a single serving environment.
    Note

    Use the Bring Your Own Container (BYOC) approach to create model group deployment of this type
  • Inference Keys
    Inference Keys let you use SaaS-friendly aliases instead of model OCIDs when making inference calls. An inference key acts as an alias mapped to a specific model OCID and is defined during the creation of a Model Group.
    Note

    Inference keys support a maximum length of 32 characters.

    The following are snapshots showing how to define an inference key using both the REST API and the SDK.

    Rest API:
    
    "memberModelEntries": {
            "memberModelDetails": [
                {
                    "inferenceKey": "key1",
                    "modelId": "ocid1.datasciencemodel.oc1.iad.aaaaaaaa4kqzxsqdmlf3x2hedpyghfpy727odfuwr3pwwhocw32wbtjuj5zq"
                },
                {
                    "inferenceKey": "key2",
                    "modelId": "ocid1.datasciencemodel.oc1.iad.aaaaaaaa5oyorntk2xa2swphlzqgjwmevnrentlcay7ixy5bahkuwb34xlpq"
                },
                {
                    "inferenceKey": "key3",
                    "modelId": "ocid1.datasciencemodel.oc1.iad.aaaaaaaatutjajr32s5uggnv3zud3ve4rya57innybhpkuam3egzmvow4zvq"
                }
            ]
        }
    SDK:
    
    member_model_details_list = [
            MemberModelDetails(
                model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxziav7hda2c2xn57bifhvfjnb63teaxsyal4hie2uykkwrtq",
                inference_key="key-1"),
            MemberModelDetails(
                model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxzia4qrtrviyzlhkvaimsl6aub7nldtnzts72voejpdvmu2q",
                inference_key="key-2"),
            MemberModelDetails(
                model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxziaxicmn7domsjwl5ojmks3dki32ffy26prhey6tmxiwkeq",
                inference_key="key-3")
        ]

Creating a Model Group

Three options are available for creating a model group:
Create a Model Group
Use this option to create a new Model Group from scratch.
Clone and Change an Existing Model Group
Use this option if you already have an existing Model Group and intend to change it by adding or removing models.
Clone from Model Group Version History
Use this option to update the latest model group version of the Model Group Version History.

Create a Model Group

Create a model group from scratch.

  • Use this option to create a new Model Group. Apply the Model Group Policies. If you already have an existing Model Group and intend to change it by adding or removing models, skip this step and go to Step 2: Clone or Patch Model Group.

    1. Navigate to the Create Model Group page.
    2. Select create a new Model Group.
    3. (Optional) Enter a unique name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
    4. (Optional) Enter a description (limit of 400 characters) for the model group.
    5. If you're creating the model group of type HOMOGENOUS, then use the upload artifact option to upload the model group deployment runtime artifact.
    6. Select the compartment.
    7. Select the project.
    8. Select the models to include in the Model Group.
    9. (Optional) Add a version history to the Model Group.
      • To create a new version history, select Create a new Model Group Version History.
        1. Select the compartment from the list.
        2. (Optional) Enter a name (limit of 255 characters). If you don't provide a name, a name is automatically generated..
        3. (Optional) Enter a description (limit of 400 characters) for the model group.
      • To select an existing version history, select Use existing model group version history.
        1. Select the compartment from the list.
        2. Select the project from the list.
        3. Select the model group version history from the list.
    10. Classify the Model Group.
      The Model Group can be of type:
      • Homogenous
      • Heterogeneous
      • Stacked Inferencing
    11. Select Create.
    1. (Optional) Create Model Group version history:
      def __create_model_group_version_history(compartment_id, project_id):
          model_group_version_history_details_object = CreateModelGroupVersionHistoryDetails()
          model_groupversion_history_details_object.compartment_id = f'<compartment_id>
          model_group_version_history_details_object.display_name = f'<display_name>
          model_group_version_history_details_object.project_id = f'<project_id>
       
          try:
              mgvh_response = data_science_client.create_model_group_version_history(model_group_version_history_details_object)
              mgvh_id = json.loads(str(mgvh_response.data))['id']
              return mgvh_id
          except Exception as e:
              logger.error("Failed to create model group version history with error: %s", format(e))
    2. Create Model Group:
      def __create_model_group(compartment_id, project_id):
          model_group_details_object = ModelGroupDetails()
          model_group_details_object.type = ModelGroupDetails.TYPE_HOMOGENEOUS
          #  Optionally, use model_group_details_object.custom_metadata_list to specify custom metadata for the model group.
       
          member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxziav7hda2c2xn57bifhvfjnb63teaxsyal4hie2uykkwrtq",
                  inference_key="key-1"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxzia4qrtrviyzlhkvaimsl6aub7nldtnzts72voejpdvmu2q",
                  inference_key="key-2"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxziaxicmn7domsjwl5ojmks3dki32ffy26prhey6tmxiwkeq",
                  inference_key="key-3")
          ]
       
          member_model_entries = MemberModelEntries()
          member_model_entries.member_model_details = member_model_details_list
       
          create_model_group_details_object = CreateModelGroupDetails()
          create_model_group_details_object.compartment_id = f'<compartment_id>
          create_model_group_details_object.display_name = f'<display_name>
          create_model_group_details_object.project_id = f'<project_id>
          create_model_group_details_object.member_model_entries = member_model_entries
          create_model_group_details_object.model_group_details = model_group_details_object
       
          try:
              model_group_response = data_science_client.create_model_group(create_model_group_details_object)
              model_group_id = json.loads(str(model_group_response.data))['id']
              # Get the data from response
              logger.info(model_group_response.headers)
              return model_group_id
          except Exception as e:
              logger.error("Failed to create model group with error: %s", format(e)))
    3. Create Model Group with versioning:
      def __create_model_group_with_versioning(compartment_id, project_id, model_group_version_history_id):
          model_group_details_object = ModelGroupDetails()
          model_group_details_object.type = ModelGroupDetails.TYPE_HOMOGENEOUS
          # Optionally, use model_group_details_object.custom_metadata_list to specify custom metadata for the model group.
       
          member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxziav7hda2c2xn57bifhvfjnb63teaxsyal4hie2uykkwrtq",
                  inference_key="key-1"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxzia4qrtrviyzlhkvaimsl6aub7nldtnzts72voejpdvmu2q",
                  inference_key="key-2"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.iad.amaaaaaam3xyxziaxicmn7domsjwl5ojmks3dki32ffy26prhey6tmxiwkeq",
                  inference_key="key-3")
          ]
       
          member_model_entries = MemberModelEntries()
          member_model_entries.member_model_details = member_model_details_list
       
          create_model_group_details_object = CreateModelGroupDetails()
          create_model_group_details_object.compartment_id = f'<compartment_id>
          create_model_group_details_object.display_name = f'<display_name>
          create_model_group_details_object.project_id = f'<project_id>
          create_model_group_details_object.member_model_entries = member_model_entries
          create_model_group_details_object.model_group_details = model_group_details_object
          create_model_group_details_object.model_group_version_history_id = model_group_version_history_id
          create_model_group_details_object.version_label = f'<version_label>
       
          try:
              model_group_response = data_science_client.create_model_group(create_model_group_details_object)
              model_group_id = json.loads(str(model_group_response.data))['id']
              # Get the data from response
              logger.info(model_group_response.headers)
              return model_group_id
          except Exception as e:
              logger.error("Failed to create model group with error: %s", format(e))
              exit(1)
    4. Upload Model Group artifact:
      def __attach_model_group_artifact(modelGroupId, file_name):
          logger.info("Create model group artifact")
          f = open(file_name, "rb")
          logger.info("File open")
          content_disposition = "attachment;filename={}".format(file_name)
          logger.debug(content_disposition)
          try:
              data_science_client.base_client.timeout = 30 * 60
              data_science_client.create_model_group_artifact(
                  modelGroupId, f, content_disposition=content_disposition)
              logger.info("Upload success")
          except Exception as e:
              logger.error("Upload error")
          f.close()
          return
    1. Create Model Group version history:
      {
          "displayName":"ModelGroupVersionHistory-Demo-1",
          "description":"Model Group Version History Demo ",
          "compartmentId":"ocid1.compartment.oc1.iad.aaaaaaaasrc2amzllrujrnevxzq2lqgiblp3xs2iwit7xamanuwzdbipe2zq",
          "projectId":"ocid1.datascienceproject.oc1.iad.aaaaaaaa5i2bgmfne4nmlotldb2ngo4itvmbck24m3dro2gdqszsissmydoq"
      }
    2. Create Model Group request payload (homogeneous type):
      {
          "createType": "CREATE",
          "compartmentId": "ocid1.tenancy.oc1..aaaaaaaahzy3x4boh7ipxyft2rowu2xeglvanlfewudbnueugsieyuojkldq",
          "projectId": "ocid1.datascienceproject.oc1.iad.aaaaaaaa5i2bgmfne4nmlotldb2ngo4itvmbck24m3dro2gdqszsissmydoq",
          "displayName": "Model-Group-Create-Demo-1",
          "description": "Test model group creation",
          "modelGroupDetails" : {
              "type": "HOMOGENEOUS",
              "customMetadataList": [{
                  "key":"key-1",
                  "value":"val-1",
                  "description": "Model Group metadata",
                  "category": "Configuration"
              }]
          },
          "memberModelEntries": {
              "memberModelDetails": [
                  {
                      "inferenceKey": "key1",
                      "modelId": "ocid1.datasciencemodel.oc1.iad.aaaaaaaa4kqzxsqdmlf3x2hedpyghfpy727odfuwr3pwwhocw32wbtjuj5zq"
                  },
                  {
                      "inferenceKey": "key2",
                      "modelId": "ocid1.datasciencemodel.oc1.iad.aaaaaaaa5oyorntk2xa2swphlzqgjwmevnrentlcay7ixy5bahkuwb34xlpq"
                  },
                  {
                      "inferenceKey": "key3",
                      "modelId": "ocid1.datasciencemodel.oc1.iad.aaaaaaaatutjajr32s5uggnv3zud3ve4rya57innybhpkuam3egzmvow4zvq"
                  }
              ]
          }
      }
    3. Create Model Group request with versioning:
      {
          "createType": "CREATE",
          "compartmentId": "ocid1.tenancy.oc1..<ocid>",
          "projectId": "ocid1.datascienceproject.oc1.<ocid>",
          "displayName": "Model-Group-Create-Demo-1",
          "description": "Test model group creation",
          "modelGroupDetails" : {
              "type": "HOMOGENEOUS",
              "customMetadataList": [{
                  "key":"key-1",
                  "value":"val-1",
                  "description": "Model Group metadata",
                  "category": "Configuration"
              }]
          },
          "memberModelEntries": {
              "memberModelDetails": [
                  {
                      "inferenceKey": "key1",
                      "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                  },
                  {
                      "inferenceKey": "key2",
                      "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                  },
                  {
                      "inferenceKey": "key3",
                      "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                  }
              ]
          },
          "modelGroupVersionHistoryId":"ocid1.notreviewedplaceholder.oc1.<ocid>",
          "versionLabel": "Model group versioning demo"
      }
    4. Upload Model Group Artifact
      POST https://datascience.<region-identifier>.oci.oraclecloud.com/20190101/modelGroups/<model-group-ocid>/artifact
       
      Body:
      type: binary
      attachment: model-artifact file

Clone or Patch a Model Group

Use this option if you already have an existing Model Group and want to change its composition by adding or removing one or more models. If you don't need to change an existing group, move to the next step.

Use clone to:

  • Create a new model group from an existing one.

  • Change models (add or remove) while cloning.

Patch operations:

  • INSERT: Add new models.

  • REMOVE: Remove existing models.

    1. From the Basic information page, select Clone and modify existing Model Group.
    2. (Optional) Enter a unique name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
    3. (Optional) Enter a description (limit of 400 characters) for the model group.
    4. Select the compartment from the list.
    5. If you're creating the model group of type HOMOGENOUS, then use upload artifact option to upload the model group deployment runtime artifact.
    6. Select the Compartment to display the list of available Model Groups.
    7. Select the Model Group.
    8. Select the models to add to the model group.
    9. Select Add additional models to add new models to the Model Group.
    10. Select the compartment.
    11. Select the project.
    12. Select the models to add.
    13. (Optional) Create the Model Group with versioning:
      Create a new Model Group version history or use an existing one:
      • Select Create a new Model Group Version History
        1. Select the compartment.
        2. Select the project.
        3. (Optional) Enter a unique name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
        4. (Optional) Enter a description (limit of 400 characters) for the model group version history.
      • Select Use existing Model Group Version History
        1. Select the compartment.
        2. Select the project.
        3. Select the Model Group version history.
    14. Classify the Model Group.
      The Model Group can be of type:
      • Homogenous
      • Heterogeneous
      • Stacked Inferencing
    15. Select Create.
    1. Clone the Model Group from an existing Model Group:
      def __clone_from_model_group(compartment_id, project_id):
          print("cloning from the Model Group")
          new_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-11"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-12")
          ]
       
          remove_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-3")
          ]
          patch_insert_model_details = PatchInsertNewMemberModels()
          patch_insert_model_details.values = new_member_model_details_list
       
          patch_remove_model_details = PatchRemoveMemberModels()
          patch_remove_model_details.values = remove_member_model_details_list
       
          patch_instruction_list = [patch_insert_model_details, patch_remove_model_details]
       
          patch_model_group_member_model_details_object = PatchModelGroupMemberModelDetails()
          patch_model_group_member_model_details_object.items = patch_instruction_list
       
          modify_model_group_details_object = ModifyModelGroupDetails()
          modify_model_group_details_object.display_name = "test model group clone"
          modify_model_group_details_object.description = "test model group clone"
       
          clone_create_from_model_group_object = CloneCreateFromModelGroupDetails()
          clone_create_from_model_group_object.source_id = baseModelGroupId
          clone_create_from_model_group_object.patch_model_group_member_model_details = patch_model_group_member_model_details_object
          clone_create_from_model_group_object.modify_model_group_details = modify_model_group_details_object
       
          clone_model_group_details_object = CloneModelGroupDetails()
          clone_model_group_details_object.compartment_id = compartment_id
          clone_model_group_details_object.project_id = project_id
          clone_model_group_details_object.model_group_clone_source_details = clone_create_from_model_group_object
       
          try:
              model_group_response = data_science_client.create_model_group(clone_model_group_details_object)
              model_group_id = json.loads(str(model_group_response.data))['id']
              logger.info(model_group_id)
              print(model_group_response.headers)
              return model_group_id
          except Exception as e:
              logger.error("Failed to create model group with error: %s", format(e))
    2. Clone the Model Group from the latest version of the Model Group version history:
      def __clone_from_model_group_version_history(compartment_id, project_id, model_group_version_history_id):
          print("cloning from the Model Group Version History")
          new_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-11"),
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-12")
          ]
       
          remove_member_model_details_list = [
              MemberModelDetails(
                  model_id="ocid1.datasciencemodel.oc1.<ocid>",
                  inference_key="key-3")
          ]
          patch_insert_model_details = PatchInsertNewMemberModels()
          patch_insert_model_details.values = new_member_model_details_list
       
          patch_remove_model_details = PatchRemoveMemberModels()
          patch_remove_model_details.values = remove_member_model_details_list
       
          patch_instruction_list = [patch_insert_model_details, patch_remove_model_details]
       
          patch_model_group_member_model_details_object = PatchModelGroupMemberModelDetails()
          patch_model_group_member_model_details_object.items = patch_instruction_list
       
          modify_model_group_details_object = ModifyModelGroupDetails()
          modify_model_group_details_object.display_name = "test model group clone from mgvh"
          modify_model_group_details_object.description = "test model group clone from mgvh"
       
          clone_create_from_model_group_version_history_object = CloneCreateFromModelGroupVersionHistoryDetails()
          clone_create_from_model_group_version_history_object.source_id = model_group_version_history_id
          clone_create_from_model_group_version_history_object.patch_model_group_member_model_details = patch_model_group_member_model_details_object
          clone_create_from_model_group_version_history_object.modify_model_group_details = modify_model_group_details_object
       
          clone_model_group_details_object = CloneModelGroupDetails()
          clone_model_group_details_object.compartment_id = compartment_id
          clone_model_group_details_object.project_id = project_id
          clone_model_group_details_object.model_group_clone_source_details = clone_create_from_model_group_version_history_object
       
          try:
              model_group_response = data_science_client.create_model_group(clone_model_group_details_object)
              model_group_id = json.loads(str(model_group_response.data))['id']
              logger.info(model_group_id)
              print(model_group_response.headers)
              return model_group_id
          except Exception as e:
              logger.error("Failed to create model group with error: %s", format(e))
    1. Clone from the Model Group:
      {
          "createType": "CLONE",
          "modelGroupCloneSourceDetails" : {
              "modelGroupCloneSourceType": "MODEL_GROUP",
              "sourceId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
              "modifyModelGroupDetails": {
                  "description": "cloned model group"
              },
              "patchModelGroupMemberModelDetails": {
                  "items" : [
                      {
                          "operation":"INSERT",
                          "values": [
                              {
                                  "inferenceKey": "key101",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              },
                              {
                                  "inferenceKey": "key102",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }
                          ]
                      },
                      {
                          "operation":"REMOVE",
                          "values": [
                              {
                                  "inferenceKey": "key3",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }  
                          ]
                      }
                  ]
              }
          }
      }
    2. Clone from the latest version of the Model Group version history:
      {
          "createType": "CLONE",
          "modelGroupCloneSourceDetails" : {
              "modelGroupCloneSourceType": "MODEL_GROUP_VERSION_HISTORY",
              "sourceId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
              "modifyModelGroupDetails": {
                  "description": "cloned model group from the latest of model group version history"
              },
              "patchModelGroupMemberModelDetails": {
                  "items" : [
                      {
                          "operation":"INSERT",
                          "values": [
                              {
                                  "inferenceKey": "key101",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              },
                              {
                                  "inferenceKey": "key102",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }
                          ]
                      },
                      {
                          "operation":"REMOVE",
                          "values": [
                              {
                                  "inferenceKey": "key2",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }  
                          ]
                      }
                  ]
              }
          }
      }
    3. Update the Model Group:
      {
          "displayName": "updated display name -1 ",
          "description": "update test-1",
          "modelGroupVersionHistoryId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
          "versionLabel": "Model Group Versioning Demo"
      }

Clone a Model Group from a Model Group Version History

    1. Select Clone from Model Group Version History.
    2. (Optional) Enter a unique name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
    3. (Optional) Enter a description (limit of 400 characters) for the model group.
    4. Select the compartment.
    5. If you're creating the model group of type HOMOGENOUS, then use the upload artifact option to upload the model group deployment runtime artifact.
    6. Select the Model Group version history:
      1. Select the compartment.
      2. Select one or more models to be added from the existing model group.
      3. Select Add Additional Models to add new models to the Model Group.
      4. Select the compartment.
      5. Select the project.
      6. Select one or more models to be added.
    7. (Optional) Create the Model Group with versioning:
      Create a new Model Group version history or use an existing one:
      • Select Create a new Model Group Version History
        1. Select the compartment.
        2. Select the project.
        3. (Optional) Enter a unique name (limit of 255 characters). If you don't provide a name, a name is automatically generated.
        4. (Optional) Enter a description (limit of 400 characters) for the model group version history.
      • Select Use existing Model Group Version History
        1. Select the compartment.
        2. Select the project.
        3. Select the Model Group version history.
    8. Classify the Model Group.
      The Model Group can be of type:
      • Homogenous
      • Heterogeneous
      • Stacked Inferencing
    9. Select Create.

    SDK

    Clone the Model Group from the latest version of the Model Group version history:
    def __clone_from_model_group_version_history(compartment_id, project_id, model_group_version_history_id):
        print("cloning from the Model Group Version History")
        new_member_model_details_list = [
            MemberModelDetails(
                model_id="ocid1.datasciencemodel.oc1.<ocid>",
                inference_key="key-11"),
            MemberModelDetails(
                model_id="ocid1.datasciencemodel.oc1.<ocid>",
                inference_key="key-12")
        ]
     
        remove_member_model_details_list = [
            MemberModelDetails(
                model_id="ocid1.datasciencemodel.oc1.<ocid>",
                inference_key="key-3")
        ]
        patch_insert_model_details = PatchInsertNewMemberModels()
        patch_insert_model_details.values = new_member_model_details_list
     
        patch_remove_model_details = PatchRemoveMemberModels()
        patch_remove_model_details.values = remove_member_model_details_list
     
        patch_instruction_list = [patch_insert_model_details, patch_remove_model_details]
     
        patch_model_group_member_model_details_object = PatchModelGroupMemberModelDetails()
        patch_model_group_member_model_details_object.items = patch_instruction_list
     
        modify_model_group_details_object = ModifyModelGroupDetails()
        modify_model_group_details_object.display_name = "test model group clone from mgvh"
        modify_model_group_details_object.description = "test model group clone from mgvh"
     
        clone_create_from_model_group_version_history_object = CloneCreateFromModelGroupVersionHistoryDetails()
        clone_create_from_model_group_version_history_object.source_id = model_group_version_history_id
        clone_create_from_model_group_version_history_object.patch_model_group_member_model_details = patch_model_group_member_model_details_object
        clone_create_from_model_group_version_history_object.modify_model_group_details = modify_model_group_details_object
     
        clone_model_group_details_object = CloneModelGroupDetails()
        clone_model_group_details_object.compartment_id = compartment_id
        clone_model_group_details_object.project_id = project_id
        clone_model_group_details_object.model_group_clone_source_details = clone_create_from_model_group_version_history_object
     
        try:
            model_group_response = data_science_client.create_model_group(clone_model_group_details_object)
            model_group_id = json.loads(str(model_group_response.data))['id']
            logger.info(model_group_id)
            print(model_group_response.headers)
            return model_group_id
        except Exception as e:
            logger.error("Failed to create model group with error: %s", format(e))

    API

    1. Clone from the latest version of the Model Group version history:
      {
          "createType": "CLONE",
          "modelGroupCloneSourceDetails" : {
              "modelGroupCloneSourceType": "MODEL_GROUP_VERSION_HISTORY",
              "sourceId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
              "modifyModelGroupDetails": {
                  "description": "cloned model group from the latest of model group version history"
              },
              "patchModelGroupMemberModelDetails": {
                  "items" : [
                      {
                          "operation":"INSERT",
                          "values": [
                              {
                                  "inferenceKey": "key101",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              },
                              {
                                  "inferenceKey": "key102",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }
                          ]
                      },
                      {
                          "operation":"REMOVE",
                          "values": [
                              {
                                  "inferenceKey": "key2",
                                  "modelId": "ocid1.datasciencemodel.oc1.<ocid>"
                              }  
                          ]
                      }
                  ]
              }
          }
      }
    2. Update the Model Group:
      {
          "displayName": "updated display name -1 ",
          "description": "update test-1",
          "modelGroupVersionHistoryId": "ocid1.notreviewedplaceholder.oc1.<ocid>",
          "versionLabel": "Model Group Versioning Demo"
      }

Deploy the Model Group

    1. Select Models.
    2. Select Model Groups.
    3. Select the Model Group to deploy.
    4. Select Submit.
  • Create the model group deployment:
    # 1. Create model group configuration details object
        model_group_config_details = ModelGroupConfigurationDetails(
        model_group_id="ocid1.modelgroup.oc1..exampleuniqueID"
        bandwidth_mbps=<bandwidth-mbps>,
        instance_configuration=<instance-configuration>,
        scaling_policy=<scaling-policy>
        )
     
     
    # 2. Create infrastructure configuration details object
        infrastructure_config_details = InstancePoolInfrastructureConfigurationDetails(
        infrastructure_type="INSTANCE_POOL",
        instance_configuration=instance_config,
        scaling_policy=scaling_policy
        )
     
    # 3. Create environment configuration
        environment_config_details = ModelDeploymentEnvironmentConfigurationDetails(
        environment_configuration_type="DEFAULT",
        environment_variables={"WEB_CONCURRENCY": "1"}
        )
      
    # 4. Create category log details
        category_log_details = CategoryLogDetails(
        access=LogDetails(
            log_group_id=<log-group-id>,
            log_id=<log-id>
        ),
        predict=LogDetails(
            log_group_id=<log-group-id>,
            log_id=<log-id>
        )
        )
     
    # 5. Bundle into deployment configuration
        model_group_deployment_config_details = ModelGroupDeploymentConfigurationDetails(
        deployment_type="MODEL_GROUP",
        model_group_configuration_details=model_group_config,
        infrastructure_configuration_details=infrastructure_config_details,
        environment_configuration_details=environment_config_details
        )
     
    # 6. Set up parameters required to create a new model deployment.
        create_model_deployment_details = CreateModelDeploymentDetails(
        display_name=<deployment_name>,
        description=<description>,
        compartment_id=<compartment-id>,
        project_id=<project-id>,
        model_deployment_configuration_details=model_group_deployment_config_details,
        category_log_details=category_log_details
        )
     
    # 7. Create deployment using SDK client
        response = data_science_client.create_model_deployment(
        create_model_deployment_details=create_model_deployment_details
        )
     
    print("Model Deployment OCID:", response.data.id)
  • Create the model group deployment:
    {
            "displayName": "MMS Model Group Deployment",
            "description": "mms",
            "compartmentId": compartment_id,
            "projectId": project_id,
            "modelDeploymentConfigurationDetails": {
                "deploymentType": "MODEL_GROUP",
                "modelGroupConfigurationDetails": {
                    "modelGroupId": model_group_id
                },
                "infrastructureConfigurationDetails": {
                    "infrastructureType": "INSTANCE_POOL",
                    "instanceConfiguration": {
                        "instanceShapeName": "VM.Standard.E4.Flex",
                        "modelDeploymentInstanceShapeConfigDetails": {
                            "ocpus": 8,
                            "memoryInGBs": 128
                        }
                    },
                    "scalingPolicy": {
                        "policyType": "FIXED_SIZE",
                        "instanceCount": 1
                    }
                },
                "environmentConfigurationDetails": {
                    "environmentConfigurationType": "DEFAULT",
                    "environmentVariables": {
                        "WEB_CONCURRENCY": "1"
                    }
                }
            },
            "categoryLogDetails": {
                "access": {
                    "logGroupId": "ocid1.loggroup.oc1.iad.amaaaaaav66vvniaygnbicsbzb4anlmf7zg2gsisly3ychusjlwuq34pvjba",
                    "logId": "ocid1.log.oc1.iad.amaaaaaav66vvniavsuh34ijk46uhjgsn3ddzienfgquwrr7dwa4dzt4pirq"
                },
                "predict": {
                    "logGroupId": "ocid1.loggroup.oc1.iad.amaaaaaav66vvniaygnbicsbzb4anlmf7zg2gsisly3ychusjlwuq34pvjba",
                    "logId": "ocid1.log.oc1.iad.amaaaaaav66vvniavsuh34ijk46uhjgsn3ddzienfgquwrr7dwa4dzt4pirq"
                }
            }
        }
    }

Stacked Model Group Creation

  1. Create a base model using the CreateModel API command.
  2. Create fine-tuned weight model using the CreateModel API command.
  3. Create a model group with the modelGroupDetails:
    1. type: STACKED
    2. baseModelId: $baseModelOCID (created in step 1)
    For example:
    compartment_id = "compartmentID"
    project_id = "projectID"
    mg_payload = json.dumps({
            "createType": "CREATE",
            "compartmentId": compartment_id,
            "projectId": project_id,
            "displayName": "Model Group - Stacked ",
            "description": "Test stacked model group",
            "modelGroupDetails" : {
                "type": "STACKED",
                "baseModelId": "ocid1.datasciencemodel.oc1.iad.amaaaaaav66vvnia5eofo6co5mduy7rkfia2ve3xk6trqzkvrolwvxhkdwxa"
            },
            "memberModelEntries": {
                "memberModelDetails": [
                    {
                        "inferenceKey": "basemodel",
                        "modelId": "ocid1.datasciencemodel.oc1.iad.amaaaaaav66vvnia5eofo6co5mduy7rkfia2ve3xk6trqzkvrolwvxhkdwxa"
                    },
                    {
                        "inferenceKey": "sql-lora-1",
                        "modelId": "ocid1.datasciencemodel.oc1.iad.amaaaaaav66vvniavutbdm736xd6azkwdimfgae2j75nh5aem2ejkywbzsia"
                    },
                    {
                        "inferenceKey": "sql-lora-2",
                        "modelId": "ocid1.datasciencemodel.oc1.iad.amaaaaaav66vvniajgixlb4ajceyrv2vlxtz3opkangpcgt3cl3jeovva3oa"
                    }
                ]
            }
        })