Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
namespace: default
namespace: mpi-operator
name: nccl-tests
labels:
app: nccl-tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
namespace: default
namespace: mpi-operator
name: nccl-tests
labels:
app: nccl-tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
namespace: default
namespace: mpi-operator
name: nccl-tests
labels:
app: nccl-tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
namespace: default
namespace: mpi-operator
name: nccl-tests
labels:
app: nccl-tests
Expand Down
11 changes: 6 additions & 5 deletions modules/python/gpu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions modules/python/gpu/pkg/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Comment thread
anson627 marked this conversation as resolved.
Resolved
label_selector="app=mpi-operator",
namespace="mpi-operator",
operation_timeout_in_minutes=5,
)
4 changes: 2 additions & 2 deletions modules/python/gpu/pkg/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion modules/python/gpu/pkg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 12 additions & 4 deletions modules/python/tests/gpu/test_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down