Skip to content
Open
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
6 changes: 6 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ jobs:
platforms: linux/amd64
runner: [self-hosted, linux/amd64, rocm]
build_args: "NUM_MAKE_JOBS=2"
- name: rocm10.3.0
dockerfile: rocm10.3.0
tags: superbench/main:rocm10.3.0
platforms: linux/amd64
runner: [self-hosted, linux/amd64, rocm]
build_args: "NUM_MAKE_JOBS=2"
steps:
- name: Checkout
uses: actions/checkout@0717577d45739eb3c851188b29f50ed6c0b2194e # v2.8.0
Expand Down
264 changes: 264 additions & 0 deletions dockerfile/rocm10.3.0.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
ARG BASE_IMAGE=ubuntu:24.04
FROM ${BASE_IMAGE}

# AMD publishes ROCm 10.3 as nightlies. Install the matching SDK and
# PyTorch 2.15 wheels together on Ubuntu 24.04 with Python 3.12.
LABEL maintainer="SuperBench"

ARG DEBIAN_FRONTEND=noninteractive
ARG DOCKER_VERSION=29.6.2
ARG NUM_MAKE_JOBS=16

ENV MPI_HOME=/usr/local/mpi

SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]

# Use the DOCA 3.4 userspace and Open MPI 5 stack from PR #867, packaged for Ubuntu 24.04.
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl && \
doca_repo="https://linux.mellanox.com/public/repo/doca/3.4.0/ubuntu24.04/x86_64" && \
curl -fsSL "${doca_repo}/doca_keyring.gpg" -o /usr/share/keyrings/doca_keyring.gpg && \
printf '%s\n' '2367ec42f81ddf785040cc410b03d861d9eb2c75c35ff859d98ce4494944f4e0 /usr/share/keyrings/doca_keyring.gpg' | \
sha256sum --check --strict && \
printf 'deb [signed-by=/usr/share/keyrings/doca_keyring.gpg] %s ./\n' "${doca_repo}" > /etc/apt/sources.list.d/doca.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
autoconf \
automake \
bc \
build-essential \
cmake \
dmidecode \
doca-ofed-userspace=3.4.0-085000 \
file \
flex \
git \
iproute2 \
jq \
kmod \
libaio-dev \
libboost-program-options-dev \
libcurl4-openssl-dev \
libdw1t64 \
libelf1t64 \
libgfortran5 \
libncurses6 \
libnuma-dev \
libpci-dev \
libquadmath0 \
libssl-dev \
libtool \
libunwind8 \
lshw \
net-tools \
ninja-build \
numactl \
openmpi=5.0.10rc2.2605121430-1.b99be7132e \
openssh-client \
openssh-server \
pciutils \
python-is-python3 \
python3-dev \
python3-venv \
rsync \
sudo \
util-linux \
vim \
wget && \
mpi_prefix="$(dpkg-query -L openmpi | sed -n 's#/bin/mpirun$##p')" && \
test -n "${mpi_prefix}" && \
test -x "${mpi_prefix}/bin/mpicxx" && \
ln -sT "${mpi_prefix}" "${MPI_HOME}" && \
printf '%s\n' "${MPI_HOME}/lib" > /etc/ld.so.conf.d/superbench-mpi.conf && \
ldconfig && \
"${MPI_HOME}/bin/mpirun" --version && \
rm -rf /var/lib/apt/lists/*

# SuperBench uses only the Docker client, against a host or remote daemon.
RUN curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz" -o /tmp/docker.tgz && \
tar --extract --file /tmp/docker.tgz --strip-components 1 --directory /usr/local/bin/ docker/docker && \
rm /tmp/docker.tgz

# Configure SSH and file descriptor limits for benchmark workers.
RUN mkdir -p /root/.ssh /var/run/sshd && \
touch /root/.ssh/authorized_keys && \
sed -i "s/[# ]*PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config && \
sed -i "s/[# ]*PermitUserEnvironment no/PermitUserEnvironment yes/" /etc/ssh/sshd_config && \
sed -i "s/[# ]*Port.*/Port 22/" /etc/ssh/sshd_config && \
printf '%s\n' '* soft nofile 1048576' '* hard nofile 1048576' \
'root soft nofile 1048576' 'root hard nofile 1048576' >> /etc/security/limits.conf

