diff --git a/modules/python/gpu/cfg/gpu/values.yaml b/modules/python/gpu/cfg/gpu-operator/values.yaml similarity index 100% rename from modules/python/gpu/cfg/gpu/values.yaml rename to modules/python/gpu/cfg/gpu-operator/values.yaml diff --git a/modules/python/gpu/cfg/mpi/aws-job.yaml b/modules/python/gpu/cfg/mpi-operator/aws-job.yaml similarity index 99% rename from modules/python/gpu/cfg/mpi/aws-job.yaml rename to modules/python/gpu/cfg/mpi-operator/aws-job.yaml index 17e84e9e67..bad5de401a 100644 --- a/modules/python/gpu/cfg/mpi/aws-job.yaml +++ b/modules/python/gpu/cfg/mpi-operator/aws-job.yaml @@ -1,7 +1,7 @@ apiVersion: kubeflow.org/v2beta1 kind: MPIJob metadata: - namespace: default + namespace: mpi-operator name: nccl-tests labels: app: nccl-tests diff --git a/modules/python/gpu/cfg/mpi/azure-job-hostpath.yaml b/modules/python/gpu/cfg/mpi-operator/azure-job-hostpath.yaml similarity index 99% rename from modules/python/gpu/cfg/mpi/azure-job-hostpath.yaml rename to modules/python/gpu/cfg/mpi-operator/azure-job-hostpath.yaml index 8278c8a0a6..dc66b55bf2 100644 --- a/modules/python/gpu/cfg/mpi/azure-job-hostpath.yaml +++ b/modules/python/gpu/cfg/mpi-operator/azure-job-hostpath.yaml @@ -1,7 +1,7 @@ apiVersion: kubeflow.org/v2beta1 kind: MPIJob metadata: - namespace: default + namespace: mpi-operator name: nccl-tests labels: app: nccl-tests diff --git a/modules/python/gpu/cfg/mpi/azure-job-sriov.yaml b/modules/python/gpu/cfg/mpi-operator/azure-job-sriov.yaml similarity index 98% rename from modules/python/gpu/cfg/mpi/azure-job-sriov.yaml rename to modules/python/gpu/cfg/mpi-operator/azure-job-sriov.yaml index b676fe898f..9895b5fabd 100644 --- a/modules/python/gpu/cfg/mpi/azure-job-sriov.yaml +++ b/modules/python/gpu/cfg/mpi-operator/azure-job-sriov.yaml @@ -1,7 +1,7 @@ apiVersion: kubeflow.org/v2beta1 kind: MPIJob metadata: - namespace: default + namespace: mpi-operator name: nccl-tests labels: app: nccl-tests diff --git a/modules/python/gpu/cfg/mpi/azure-job-topology.yaml b/modules/python/gpu/cfg/mpi-operator/azure-job-topology.yaml similarity index 99% rename from modules/python/gpu/cfg/mpi/azure-job-topology.yaml rename to modules/python/gpu/cfg/mpi-operator/azure-job-topology.yaml index 542086949f..a6b9e1cc27 100644 --- a/modules/python/gpu/cfg/mpi/azure-job-topology.yaml +++ b/modules/python/gpu/cfg/mpi-operator/azure-job-topology.yaml @@ -1,7 +1,7 @@ apiVersion: kubeflow.org/v2beta1 kind: MPIJob metadata: - namespace: default + namespace: mpi-operator name: nccl-tests labels: app: nccl-tests diff --git a/modules/python/gpu/cfg/net/nfd-network-rule.yaml b/modules/python/gpu/cfg/network-operator/nfd-network-rule.yaml similarity index 100% rename from modules/python/gpu/cfg/net/nfd-network-rule.yaml rename to modules/python/gpu/cfg/network-operator/nfd-network-rule.yaml diff --git a/modules/python/gpu/cfg/net/nic-cluster-policy.yaml b/modules/python/gpu/cfg/network-operator/nic-cluster-policy.yaml similarity index 100% rename from modules/python/gpu/cfg/net/nic-cluster-policy.yaml rename to modules/python/gpu/cfg/network-operator/nic-cluster-policy.yaml diff --git a/modules/python/gpu/cfg/net/values.yaml b/modules/python/gpu/cfg/network-operator/values.yaml similarity index 100% rename from modules/python/gpu/cfg/net/values.yaml rename to modules/python/gpu/cfg/network-operator/values.yaml diff --git a/modules/python/gpu/main.py b/modules/python/gpu/main.py index 67d7473c74..a47cb3845a 100644 --- a/modules/python/gpu/main.py +++ b/modules/python/gpu/main.py @@ -93,7 +93,7 @@ def execute( try: subprocess.run( - ["kubectl", "delete", "mpijob", "nccl-tests", "-n", "default", "--ignore-not-found=true"], + ["kubectl", "delete", "mpijob", "nccl-tests", "-n", "mpi-operator", "--ignore-not-found=true"], check=True, capture_output=True, text=True @@ -123,21 +123,21 @@ def execute( logger.info("No SR-IOV device plugin found, using hostPath for InfiniBand") job_type = "hostpath" - nccl_file = f"{config_dir}/mpi/azure-job-{job_type}.yaml" + nccl_file = f"{config_dir}/mpi-operator/azure-job-{job_type}.yaml" logger.info(f"Running nccl-tests with {replacements} using {nccl_file}") nccl_template = KUBERNETES_CLIENT.create_template(nccl_file, replacements) nccl_dict = yaml.safe_load(nccl_template) KUBERNETES_CLIENT.apply_manifest_from_file(manifest_dict=nccl_dict) elif provider.lower() == "aws": replacements["efa_allocatable"] = efa_allocatable - nccl_file = f"{config_dir}/mpi/{provider}-job.yaml" + nccl_file = f"{config_dir}/mpi-operator/{provider}-job.yaml" logger.info(f"Running nccl-tests with {replacements} using {nccl_file}") nccl_template = KUBERNETES_CLIENT.create_template(nccl_file, replacements) nccl_dict = yaml.safe_load(nccl_template) KUBERNETES_CLIENT.apply_manifest_from_file(manifest_dict=nccl_dict) else: - nccl_file = f"{config_dir}/mpi/{provider}-job.yaml" + nccl_file = f"{config_dir}/mpi-operator/{provider}-job.yaml" logger.info(f"Running nccl-tests with {replacements} using {nccl_file}") nccl_template = KUBERNETES_CLIENT.create_template(nccl_file, replacements) @@ -147,9 +147,10 @@ def execute( KUBERNETES_CLIENT.wait_for_pods_completed, label_selector="component=launcher", pod_count=1, + namespace="mpi-operator", ) pod_name = pods[0].metadata.name - raw_logs = KUBERNETES_CLIENT.get_pod_logs(pod_name) + raw_logs = KUBERNETES_CLIENT.get_pod_logs(pod_name, namespace="mpi-operator") logs = raw_logs.decode("utf-8") logger.info(f"Getting logs for pod {pod_name}:\n{logs}") result_path = f"{result_dir}/raw.log" diff --git a/modules/python/gpu/pkg/mpi.py b/modules/python/gpu/pkg/mpi.py index 31b74cc418..affc33547c 100644 --- a/modules/python/gpu/pkg/mpi.py +++ b/modules/python/gpu/pkg/mpi.py @@ -21,13 +21,13 @@ def install_mpi_operator( Install MPI Operator using Helm Args: - chart_version: Specific chart version to install + chart_version: Specific chart version to install (e.g., "0.5.0") """ mpi_file = f"https://raw.githubusercontent.com/kubeflow/mpi-operator/{chart_version}/deploy/v2beta1/mpi-operator.yaml" KUBERNETES_CLIENT.apply_manifest_from_url(mpi_file) execute_with_retries( KUBERNETES_CLIENT.wait_for_pods_ready, - label_selector="app.kubernetes.io/name=mpi-operator", + label_selector="app=mpi-operator", namespace="mpi-operator", operation_timeout_in_minutes=5, ) diff --git a/modules/python/gpu/pkg/net.py b/modules/python/gpu/pkg/net.py index bdfe2db6de..9fac527b3c 100644 --- a/modules/python/gpu/pkg/net.py +++ b/modules/python/gpu/pkg/net.py @@ -54,9 +54,9 @@ def install_network_operator( operation_timeout_in_minutes=5, ) - nfd_file = f"{config_dir}/net/nfd-network-rule.yaml" + nfd_file = f"{config_dir}/network-operator/nfd-network-rule.yaml" KUBERNETES_CLIENT.apply_manifest_from_file(nfd_file) - nic_file = f"{config_dir}/net/nic-cluster-policy.yaml" + nic_file = f"{config_dir}/network-operator/nic-cluster-policy.yaml" KUBERNETES_CLIENT.apply_manifest_from_file(nic_file) execute_with_retries( KUBERNETES_CLIENT.wait_for_pods_ready, diff --git a/modules/python/gpu/pkg/utils.py b/modules/python/gpu/pkg/utils.py index bf600d8ba5..b3eb8fd1fc 100644 --- a/modules/python/gpu/pkg/utils.py +++ b/modules/python/gpu/pkg/utils.py @@ -265,12 +265,22 @@ def create_topology_configmap( # Create ConfigMap configmap_name = "nvidia-topology" + namespace = "mpi-operator" + + # Delete existing ConfigMap if it exists + try: + v1_api.delete_namespaced_config_map(name=configmap_name, namespace=namespace) + logger.info(f"Deleted existing ConfigMap '{configmap_name}'") + except client.ApiException as e: + if e.status != 404: + logger.warning(f"Error deleting ConfigMap: {e}") + logger.info(f"Creating ConfigMap from content:\n{topology_content}") configmap = client.V1ConfigMap( metadata=client.V1ObjectMeta(name=configmap_name), data={"topo.xml": topology_content}, ) - v1_api.create_namespaced_config_map(namespace="default", body=configmap) + v1_api.create_namespaced_config_map(namespace=namespace, body=configmap) logger.info(f"ConfigMap '{configmap_name}' created successfully") except requests.RequestException as e: diff --git a/modules/python/tests/gpu/test_gpu.py b/modules/python/tests/gpu/test_gpu.py index bcbf046efe..f4ae74a626 100644 --- a/modules/python/tests/gpu/test_gpu.py +++ b/modules/python/tests/gpu/test_gpu.py @@ -221,13 +221,17 @@ def test_install_mpi_operator_success( self, mock_k8s_client, _mock_execute_with_retries ): """Test successful MPI operator installation.""" - mock_k8s_client.apply_manifest_from_url.return_value = None _mock_execute_with_retries.return_value = None + mock_k8s_client.apply_manifest_from_url.return_value = None - install_mpi_operator(chart_version=self.test_chart_version) + install_mpi_operator( + chart_version=self.test_chart_version + ) + # Verify the manifest is applied from the correct URL expected_url = f"https://raw.githubusercontent.com/kubeflow/mpi-operator/{self.test_chart_version}/deploy/v2beta1/mpi-operator.yaml" mock_k8s_client.apply_manifest_from_url.assert_called_once_with(expected_url) + # Verify execute_with_retries is called once for the wait operation _mock_execute_with_retries.assert_called_once() @@ -285,7 +289,9 @@ def test_configure_all_operators(self, mock_network, mock_gpu, mock_mpi, mock_ef install_driver=True, enable_nfd=False, ) - mock_mpi.assert_called_once_with(chart_version=self.test_chart_version) + mock_mpi.assert_called_once_with( + chart_version=self.test_chart_version + ) @patch("gpu.main.install_efa_operator") @patch("gpu.main.install_mpi_operator") @@ -338,7 +344,9 @@ def test_configure_both_network_and_mpi_operator( chart_version=self.test_chart_version, config_dir=self.test_config_dir ) mock_gpu.assert_not_called() - mock_mpi.assert_called_once_with(chart_version=self.test_chart_version) + mock_mpi.assert_called_once_with( + chart_version=self.test_chart_version + ) @patch("gpu.main.install_efa_operator") @patch("gpu.main.install_mpi_operator")