SageMaker HyperPod のスケールダウンについて整理してみた EKS オーケストレータ編

SageMaker HyperPod のスケールダウンについて整理してみた EKS オーケストレータ編

Clock Icon2025.02.23

こんにちは!クラウド事業本部コンサルティング部のたかくに(@takakuni_)です。

先日、 SageMaker HyperPod クラスターがインスタンスグループの削除をサポートしました。

Changes Added new capability in the UpdateCluster operation to remove instance groups from your SageMaker HyperPod cluster.

https://awsapichanges.com/archive/changes/f24a18-api.sagemaker.html

これにより、HyperPod クラスター内のインスタンスグループ/インスタンスの増減がより柔軟になりました。今回は EKS オーケーストレータのスケールダウンについて整理してみたいと思います。

まとめ

先にまとめです。EKS オーケストレータは、次のルールに沿って、インスタンスグループ/インスタンスを増減できます。

やってみる

EKS オーケストレータを利用した SageMaker HyperPod クラスターを用意します。インスタンスグループの初期状態を以下とします。

  • worker-group-1(1台 ml.t3.medium)
  • worker-group-2(1台 ml.t3.medium)

実施するシナリオは次のとおりです。

  1. インスタンスグループ(worker-group-3)の追加
  2. インスタンスグループ(worker-group-3)のインスタンスを追加(2台)
  3. インスタンスグループ(worker-group-3)のインスタンスを UpdateCluster API で削除(1台)
  4. インスタンスグループ(worker-group-3)のインスタンスを BatchDeleteClusterNodes API で削除(1台)
  5. インスタンスグループ(worker-group-3)を削除
  6. インスタンスグループ(worker-group-2)を削除
    1. インスタンスが存在しているケースでインスタンスグループは削除可能なのか
  7. インスタンスグループ(worker-group-1)のインスタンスを UpdateCluster API で削除(1台)
  8. インスタンスグループ(worker-group-1)を削除

インスタンスグループの追加

まずはインスタンスグループの追加を行います。 worker-group-3 というインスタンスが存在しないインスタンスグループを作成します。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    },
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
-    }
+    },
+    {
+      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
+      "InstanceCount": 0,
+      "InstanceGroupName": "worker-group-3",
+      "InstanceStorageConfigs": [
+        {
+          "EbsVolumeConfig": {
+            "VolumeSizeInGB": 500
+          }
+        }
+      ],
+      "InstanceType": "ml.t3.medium",
+      "LifeCycleConfig": {
+        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
+        "OnCreate": "on_create.sh"
+      },
+      "ThreadsPerCore": 2
+    }
  ]
}

インスタンスが存在しないインスタンスグループが作成され、クラスターの状態は InService となっています。

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 0,
      "InstanceGroupName": "worker-group-3",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスの追加

続いてインスタンスグループにインスタンスを追加します。

Slurm と違い、provisioning_parameters.json を利用しないため、Update Cluster 用の JSON ファイルのみ変更します。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    },
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    },
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
-      "InstanceCount": 0,
+      "InstanceCount": 2,
      "InstanceGroupName": "worker-group-3",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    }
  ]
}

更新は AWS CLI で操作します。

takakuni@ genai-blog % aws sagemaker update-cluster \
--cli-input-json file://update_cluster_eks.json
{
    "ClusterArn": "arn:aws:sagemaker:ap-northeast-1:123456789012:cluster/so8l47aegvx5"
}

インスタンスグループ worker-group-3 のインスタンス数が 2 に増加しています。

Status も InService となっており、稼働できる状況です。

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 2,
      "InstanceGroupName": "worker-group-3",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスの削除 UpdateCluster API

続いてインスタンスの削除を行います。 まずは UpdateCluster API でインスタンス数を減らします。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    },
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    },
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
-      "InstanceCount": 2,
+      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-3",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    }
  ]
}

CurrentCount が 1 に変更されてます。

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-3",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスの削除 BatchDeleteClusterNodes API

続いて、BatchDeleteClusterNodes API で worker-group-3 に所属する、残りのインスタンスを削除します。

# インスタンスの特定
takakuni@ genai-blog % NODE_ID=$(aws sagemaker list-cluster-nodes \
    --cluster-name eks-orchestrator-hyperpod-cluster \
    --instance-group-name-contains "worker-group-3" | jq -r '.ClusterNodeSummaries[].InstanceId')

# インスタンス ID の表示
takakuni@ genai-blog % echo "Deleting nodes: $NODE_ID"
Deleting nodes: i-0e23a7c9d39bcf51c

# インスタンスの削除
takakuni@ genai-blog % aws sagemaker batch-delete-cluster-nodes \
    --cluster-name eks-orchestrator-hyperpod-cluster \
    --node-ids $NODE_ID
{
    "Successful": [
        "i-0e23a7c9d39bcf51c"
    ]
}

クラスターを確認すると、インスタンス数が 0 のインスタンスグループに戻りました。

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 0,
      "InstanceGroupName": "worker-group-3",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスグループの削除