# Install Intel MLC.
RUN curl -fsSL https://downloadmirror.intel.com/926327/mlc_v3.13.tgz -o /tmp/mlc.tgz && \
printf '%s\n' 'a8537e8ff3fad626d75a383fabc224ccc4cc98a0111c9989f7fb26b639f12019 /tmp/mlc.tgz' | sha256sum -c - && \
tar -xzf /tmp/mlc.tgz -C /tmp Linux/mlc && \
install -m 755 /tmp/Linux/mlc /usr/local/bin/ && \
rm -rf /tmp/Linux /tmp/mlc.tgz

# Target MI455X by default. Override with a space-separated list of GPU targets.
ARG AMDGPU_TARGETS="gfx1250"
ENV ROCM_PATH=/opt/rocm \
EXTRAS_PATH=/opt/rocm-extras \
SB_HOME=/opt/superbench \
SB_MICRO_PATH=/opt/superbench \
SB_MEGATRON_PATH=/opt/rocm10-frameworks/Megatron-LM \
AMDGPU_TARGETS="${AMDGPU_TARGETS}" \
AITER_USE_SYSTEM_TRITON=1 \
USE_HIP_DATATYPE=1 \
USE_HIPBLAS_COMPUTETYPE=1 \
ANSIBLE_DEPRECATION_WARNINGS=FALSE \
ANSIBLE_COLLECTIONS_PATH=/usr/share/ansible/collections

# Use a venv so pip does not replace Ubuntu-managed Python packages.
ARG ROCM_VERSION=10.3.0a20261201
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
RUN python3 -m venv "${VIRTUAL_ENV}" && \
python3 -m pip install --no-cache-dir \
--index-url https://nightly.repo.amd.com/rocm/whl-next/ --extra-index-url https://pypi.org/simple \
"rocm[devel,device-all]==${ROCM_VERSION}" "torch[device-all]==2.15.0+rocm${ROCM_VERSION}" \
"torchvision[device-all]==0.29.2+rocm${ROCM_VERSION}" "torchaudio==2.11.1+rocm${ROCM_VERSION}" \
"apex==1.15.0+rocm${ROCM_VERSION}" && \
rocm-sdk init && \
rocm_root="$(rocm-sdk path --root)" && \
if [ "$(rocm-sdk version)" != "${ROCM_VERSION}" ]; then \
printf 'The benchmark binaries require ROCm SDK %s.\n' "${ROCM_VERSION}" >&2; exit 1; \
fi && \
if [ ! -x "${rocm_root}/bin/hipcc" ] || [ ! -x "${rocm_root}/bin/hipify-perl" ]; then \
printf 'ROCm SDK development tools not found under %s\n' "${rocm_root}" >&2; exit 1; \
fi && \
ln -sfnT "${rocm_root}" "${ROCM_PATH}"

ENV CMAKE_PREFIX_PATH="${ROCM_PATH}" \
PATH="${MPI_HOME}/bin:${SB_MICRO_PATH}/bin:${EXTRAS_PATH}/bin:${ROCM_PATH}/bin:${PATH}" \
LD_LIBRARY_PATH="${MPI_HOME}/lib:${EXTRAS_PATH}/lib:${ROCM_PATH}/lib:${ROCM_PATH}/lib/llvm/lib:${ROCM_PATH}/lib/host-math/lib:${ROCM_PATH}/lib/rocm_sysdeps/lib:/usr/local/lib"

RUN printf '%s\n' "PATH=${PATH}" "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" "ROCM_PATH=${ROCM_PATH}" \
"EXTRAS_PATH=${EXTRAS_PATH}" "SB_MICRO_PATH=${SB_MICRO_PATH}" "SB_MEGATRON_PATH=${SB_MEGATRON_PATH}" \
"AITER_USE_SYSTEM_TRITON=${AITER_USE_SYSTEM_TRITON}" > /etc/environment

WORKDIR ${SB_HOME}

