---
apiVersion: kubeflow.org/v2beta1
kind: MPIJob
metadata:
name: nccl-test-rocex
spec:
slotsPerWorker: 8
launcherCreationPolicy: WaitForWorkersReady
runPolicy:
cleanPodPolicy: Running
# Mount MPI Operator's SSH key where the user actually is.
# We run as root, so point to /root/.ssh
sshAuthMountPath: /root/.ssh
mpiReplicaSpecs:
Launcher:
replicas: 1
template:
spec:
restartPolicy: OnFailure
containers:
- name: mpi-launcher
image: nvcr.io/nvidia/pytorch:26.04-py3
securityContext:
runAsUser: 0
env:
- name: OMPI_ALLOW_RUN_AS_ROOT
value: "1"
- name: OMPI_ALLOW_RUN_AS_ROOT_CONFIRM
value: "1"
command: ["/bin/bash","-lc"]
# The Spectrum-X plugin (spcx) and its library ship in the
# PyTorch NGC image under /opt/hpcx. The -x flags below are the
# validated Spectrum-X NCCL tuning; align NCCL_IB_HCA only if your
# RoCE device prefix differs from roce_.
args:
- >
mpirun --allow-run-as-root
--mca plm_rsh_args "-p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
--bind-to core --map-by ppr:8:node
-np 16
-x NCCL_DEBUG=INFO
-x NCCL_DEBUG_SUBSYS=INIT,NET
-x NCCL_NET_PLUGIN=spcx
-x LD_LIBRARY_PATH=/opt/hpcx/nccl_spectrum-x_plugin/lib:/usr/local/lib:$LD_LIBRARY_PATH
-x NCCL_IB_HCA=roce_
-x NCCL_SOCKET_IFNAME=eth0
-x UCX_TLS=tcp
-x NCCL_IB_TC=96
-x NCCL_CROSS_NIC=0
-x NCCL_IB_MERGE_NICS=0
-x NCCL_NET_MERGE_LEVEL=PIX
-x NCCL_NCHANNELS_PER_NET_PEER=4
-x NCCL_P2P_NET_CHUNKSIZE=262144
/usr/local/bin/all_reduce_perf_mpi -b 8 -e 8G -f 2 -g 1 -w 2 --iters 4 -c 10
volumeMounts:
- name: dshm
mountPath: /dev/shm
volumes:
- name: dshm
emptyDir:
medium: Memory
Worker:
replicas: 2
template:
metadata:
annotations:
# Spectrum-X twin-planar RoCE networks (align to site config)
k8s.v1.cni.cncf.io/networks: "r0-p0,r0-p1,r1-p0,r1-p1,r2-p0,r2-p1,r3-p0,r3-p1,r4-p0,r4-p1,r5-p0,r5-p1,r6-p0,r6-p1,r7-p0,r7-p1"
spec:
restartPolicy: OnFailure
containers:
- name: mpi-worker
image: nvcr.io/nvidia/pytorch:26.04-py3
# Root to install/run sshd, generate host keys & read /etc/ssh/*.
# The PyTorch NGC image does not ship an SSH server, so install
# openssh-server at runtime before starting sshd for MPI launch.
securityContext:
runAsUser: 0
capabilities:
add: ["NET_ADMIN","NET_RAW","IPC_LOCK","SYS_RESOURCE"]
command: ["/bin/bash","-lc"]
args:
- >
apt-get update -qq &&
apt-get install -y -q openssh-server &&
mkdir -p /run/sshd &&
ssh-keygen -A &&
exec /usr/sbin/sshd -De -p 2222 -o StrictModes=no
resources:
limits:
nvidia.com/gpu: 8
nvidia.com/r0-p0: "1"
nvidia.com/r0-p1: "1"
nvidia.com/r1-p0: "1"
nvidia.com/r1-p1: "1"
nvidia.com/r2-p0: "1"
nvidia.com/r2-p1: "1"
nvidia.com/r3-p0: "1"
nvidia.com/r3-p1: "1"
nvidia.com/r4-p0: "1"
nvidia.com/r4-p1: "1"
nvidia.com/r5-p0: "1"
nvidia.com/r5-p1: "1"
nvidia.com/r6-p0: "1"
nvidia.com/r6-p1: "1"
nvidia.com/r7-p0: "1"
nvidia.com/r7-p1: "1"
volumeMounts:
- name: dshm
mountPath: /dev/shm
volumes:
- name: dshm
emptyDir:
medium: Memory