# MLPerf 基准测试

MLPerf™ Storage 是一个用于评估支持AI工作负载的存储系统性能的基准测试套件。 该套件包含AI 训练(Training)的工作负载类别：

它通过模拟诸如 “3D-Unet”、 “ResNet-50” 和 “Cosmoflow” 等模型的 I/O 模式，用于评估存储系统的吞吐性能和I/O 效率。 本指南介绍如何使用 MLPerf v2.0 Storage 基准测试工具来测试 Alluxio 集群 的性能。

## 基准测试亮点

下表展示了使用 MLPerf Storage v2.0 基准测试得到的结果(<https://mlcommons.org/benchmarks/storage/)。> 测试时数据已全部缓存到 Alluxio 中，并使用 H100 GPU 作为训练加速器。 表中的 “Accelerator Utilization (AU)” 指标表示存储系统使 GPU 保持高效工作的程度。

| 模型        | 加速器数量 (H100) | 数据集大小  | Fuse 节点 | Worker 节点 | 加速器利用率 (AU) | 读取带宽 (GiB/s) | 单加速器读取带宽 (Gib/s) |
| --------- | ------------ | ------ | ------- | --------- | ----------- | ------------ | ---------------- |
| Resnet50  | 16           | 500 GB | 1       | 2         | 99.57%      | 3.03075      | 0.1894           |
| Resnet50  | 32           | 1.0 TB | 2       | 2         | 99.57%      | 6.05086      | 0.1891           |
| Resnet50  | 128          | 4.0 TB | 8       | 8         | 99.57%      | 24.1364      | 0.1886           |
| U-Net3D   | 1            | 500 GB | 1       | 2         | 99.02%      | 2.92255      | 2.9225           |
| U-Net3D   | 2            | 1.0 TB | 2       | 2         | 99.02%      | 5.80375      | 2.8946           |
| U-Net3D   | 8            | 4.0 TB | 8       | 8         | 99.02%      | 23.1569      | 2.8946           |
| Cosmoflow | 5            | 500 GB | 1       | 2         | 74.97%      | 2.69356      | 0.5387           |
| Cosmoflow | 8            | 1.0 TB | 8       | 8         | 74.97%      | 4.31414      | 0.5393           |

## 测试环境

基准测试结果是使用以下环境生成的，所有实例都部署在同一个 AWS 可用区中。

* **Alluxio 集群**:
  * 2 个工作节点 (`i3en.12xlarge`: 48 核, 384GiB RAM, 3000GB NVMe SSD)
  * 1 个 FUSE 客户端节点 (`c5n.9xlarge`: 36 核, 96GiB RAM, 50GB EBS)
* **操作系统**: Ubuntu 24.04

## 设置和配置

### 1. 安装 MLPerf Storage 工具

在计划运行基准测试的客户端节点上执行以下操作：

```shell
# 安装 MPI 依赖
sudo apt install python3-pip python3-venv libopenmpi-dev openmpi-common

# 创建 Python 虚拟环境并激活
python3 -m venv ~/.venvs/myenv
source ~/.venvs/myenv/bin/activate

# 更新 pip
python3 -m pip install --upgrade pip

# 从 MLCommons 仓库克隆 MLPerf Storage v2.0 分支并安装依赖
git clone -b v2.0-rc0 https://github.com/mlcommons/storage.git
cd storage
pip3 install -e .
```

目录结构如下：

```
storage/
 ├── mlpstorage/         # 基准测试源代码
 ├── configs/
 │   ├── dlio/workload/  # 各种训练与检查点工作负载的配置文件
 │   └── vectordbbench/  # 向量数据库工作负载（仅预览，不可提交）

```

该基准测试通过 dlio\_benchmark 模拟深度学习 I/O 模式。 dlio\_benchmark 当前需从特定分支获取，未来版本将从 PyPI 安装。 每个工作负载的配置通过 YAML 文件 定义，位于 configs 目录下。

### 2. 配置 Alluxio

为了在 ML 训练期间获得最佳读取性能，我们建议在 Alluxio 集群节点的 `conf/alluxio-site.properties` 文件中设置以下属性。

```properties
alluxio.user.metadata.cache.max.size=2000000
alluxio.user.metadata.cache.expiration.time=24h
alluxio.user.position.reader.streaming.async.prefetch.thread=256
alluxio.user.position.reader.streaming.async.prefetch.part.length=4MB
alluxio.user.position.reader.streaming.async.prefetch.max.part.number=4
```

在运行基准测试之前，请确保：

* Alluxio FUSE 进程正在客户端节点上运行。
* 训练数据集已完全加载到 Alluxio 缓存中。

## 运行基准测试

基准测试过程包括生成一个合成数据集，然后对其运行训练模拟。

### 步骤 1：生成数据集

注意：此步骤仅需在一个客户端（launcher client）上执行。 数据集大小取决于加速器数量、客户端数量及系统内存。 一般遵循以下两条规则： 磁盘容量大小应至少为所有客户端系统内存总和的 5 倍； 每个 GPU 的训练应运行 500 次迭代（iteration）。 如果在执行该命令时传入了客户端列表，则内存数量会通过程序自动计算。否则，用户可以自行提供客户端数量以及每个客户端的内存大小，用于进行计算。

示例命令：

```shell
mlpstorage training datasize -m unet3d --client-host-memory-in-gb 128 --max-accelerators 16 --num-client-hosts 2 --accelerator-type a100 --results-dir ~/mlps-results
```

接着，根据工作负载生成合成数据集：

```shell
mlpstorage training datagen --hosts 10.117.61.121,10.117.61.165 --model unet3d --num-processes 8 --data-dir /mnt/unet3d_data --param dataset.num_files_train=56000
```

生成数据集后，将其上传到您的 UFS 并确保已加载到 Alluxio 中。

### 步骤 2：运行训练基准测试

示例命令：

```shell
mlpstorage training run --hosts 10.117.61.121,10.117.61.165 --num-client-hosts 2 --client-host-memory-in-gb 64 --num-accelerators 2 --accelerator-type h100 --model unet3d --data-dir unet3d_data --results-dir unet3d_results --param dataset.num_files_train=400
```

### 步骤 3：生成基准测试报告

基准测试提交报告是通过汇总各个独立运行的结果生成的。报告命令提供了相关功能，用于为指定的结果目录生成报告。

运行以下命令以汇总结果并生成报告：

```shell
mlpstorage reports reportgen --output-dir ./reports --results-dir ./unet3d_results
```

注意：reportgen 命令必须在最初的 launcher client 节点上运行。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-cn/benchmark/benchmarking-ml-training-performance-with-mlperf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