# Use AMD's ROCm Extras tarball with the wheel SDK instead of installing a second ROCm stack.
ARG RVS_VERSION=1.8.28-r1003.20261201
ARG RVS_SHA256=7c672bb82c8bdeca15103b30aafa2be5c22ec45ca88df15c45eec846f1a7b56b
RUN curl -fsSL "https://nightly.repo.amd.com/rocm/extras/rvs/tarball/amdrocm10-rvs-${RVS_VERSION}-Linux.tar.gz" -o /tmp/rvs.tar.gz && \
printf '%s %s\n' "${RVS_SHA256}" /tmp/rvs.tar.gz | sha256sum --check --strict && \
mkdir -p "${EXTRAS_PATH}" && \
tar -xzf /tmp/rvs.tar.gz -C "${EXTRAS_PATH}" && \
rm /tmp/rvs.tar.gz && \
rvs --version && \
test -x "${EXTRAS_PATH}/bin/TransferBench"

# The clients also need the test kernel packs, relative to their install prefix.
ARG ROCM_TESTS_SHA256=d7cdf4f4107c2fe90081c01d831056d55cfb96dda19d3f6f41964acbfadfb1b3
RUN curl -fsSL "https://nightly.repo.amd.com/rocm/core/tarball/therock-dist-linux-multiarch-tests-${ROCM_VERSION}.tar.gz" -o /tmp/rocm-tests.tar.gz && \
printf '%s %s\n' "${ROCM_TESTS_SHA256}" /tmp/rocm-tests.tar.gz | sha256sum --check --strict && \
tar -xzf /tmp/rocm-tests.tar.gz -C "${SB_MICRO_PATH}" --wildcards --no-wildcards-match-slash \
'./bin/rocblas-bench' './bin/hipblaslt-bench' './.kpack/blas_test_*.kpack' && \
rm /tmp/rocm-tests.tar.gz && \
read -r -a architectures <<< "${AMDGPU_TARGETS}" && \
for arch in "${architectures[@]}"; do \
if [ ! -s "${SB_MICRO_PATH}/.kpack/blas_test_${arch}.kpack" ]; then \
printf 'The ROCm %s BLAS clients have no test kernel pack for %s.\n' "${ROCM_VERSION}" "${arch}" >&2; exit 1; \
fi; \
done && \
for client in rocblas-bench hipblaslt-bench; do \
if ! linkage="$(ldd -r "${SB_MICRO_PATH}/bin/${client}" 2>&1)" || \
grep -Eq 'not found|undefined symbol' <<< "${linkage}"; then \
printf '%s\n' "${linkage}" >&2; exit 1; \
fi; \
done

# Use the rocm-systems revision from the SDK's nightly build manifest.
ARG ROCM_SYSTEMS_COMMIT=68bd96c6d640e7c94bdcceefbf3ecb8038f2f866
RUN read -r -a architectures <<< "${AMDGPU_TARGETS}" && \
if [ "${#architectures[@]}" -eq 0 ]; then \
printf 'AMDGPU_TARGETS must contain at least one GPU architecture.\n' >&2; exit 1; \
fi && \
gpu_targets="$(IFS=';'; printf '%s' "${architectures[*]}")" && \
git init -q /tmp/rocm-systems && \
git -C /tmp/rocm-systems remote add origin https://github.com/ROCm/rocm-systems.git && \
git -C /tmp/rocm-systems sparse-checkout set projects/rccl-tests && \
git -C /tmp/rocm-systems fetch -q --depth 1 --filter=blob:none origin "${ROCM_SYSTEMS_COMMIT}" && \
git -C /tmp/rocm-systems checkout -q --detach FETCH_HEAD && \
cmake -S /tmp/rocm-systems/projects/rccl-tests -B /tmp/rccl-tests-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${ROCM_PATH};${MPI_HOME}" \
-DROCM_PATH="${ROCM_PATH}" -DGPU_TARGETS="${gpu_targets}" \
-DUSE_MPI=ON -DBUILD_RCCL_TESTS_HOST_UNIT_TESTS=OFF \
-DMPI_CXX_COMPILER="${MPI_HOME}/bin/mpicxx" \
-DCMAKE_INSTALL_PREFIX="${SB_MICRO_PATH}" && \
cmake --build /tmp/rccl-tests-build --parallel "${NUM_MAKE_JOBS}" && \
cmake --install /tmp/rccl-tests-build && \
linkage="$(ldd "${SB_MICRO_PATH}/bin/all_reduce_perf")" && \
grep -F "${ROCM_PATH}/lib/librccl.so" <<< "${linkage}" && \
grep -F "${MPI_HOME}/lib/libmpi.so" <<< "${linkage}" && \
rm -rf /tmp/rocm-systems /tmp/rccl-tests-build

