|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# This source code is licensed under the BSD-style license found in the |
| 6 | +# LICENSE file in the root directory of this source tree. |
| 7 | + |
| 8 | +set -euo pipefail |
| 9 | + |
| 10 | +ROCM_VERSION="${ROCM_VERSION:-7.1}" |
| 11 | +ROCM_PATH="${ROCM_PATH:-/opt/rocm}" |
| 12 | +PYTORCH_ROCM_INDEX="${PYTORCH_ROCM_INDEX:-https://download.pytorch.org/whl/test/rocm${ROCM_VERSION}}" |
| 13 | +TORCHAO_ROCM_WHEEL_BASE="${TORCHAO_ROCM_WHEEL_BASE:-https://download.pytorch.org/whl/nightly/rocm${ROCM_VERSION}}" |
| 14 | +VOXTRAL_CI_TMP_ROOT="${RUNNER_TEMP:-/tmp}" |
| 15 | +mkdir -p "${VOXTRAL_CI_TMP_ROOT}" 2>/dev/null || VOXTRAL_CI_TMP_ROOT=/tmp |
| 16 | +VOXTRAL_CI_TMPDIR="$(mktemp -d "${VOXTRAL_CI_TMP_ROOT}/executorch-rocm-voxtral.XXXXXX")" |
| 17 | +trap 'rm -rf "${VOXTRAL_CI_TMPDIR}"' EXIT |
| 18 | +VOXTRAL_START_SECONDS="${SECONDS}" |
| 19 | + |
| 20 | +export ROCM_PATH |
| 21 | +export HIP_VISIBLE_DEVICES=0 |
| 22 | +export CUDA_VISIBLE_DEVICES=0 |
| 23 | +export HF_HOME="${VOXTRAL_CI_TMP_ROOT}/hf-cache" |
| 24 | +export HF_HUB_DISABLE_XET=1 |
| 25 | +mkdir -p "${HF_HOME}" |
| 26 | +HF_TOKEN="$(printf '%s' "${SECRET_EXECUTORCH_HF_TOKEN}" | tr -d '\r\n')" |
| 27 | +export HF_TOKEN |
| 28 | + |
| 29 | +read -r TORCH_VERSION TORCHAO_VERSION < <( |
| 30 | + python - <<'PY' |
| 31 | +from install_requirements import TORCHAO_NIGHTLY_VERSION |
| 32 | +from torch_pin import TORCH_VERSION |
| 33 | +
|
| 34 | +print(TORCH_VERSION, TORCHAO_NIGHTLY_VERSION) |
| 35 | +PY |
| 36 | +) |
| 37 | +# TorchAO ROCm wheels are not exposed by the per-version pip index. |
| 38 | +TORCHAO_WHEEL="${TORCHAO_ROCM_WHEEL_BASE}/torchao-${TORCHAO_VERSION}" |
| 39 | +TORCHAO_WHEEL+="%2Brocm${ROCM_VERSION}-cp310-abi3-manylinux_2_28_x86_64.whl" |
| 40 | +python -m pip install "torch==${TORCH_VERSION}" \ |
| 41 | + --index-url "${PYTORCH_ROCM_INDEX}" |
| 42 | +python -m pip install -r requirements-dev.txt \ |
| 43 | + "${TORCHAO_WHEEL}" |
| 44 | +python -m pip install --editable . --no-build-isolation |
| 45 | + |
| 46 | +if ! command -v conda >/dev/null; then |
| 47 | + echo "The ROCm CI image must provide conda for its runtime libraries" |
| 48 | + exit 1 |
| 49 | +fi |
| 50 | +conda install -y -c conda-forge ffmpeg 'libstdcxx-ng>=12' |
| 51 | + |
| 52 | +python -m pip install 'fsspec[http]<=2025.3.0' |
| 53 | +python -m pip install datasets huggingface_hub librosa mistral-common safetensors soundfile |
| 54 | +python -m pip install torchcodec==0.11.0 \ |
| 55 | + --extra-index-url https://download.pytorch.org/whl/test/cpu |
| 56 | + |
| 57 | +python - <<'PY' |
| 58 | +import torch |
| 59 | +import torchao |
| 60 | +
|
| 61 | +assert torch.version.hip is not None, "PyTorch is not a ROCm build" |
| 62 | +assert torch.version.cuda is None, "PyTorch unexpectedly reports a CUDA runtime" |
| 63 | +assert torch.cuda.is_available(), "No AMD GPU is visible through PyTorch" |
| 64 | +assert "+rocm" in torchao.__version__, "TorchAO is not a ROCm build" |
| 65 | +
|
| 66 | +device = torch.cuda.get_device_properties(0) |
| 67 | +arch = device.gcnArchName.split(":", 1)[0] |
| 68 | +assert arch == "gfx950", f"Expected gfx950, got {device.gcnArchName}" |
| 69 | +assert device.warp_size == 64, f"Expected wave64, got {device.warp_size}" |
| 70 | +print( |
| 71 | + torch.__version__, |
| 72 | + torchao.__version__, |
| 73 | + torch.version.hip, |
| 74 | + device.name, |
| 75 | + device.gcnArchName, |
| 76 | +) |
| 77 | +PY |
| 78 | + |
| 79 | +python -m pytest -v -o 'addopts=' examples/models/voxtral_realtime/tests |
| 80 | + |
| 81 | +VOXTRAL_MODEL_DIR="${VOXTRAL_CI_TMPDIR}/model" |
| 82 | +VOXTRAL_AUDIO="${VOXTRAL_CI_TMPDIR}/test_audio.wav" |
| 83 | +VOXTRAL_OUTPUT="${VOXTRAL_CI_TMPDIR}/output" |
| 84 | +VOXTRAL_LOG="${VOXTRAL_CI_TMPDIR}/voxtral.log" |
| 85 | + |
| 86 | +python - "${VOXTRAL_MODEL_DIR}" <<'PY' |
| 87 | +import sys |
| 88 | +
|
| 89 | +from huggingface_hub import snapshot_download |
| 90 | +
|
| 91 | +snapshot_download( |
| 92 | + "mistralai/Voxtral-Mini-4B-Realtime-2602", |
| 93 | + local_dir=sys.argv[1], |
| 94 | + allow_patterns=["params.json", "tekken.json", "consolidated.safetensors"], |
| 95 | +) |
| 96 | +PY |
| 97 | + |
| 98 | +python - "${VOXTRAL_AUDIO}" <<'PY' |
| 99 | +import sys |
| 100 | +
|
| 101 | +import soundfile as sf |
| 102 | +from datasets import load_dataset |
| 103 | +
|
| 104 | +sample = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")[0][ |
| 105 | + "audio" |
| 106 | +] |
| 107 | +sf.write(sys.argv[1], sample["array"][: sample["sampling_rate"] * 30], sample["sampling_rate"]) |
| 108 | +PY |
| 109 | + |
| 110 | +CMAKE_PREFIX_PATH="$(python -c 'import torch; print(torch.utils.cmake_prefix_path)')" |
| 111 | +export CMAKE_PREFIX_PATH |
| 112 | +VOXTRAL_PYTHON=python \ |
| 113 | + bash examples/models/voxtral_realtime/run_rocm_e2e.sh \ |
| 114 | + "${VOXTRAL_MODEL_DIR}" \ |
| 115 | + "${VOXTRAL_AUDIO}" \ |
| 116 | + w4-bf16 \ |
| 117 | + streaming \ |
| 118 | + "${VOXTRAL_OUTPUT}" 2>&1 | tee "${VOXTRAL_LOG}" |
| 119 | + |
| 120 | +if ! grep -qi 'Quilter' "${VOXTRAL_LOG}"; then |
| 121 | + echo "Voxtral transcript did not contain the expected word: Quilter" |
| 122 | + exit 1 |
| 123 | +fi |
| 124 | +echo "Voxtral transcript contains the expected word: Quilter" |
| 125 | + |
| 126 | +for VOXTRAL_METRIC in 'Voxtral export metrics:' 'Voxtral RTF:'; do |
| 127 | + if ! grep -q "${VOXTRAL_METRIC}" "${VOXTRAL_LOG}"; then |
| 128 | + echo "Voxtral CI did not report ${VOXTRAL_METRIC}" |
| 129 | + exit 1 |
| 130 | + fi |
| 131 | +done |
| 132 | + |
| 133 | +du -sh "${VOXTRAL_MODEL_DIR}" "${VOXTRAL_OUTPUT}" |
| 134 | +echo "Voxtral ROCm CI wall time: $((SECONDS - VOXTRAL_START_SECONDS)) seconds" |
0 commit comments