Skip to content
Closed
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
56 changes: 55 additions & 1 deletion benchmarks/single_node/fixed_seq_len/minimaxm3_fp4_b300.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# MiniMax-M3 NVFP4 B300 single-node vLLM recipe.
# Same shape as minimaxm3_fp8_b300.sh but uses the nvidia/MiniMax-M3-NVFP4
# checkpoint. MiniMax-M3 modelopt NVFP4 support (vllm-project/vllm PR #46380) is
# baked into the perf container image, so no runtime patch is needed.
# baked into the perf container image.
#
# At runtime the recipe swaps the image's FlashInfer for the pinned nightly
# release and applies the CuTeDSL split-K gemm patch on top, mirroring vLLM
# commits 82a00090a (nightly install) and 0a16bea6b (patch). It also patches
# the installed vLLM with the VLLM_MINIMAX_M3_BF16_ROUTER_GEMM knob (bf16
# router gate weights, cuBLAS bf16 x bf16 -> fp32 logits) and enables it.

source "$(dirname "$0")/../../benchmark_lib.sh"

Expand All @@ -19,6 +25,51 @@ check_env_vars \
RANDOM_RANGE_RATIO \
RESULT_FILENAME

# --- FlashInfer nightly + CuTeDSL split-K gemm patch -------------------------
# Pinned to nightly release nightly-v0.6.14-20260702. The wheels are not yet on
# the flashinfer.ai/whl/nightly flat index, so install by direct release URL.
FLASHINFER_VERSION=0.6.14.dev20260702
FLASHINFER_NIGHTLY_TAG=nightly-v0.6.14-20260702
FLASHINFER_RELEASE_URL="https://github.com/flashinfer-ai/flashinfer/releases/download/${FLASHINFER_NIGHTLY_TAG}"

# The flashinfer-jit-cache wheel is CUDA-version-specific; derive cuXYZ from
# the torch build inside the container (e.g. 13.0 -> cu130).
CUDA_MAJOR_MINOR="cu$(python3 -c 'import torch; print(torch.version.cuda.replace(".", ""))')" \
|| { echo "Failed to determine CUDA version from torch" >&2; exit 1; }

python3 -m pip uninstall -y flashinfer-python flashinfer-cubin flashinfer-jit-cache

python3 -m pip install --pre \
"${FLASHINFER_RELEASE_URL}/flashinfer_python-${FLASHINFER_VERSION}-py3-none-any.whl" \
"${FLASHINFER_RELEASE_URL}/flashinfer_cubin-${FLASHINFER_VERSION}-py3-none-any.whl" \
"${FLASHINFER_RELEASE_URL}/flashinfer_jit_cache-${FLASHINFER_VERSION}+${CUDA_MAJOR_MINOR}-cp39-abi3-manylinux_2_28_$(uname -m).whl" \
|| { echo "FlashInfer nightly install failed" >&2; exit 1; }

# Apply CuTeDSL split-K gemm patch (jiahanc/flashinfer branch cutedsl-splitK,
# flashinfer/gemm changes only) on top of the pinned nightly. The reinstall
# above guarantees pristine files, so the patch always applies cleanly.
FLASHINFER_PATCH="$(dirname "$0")/patches/flashinfer-cutedsl-splitk-gemm.patch"
if ! command -v patch >/dev/null 2>&1; then
apt-get update -y && apt-get install -y --no-install-recommends patch \
|| { echo "Failed to install patch(1)" >&2; exit 1; }
fi
SITE_PACKAGES=$(dirname "$(python3 -c "import importlib.util; print(importlib.util.find_spec('flashinfer').submodule_search_locations[0])")") \
|| { echo "Could not locate the installed flashinfer package" >&2; exit 1; }
patch -p1 -d "${SITE_PACKAGES}" < "$FLASHINFER_PATCH" \
|| { echo "FlashInfer CuTeDSL split-K gemm patch failed" >&2; exit 1; }

# Patch the installed vLLM with the VLLM_MINIMAX_M3_BF16_ROUTER_GEMM knob
# (bf16 router gate weights + cuBLAS bf16 x bf16 -> fp32 router logits).
# vLLM is not reinstalled above, so guard against re-applying on reruns.
VLLM_ROUTER_PATCH="$(dirname "$0")/patches/minimax-m3-bf16-router-gemm.patch"
if patch -R -p1 -s -f --dry-run -d "${SITE_PACKAGES}" < "$VLLM_ROUTER_PATCH" >/dev/null 2>&1; then
echo "[minimax-m3-bf16-router-gemm] already applied"
else
patch -p1 -d "${SITE_PACKAGES}" < "$VLLM_ROUTER_PATCH" \
|| { echo "MiniMax M3 bf16 router gemm patch failed" >&2; exit 1; }
fi
# -----------------------------------------------------------------------------

if [[ -n "${MODEL_PATH:-}" ]]; then
if [[ ! -d "$MODEL_PATH" || -z "$(ls -A "$MODEL_PATH" 2>/dev/null)" ]]; then
hf download "$MODEL" --local-dir "$MODEL_PATH"
Expand All @@ -38,7 +89,9 @@ SERVER_LOG=/workspace/server.log

export VLLM_ENGINE_READY_TIMEOUT_S=3600
export VLLM_FLOAT32_MATMUL_PRECISION=high
export VLLM_MINIMAX_M3_BF16_ROUTER_GEMM=1
export VLLM_FLASHINFER_ALLREDUCE_BACKEND=trtllm
export VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=1800

if [ "${DP_ATTENTION}" = "true" ]; then
PARALLEL_ARGS="--tensor-parallel-size=1 --data-parallel-size=$TP --enable-expert-parallel"
Expand All @@ -57,6 +110,7 @@ start_gpu_monitor
set -x
vllm serve "$MODEL_PATH" --served-model-name "$MODEL" --host 0.0.0.0 --port $PORT \
$PARALLEL_ARGS \
--attention_config.indexer_kv_dtype fp8 \
--gpu-memory-utilization 0.95 \
--max-model-len $MAX_MODEL_LEN \
--kv-cache-dtype fp8 \
Expand Down
Loading
Loading