COPY . .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that ee2a7a19 adds rocm10.3.0 (NUM_MAKE_JOBS=2) to build-image.yml, placing COPY . . ahead of the TransformerEngine / aiter / Megatron-LM source build (lines 227–255) means every PR in the repository will invalidate layer cache here and recompile those frameworks on the shared self-hosted ROCm runners.

Could we move the TransformerEngine / aiter / Megatron-LM build (along with /tmp/rocm-constraints.txt and CPLUS_INCLUDE_PATH) above COPY . . so unrelated PRs can reuse the cached framework layers?


# Keep hipBusBandwidth for SuperBench's current mem-bw backend.
# The pinned HIP sample uses assert without including cassert itself.
RUN make -C third_party fio rocm_perftest && \
CXX="${ROCM_PATH}/bin/hipcc" CXXFLAGS="-include cassert" \
make -C third_party rocm_bandwidthTest ROCM_VER=rocm-5.5.0 && \
for binary in fio ib_write_bw hipBusBandwidth; do \
if [ ! -x "${SB_MICRO_PATH}/bin/${binary}" ]; then \
printf 'Missing benchmark %s; ensure Git submodules are initialized.\n' "${binary}" >&2; exit 1; \
fi; \
done

# Use amd-smi from the SDK to match its native library; the cpuworker extra
# installs the same PyTorch dependencies as amdworker without a second amd-smi.
RUN site_packages="$(python3 -c 'import sysconfig; print(sysconfig.get_path("purelib"))')" && \
printf '%s\n' "${ROCM_PATH}/share/amd_smi" > "${site_packages}/superbench-amdsmi.pth" && \
python3 -m pip freeze | grep -Ei '^(amd-(torch|torchvision)[^=]*|apex|rocm[^=]*|torch|torchaudio|torchvision|triton)==' \
> /tmp/rocm-constraints.txt && \
python3 -m pip install --no-cache-dir -c /tmp/rocm-constraints.txt '.[cpuworker]' && \
python3 -c 'import amdsmi, torch, torchvision; assert torch.version.hip, "Expected the base image ROCm PyTorch build"'

# hipCUB needs the SDK's libhipcxx headers for both wheel builds and JIT extensions.
ENV CPLUS_INCLUDE_PATH="${ROCM_PATH}/include/hipccl"