インスタンスグループの削除に入ります。対象のインスタンスグループを InstanceGroups から外し、InstanceGroupsToDelete に名前を入力します。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    },
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
+    }
-    },
-    {
-      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
-      "InstanceCount": 1,
-      "InstanceGroupName": "worker-group-3",
-      "InstanceStorageConfigs": [
-        {
-          "EbsVolumeConfig": {
-            "VolumeSizeInGB": 500
-          }
-        }
-      ],
-      "InstanceType": "ml.t3.medium",
-      "LifeCycleConfig": {
-        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
-        "OnCreate": "on_create.sh"
-      },
-      "ThreadsPerCore": 2
-    }
-  ]
+  ],
+  "InstanceGroupsToDelete": ["worker-group-3"]
}

InstanceGroups から worker-group-3 が削除されていますね。

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    },
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-2",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスが存在するインスタンスグループの削除

インスタンスが存在する場合のインスタンスグループ削除もやってみます。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
+    }
-    },
-    {
-      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
-      "InstanceCount": 1,
-      "InstanceGroupName": "worker-group-2",
-      "InstanceStorageConfigs": [
-        {
-          "EbsVolumeConfig": {
-            "VolumeSizeInGB": 500
-          }
-        }
-      ],
-      "InstanceType": "ml.t3.medium",
-      "LifeCycleConfig": {
-        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
-        "OnCreate": "on_create.sh"
-      },
-      "ThreadsPerCore": 2
-    }
  ],
  "InstanceGroupsToDelete": ["worker-group-2"]
}

InstanceGroups から worker-group-2 が削除され、worker-group-1 のみになりました。

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスグループ (worker-group-1) のインスタンスを削除

インスタンスグループ worker-group-1 のインスタンスを削除してみます。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
    {
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
+      "InstanceCount": 0,
-      "InstanceCount": 1,
      "InstanceGroupName": "worker-group-1",
      "InstanceStorageConfigs": [
        {
          "EbsVolumeConfig": {
            "VolumeSizeInGB": 500
          }
        }
      ],
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ThreadsPerCore": 2
    }
+  ]
-  ],
-  "InstanceGroupsToDelete": ["worker-group-2"]
}

インスタンス数が 0 となり、HyperPod クラスター内にインスタンスが存在しない状態となりました。(Status が InService であるのが気になりますが)

takakuni@ genai-blog % aws sagemaker describe-cluster --cluster-name eks-orchestrator-hyperpod-cluster | jq '{
    ClusterName: .ClusterName,
    ClusterStatus: .ClusterStatus,
    InstanceGroups: [.InstanceGroups[] | {
        CurrentCount: .CurrentCount,
        InstanceGroupName: .InstanceGroupName,
        InstanceType: .InstanceType,
        LifeCycleConfig: .LifeCycleConfig,
        ExecutionRole: .ExecutionRole,
        Status: .Status
    }],
    VpcConfig: .VpcConfig
}'
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "ClusterStatus": "InService",
  "InstanceGroups": [
    {
      "CurrentCount": 0,
      "InstanceGroupName": "worker-group-1",
      "InstanceType": "ml.t3.medium",
      "LifeCycleConfig": {
        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
        "OnCreate": "on_create.sh"
      },
      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
      "Status": "InService"
    }
  ],
  "VpcConfig": {
    "SecurityGroupIds": [
      "sg-0740131857c314654"
    ],
    "Subnets": [
      "subnet-074b2b24eb623fcc7"
    ]
  }
}

インスタンスグループの削除 (worker-group-1)

最後にインスタンスグループを削除してみます。

update_cluster_eks.json
{
  "ClusterName": "eks-orchestrator-hyperpod-cluster",
  "InstanceGroups": [
-    {
-      "ExecutionRole": "arn:aws:iam::123456789012:role/eks-orchestrator-hyperpod-role",
-      "InstanceCount": 0,
-      "InstanceGroupName": "worker-group-1",
-      "InstanceStorageConfigs": [
-        {
-          "EbsVolumeConfig": {
-            "VolumeSizeInGB": 500
-          }
-        }
-      ],
-      "InstanceType": "ml.t3.medium",
-      "LifeCycleConfig": {
-        "SourceS3Uri": "s3://eks-orchestrator-lifecycle-123456789012/config/",
-        "OnCreate": "on_create.sh"
-      },
-      "ThreadsPerCore": 2
-    }
-  ],
+  ]
+  "InstanceGroupsToDelete": ["worker-group-1"]
}

InstanceGroups には最低 1 つ以上のキーが必要と怒られていますね。

takakuni@ genai-blog % aws sagemaker update-cluster \
--cli-input-json file://update_cluster_eks.json

Parameter validation failed:
Invalid length for parameter InstanceGroups, value: 0, valid min length: 1

InstanceGroups のキーごと JSON から無くしても怒られました。

takakuni@ genai-blog % aws sagemaker update-cluster \
--cli-input-json file://update_cluster_eks.json

Parameter validation failed:
Missing required parameter in input: "InstanceGroups"

よって、最低 1 つのインスタンスグループはクラスター内に存在する必要があることがわかります。

まとめ

以上、「SageMaker HyperPod のスケールダウンについて整理してみた EKS オーケストレータ編」でした。

文字数の関係で Slurm は別記事となりますが、近日公開予定です。

このブログがどなたかの参考になれば幸いです。

クラウド事業本部コンサルティング部のたかくに(@takakuni_)でした!

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.