# Build the training components against the pinned wheels. The CK and AOTriton
# attention backends at this Transformer Engine revision do not target gfx1250.
# Check package metadata rather than importing AITER, which requires a visible GPU.
ARG TE_COMMIT=e7835ed1b134f56e58c575fba2455471064cab9b
ARG AITER_COMMIT=04896172e283ecc389f0dfff6479c3379ed63fa1
ARG MEGATRON_COMMIT=4b4acac9a1d28ea6829c8d4f566d75698a21249d
RUN read -r -a architectures <<< "${AMDGPU_TARGETS}" && \
gpu_targets="$(IFS=';'; printf '%s' "${architectures[*]}")" && \
export NVTE_USE_ROCM=1 NVTE_FRAMEWORK=pytorch NVTE_ROCM_ARCH="${gpu_targets}" NVTE_NO_LOCAL_VERSION=1 \
NVTE_FUSED_ATTN_CK=0 NVTE_FUSED_ATTN_AOTRITON=0 PREBUILD_KERNELS=0 BUILD_TARGET=rocm \
GPU_ARCHS="${gpu_targets}" MAX_JOBS="${NUM_MAKE_JOBS}" NVTE_BUILD_MAX_JOBS="${NUM_MAKE_JOBS}" \
CMAKE_BUILD_PARALLEL_LEVEL="${NUM_MAKE_JOBS}" PIP_CONSTRAINT=/tmp/rocm-constraints.txt && \
python3 -m pip install --no-cache-dir \
importlib-metadata==10.2.0 packaging==26.4 setuptools==84.2.1 setuptools-scm==10.3.4 \
wheel==0.48.0 ninja==1.13.0 pybind11==3.0.1 pydantic==2.13.5 einops==0.8.2 psutil==7.2.2 \
mpi4py==4.1.1 flydsl==0.3.4.1 pandas==3.0.5 nvdlfw-inspect==0.2.2 \
onnxscript==0.7.2 onnx-ir==1.0.0 onnx==1.23.1 ml_dtypes==0.6.0 && \
for source in "ROCm/TransformerEngine v2.15_rocm ${TE_COMMIT} /tmp/rocm-frameworks/TransformerEngine" \
"ROCm/aiter v0.1.24.post1 ${AITER_COMMIT} /tmp/rocm-frameworks/aiter" \
"NVIDIA/Megatron-LM core_v0.19.2 ${MEGATRON_COMMIT} ${SB_MEGATRON_PATH}"; do \
read -r repo tag commit checkout <<< "${source}" && \
git -c advice.detachedHead=false clone -q --depth 1 --branch "${tag}" "https://github.com/${repo}.git" "${checkout}" && \
if [ "$(git -C "${checkout}" rev-parse HEAD)" != "${commit}" ]; then \
printf 'Unexpected revision for %s:%s (expected %s).\n' "${repo}" "${tag}" "${commit}" >&2; exit 1; \
fi && \
git -C "${checkout}" submodule update -q --init --recursive --depth 1 || exit 1; \
done && \
python3 -m pip wheel --no-cache-dir --no-build-isolation --no-deps -w /tmp/rocm-wheels \
/tmp/rocm-frameworks/TransformerEngine /tmp/rocm-frameworks/aiter "${SB_MEGATRON_PATH}" && \
python3 -m pip install --no-cache-dir --no-deps /tmp/rocm-wheels/*.whl && \
python3 -c 'from importlib.metadata import version; print(*(f"{p}=={version(p)}" for p in ("amd-aiter", "megatron-core", "transformer-engine")), sep="\n")' && \
rm -rf /tmp/rocm-frameworks /tmp/rocm-wheels

RUN python3 -m pip check && \
python3 -m pip freeze | grep -Ei '^(amd-(torch|torchvision)[^=]*|apex|rocm[^=]*|torch|torchaudio|torchvision|triton)==' | \
diff -u /tmp/rocm-constraints.txt - && \
rm /tmp/rocm-constraints.txt && \
CXX="${ROCM_PATH}/bin/hipcc" make cppbuild && \
make postinstall && \
printf 'CPLUS_INCLUDE_PATH=%s\n' "${CPLUS_INCLUDE_PATH}" >> /etc/environment && \
rm -rf .git
49 changes: 49 additions & 0 deletions docs/developer-guides/using-docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,55 @@ docker buildx build \
--tag superbench-dev --file dockerfile/rocm5.7.x.dockerfile .
```

For ROCm 10.3, the image pins AMD's `10.3.0a20261201` nightly SDK and matching
PyTorch 2.15.0 wheels on Ubuntu 24.04 with Python 3.12. This is not a stable
ROCm release. Build from the repository root on `linux/amd64`:

```bash
docker buildx build \
--platform linux/amd64 --load \
--tag superbench-dev --file dockerfile/rocm10.3.0.dockerfile .
```

The Build Image workflow builds this image on the AMD64 ROCm runner for pull
requests without publishing it. Builds on `main` publish `superbench/main:rocm10.3.0`.

The native benchmarks target `gfx1250` (MI455X) by default. The host must have
an AMD GPU driver and firmware that support MI455X. To build for MI300X
instead, pass `--build-arg AMDGPU_TARGETS=gfx942`.

The image uses DOCA-OFED 3.4.0 userspace and Open MPI 5.0.10rc2, as in
[#867](https://github.com/microsoft/superbenchmark/pull/867). The host supplies
the kernel drivers. The image uses the SDK's RCCL and builds its matching
RCCL tests with MPI support.

The image includes `rocblas-bench` and `hipblaslt-bench` for `gemm-flops` and
`hipblaslt-gemm`. The build downloads AMD's multiarch test archive (about 20 GB)
but keeps only the two clients and their kernel packs. It also includes the
ROCm Validation Suite (`rvs`) and standalone `TransferBench`. SuperBench's
`mem-bw` still uses `hipBusBandwidth`; the optional TransferBench backend is
tracked in [#868](https://github.com/microsoft/superbenchmark/pull/868).

The training stack includes Transformer Engine 2.15, AITER from v0.1.24.post1,
and Megatron Core 0.19.2 built against the pinned PyTorch wheels. To use the
bundled checkout with `megatron-gpt`, set `code_base` to
`/opt/rocm10-frameworks/Megatron-LM` in the benchmark parameters and use `mpi`
mode with one process per node. Set `num_gpus` to the number of GPUs per node.
For an offline BF16 run, set the following benchmark parameters. Keep the
single quotes inside `extra` so the executor passes the flags as one argument:

```yaml
parameters:
mock_data: true
tokenizer_type: NullTokenizer
transformer_impl: transformer_engine
extra: >-
'--vocab-size 8192 --attention-backend unfused --disable-bias-linear'
```

The selected Transformer Engine revision does not provide CK or AOTriton fused
attention for `gfx1250`.

</TabItem>
</Tabs>

Expand Down
5 changes: 4 additions & 1 deletion superbench/benchmarks/model_benchmarks/megatron_gpt3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import json
import os
import shlex
import statistics
import numpy as np
import requests
Expand Down Expand Up @@ -217,7 +218,7 @@ def add_parser_arguments(self):
'--hostfile', type=str, default=None, help='Hostfile to run the mutli-node benchmark.'
)
self._parser.add_argument('--deepspeed', action='store_true', help='Use deepspeed.')
self._parser.add_argument('--extra', type=str, default=None, help='Extra options for Megatron.')
self._parser.add_argument('--extra', type=shlex.split, default=None, help='Extra options for Megatron.')
self._parser.add_argument(
'--model',
type=str,
Expand Down Expand Up @@ -540,6 +541,8 @@ def _megatron_command(self, precision): # noqa: C901
else:
command = f'torchrun {self._distributed_args} {script_path} {megatron_options} {self._data_options}'

if self._args.extra:
command += ' ' + ' '.join(map(shlex.quote, self._args.extra))
return command

def _train_step(self, precision): # noqa: E501
Expand Down
18 changes: 18 additions & 0 deletions tests/benchmarks/model_benchmarks/test_megatron_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,24 @@ def test_megatron_gpt_command(self, mock_generate_dataset):
expected_units = normalize_command(expected_command)
self.assertEqual(actual_units, expected_units)

def test_megatron_extra_options(self):
"""Forward quoted options for the bundled Megatron version and reject invalid quoting."""
(benchmark_cls, _) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(self.benchmark_name, Platform.ROCM)
Path(self._tmp_dir, 'pretrain_gpt.py').touch()
parameters = f'--code_base {self._tmp_dir} --mock_data --num_gpus 1'
extra = '--vocab-size 128 --attention-backend unfused --load "a checkpoint path"'
mpi_env = {'OMPI_COMM_WORLD_SIZE': '1', 'OMPI_COMM_WORLD_LOCAL_SIZE': '1', 'OMPI_COMM_WORLD_RANK': '0'}
with mock.patch.dict(os.environ, mpi_env):
benchmark = benchmark_cls(self.benchmark_name, parameters=f'{parameters} --extra={shlex.quote(extra)}')
self.assertTrue(benchmark._preprocess())
command = benchmark._megatron_command(Precision.BFLOAT16)
self.assertEqual(shlex.split(command)[-6:], shlex.split(extra))

invalid = shlex.quote('--load "unterminated')
benchmark = benchmark_cls(self.benchmark_name, parameters=f'{parameters} --extra={invalid}')
self.assertFalse(benchmark._preprocess())
self.assertEqual(benchmark.return_code, ReturnCode.INVALID_ARGUMENT)

def test_deepseek_v2_command(self):
"""Test v2 command."""
# test deepspeed with megatron
Expand Down
Loading