diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000000..838bd55df1 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,67 @@ +# +name: Create and publish a Docker image + +on: + release: + types: [published] + + workflow_dispatch: + inputs: + ref: + description: 'The git ref (branch or tag) to build the Docker image from.' + required: true + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: self-hosted + timeout-minutes: 240 # wait up to 4 hours + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v5 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=match,pattern=\d.\d.\d + type=sha + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v4 + with: + context: . + push: true + file: scripts/docker/Dockerfile + shm-size: 64g + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds). + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/README.md b/README.md index 6c45955f8f..793b87cdf8 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Trinity-RFT provides functionalities for users with different backgrounds and ob ## 🚀 News +* [2025-11] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.3.3)] Trinity-RFT v0.3.3 released: bug fixes. * [2025-11] Introducing [Learn-to-Ask](https://github.com/modelscope/Trinity-RFT/tree/main/examples/learn_to_ask): a framework for training proactive dialogue agents from offline expert data ([paper](https://arxiv.org/pdf/2510.25441)). * [2025-11] Introducing [BOTS](https://github.com/modelscope/Trinity-RFT/tree/main/examples/bots): online RL task selection for efficient LLM fine-tuning ([paper](https://arxiv.org/pdf/2510.26374)). * [2025-11] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.3.2)] Trinity-RFT v0.3.2 released: bug fixes and advanced task selection & scheduling. @@ -129,7 +130,7 @@ Trinity-RFT provides functionalities for users with different backgrounds and ob Before installing, make sure your system meets the following requirements: - **Python**: version 3.10 to 3.12 (inclusive) -- **CUDA**: version >= 12.6 +- **CUDA**: version >= 12.8 - **GPUs**: at least 2 GPUs diff --git a/README_zh.md b/README_zh.md index bd8846f4d6..423e76e103 100644 --- a/README_zh.md +++ b/README_zh.md @@ -88,6 +88,7 @@ Trinity-RFT 面向不同背景和目标的用户提供相应功能: ## 🚀 新闻 +* [2025-11] [[发布说明](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.3.3)] Trinity-RFT v0.3.3 发布:修复若干 Bug。 * [2025-11] 推出 [Learn-to-Ask](https://github.com/modelscope/Trinity-RFT/tree/main/examples/learn_to_ask):利用离线专家数据,训练具备主动问询能力的对话智能体([论文](https://arxiv.org/pdf/2510.25441)). * [2025-11] 推出 [BOTS](https://github.com/modelscope/Trinity-RFT/tree/main/examples/bots):在线 RL 任务选择,实现高效 LLM 微调([论文](https://arxiv.org/pdf/2510.26374))。 * [2025-11] [[发布说明](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.3.2)] Trinity-RFT v0.3.2 发布:修复若干 Bug 并支持进阶的任务选择和调度。 @@ -129,7 +130,7 @@ Trinity-RFT 面向不同背景和目标的用户提供相应功能: 在安装之前,请确保您的系统满足以下要求: - **Python**:版本 3.10 至 3.12(含) -- **CUDA**:版本 >= 12.6 +- **CUDA**:版本 >= 12.8 - **GPU**:至少 2 块 GPU ## 源码安装(推荐) diff --git a/docs/sphinx_doc/source/tutorial/example_megatron.md b/docs/sphinx_doc/source/tutorial/example_megatron.md index 085dcf5d3d..8cdea8497f 100644 --- a/docs/sphinx_doc/source/tutorial/example_megatron.md +++ b/docs/sphinx_doc/source/tutorial/example_megatron.md @@ -38,10 +38,10 @@ We provide a Docker setup to simplify environment management. #### Build the Docker Image -Trinity-RFT provides a dedicated Dockerfile for Megatron-LM located at `scripts/docker_for_megatron/Dockerfile`. You can build the image using the following command: +Trinity-RFT provides a dedicated Dockerfile for Megatron-LM located at `scripts/docker/Dockerfile.megatron`. You can build the image using the following command: ```bash -docker build -f scripts/docker_for_megatron/Dockerfile -t trinity-rft-megatron:latest . +docker build -f scripts/docker/Dockerfile.megatron -t trinity-rft-megatron:latest . ``` > 💡 You can customize the Dockerfile before building — for example, to add pip mirrors or set API keys. diff --git a/docs/sphinx_doc/source/tutorial/trinity_installation.md b/docs/sphinx_doc/source/tutorial/trinity_installation.md index e5a7f9ce63..bd72967556 100644 --- a/docs/sphinx_doc/source/tutorial/trinity_installation.md +++ b/docs/sphinx_doc/source/tutorial/trinity_installation.md @@ -6,7 +6,7 @@ For installing Trinity-RFT, you have three options: from source (recommended), v Before installing, ensure your system meets the following requirements: - **Python**: Version 3.10 to 3.12 (inclusive) -- **CUDA**: Version >= 12.6 +- **CUDA**: Version >= 12.8 - **GPUs**: At least 2 GPUs --- diff --git a/docs/sphinx_doc/source_zh/tutorial/example_megatron.md b/docs/sphinx_doc/source_zh/tutorial/example_megatron.md index a31db2d9f0..597beb7372 100644 --- a/docs/sphinx_doc/source_zh/tutorial/example_megatron.md +++ b/docs/sphinx_doc/source_zh/tutorial/example_megatron.md @@ -43,11 +43,11 @@ pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation \ #### 构建 Docker 镜像 -Trinity-RFT 提供了专门用于 Megatron-LM 的 Dockerfile,位于 `scripts/docker_for_megatron/Dockerfile`。 +Trinity-RFT 提供了专门用于 Megatron-LM 的 Dockerfile,位于 `scripts/docker/Dockerfile.megatron`。 可以使用以下命令构建镜像: ```bash -docker build -f scripts/docker_for_megatron/Dockerfile -t trinity-rft-megatron:latest . +docker build -f scripts/docker/Dockerfile.megatron -t trinity-rft-megatron:latest . ``` > 💡 你可以在构建前自定义 Dockerfile —— 例如添加 pip 镜像源或设置 API 密钥。 diff --git a/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md b/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md index 57a0bae818..d337e84960 100644 --- a/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md +++ b/docs/sphinx_doc/source_zh/tutorial/trinity_installation.md @@ -6,7 +6,7 @@ 在安装前,请确保您的系统满足以下要求: - **Python**:3.10 至 3.12(包含) -- **CUDA**:大于等于 12.6 +- **CUDA**:大于等于 12.8 - **GPU**:至少 2 块 GPU --- diff --git a/pyproject.toml b/pyproject.toml index 2134840c4b..098e1e1074 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "trinity-rft" -version = "0.3.2" +version = "0.3.3" authors = [ {name="Trinity-RFT Team", email="trinity-rft@outlook.com"}, ] diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 69da6ed3db..b87558f123 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -1,3 +1,4 @@ +# This Dockerfile sets up a Trinity-RFT environment with minimal support. # Build and run the docker image with the following command: # # cd @@ -9,7 +10,7 @@ FROM nvcr.io/nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04 WORKDIR /workspace -RUN apt update && apt install -y \ +RUN chmod 1777 /tmp && apt update && apt install -y \ build-essential \ curl git wget vim tmux net-tools \ python3 python3-pip python3-dev python3-packaging \ diff --git a/scripts/docker_for_megatron/Dockerfile b/scripts/docker/Dockerfile.megatron similarity index 79% rename from scripts/docker_for_megatron/Dockerfile rename to scripts/docker/Dockerfile.megatron index d97018eed2..7659452311 100644 --- a/scripts/docker_for_megatron/Dockerfile +++ b/scripts/docker/Dockerfile.megatron @@ -1,7 +1,8 @@ +# This Dockerfile sets up a Trinity-RFT environment with Megatron-LM support. # Build and run the docker image with the following command: # # cd -# docker build -f scripts/docker_for_megatron/Dockerfile -t trinity-rft-megatron:latest . +# docker build -f scripts/docker/Dockerfile.megatron -t trinity-rft-megatron:latest . # docker run -it --gpus all --shm-size="64g" --rm -v $PWD:/workspace -v :/data trinity-rft-megatron:latest @@ -9,7 +10,7 @@ FROM nvcr.io/nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04 WORKDIR /workspace -RUN apt update && apt install -y \ +RUN chmod 1777 /tmp && apt update && apt install -y \ build-essential \ curl git wget vim tmux net-tools \ python3 python3-pip python3-dev python3-packaging \ @@ -30,7 +31,8 @@ RUN pip install --upgrade pip \ && pip install -e .[mm,dev] \ && pip install flash_attn==2.8.1 --no-build-isolation \ && pip install -e .[megatron] \ - && pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation \ + && NVCC_APPEND_FLAGS="--threads 4" APEX_PARALLEL_BUILD=8 pip install -v \ + --disable-pip-version-check --no-cache-dir --no-build-isolation \ --config-settings "--build-option=--cpp_ext" \ --config-settings "--build-option=--cuda_ext" \ --resume-retries 20 git+https://github.com/NVIDIA/apex.git diff --git a/scripts/docker/Dockerfile.uv b/scripts/docker/Dockerfile.uv new file mode 100644 index 0000000000..ad653226bb --- /dev/null +++ b/scripts/docker/Dockerfile.uv @@ -0,0 +1,62 @@ +# This Dockerfile sets up a Trinity-RFT environment with Megatron support using uv. +# Build and run the docker image with the following command: +# +# cd +# docker build -f scripts/docker/Dockerfile.uv -t trinity-rft:latest . +# docker run -it --gpus all --shm-size="64g" --rm -v $PWD:/workspace -v :/data trinity-rft:latest +# +# Note: +# 1. This Dockerfile uses 'uv' to create a virtual environment for better package management. If you want a simpler setup without 'uv', please refer to `scripts/docker/Dockerfile`. +# 2. Make sure to use `uv pip` to install packages within the virtual environment. + +FROM nvcr.io/nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04 + +WORKDIR /workspace + +RUN chmod 1777 /tmp && apt update && apt install -y \ + build-essential \ + curl git wget vim tmux net-tools \ + python3 python3-pip python3-dev python3-packaging python3-venv \ + libomp-dev infiniband-diags libibverbs-dev librdmacm-dev rdma-core perftest \ + && rm -rf /var/lib/apt/lists/* \ + && ln -sf /usr/bin/python3 /usr/bin/python \ + && ln -sf /usr/bin/pip3 /usr/bin/pip + +# For Aliyun users: update pip mirror to aliyun to speed up pip install +# ENV PIP_INDEX_URL=http://mirrors.cloud.aliyuncs.com/pypi/simple/ +# ENV PIP_TRUSTED_HOST=mirrors.cloud.aliyuncs.com + +ENV VIRTUAL_ENV=/opt/venv + +# copy the Trinity-RFT dir into the workspace +COPY . . + +# Install uv +RUN pip install uv && uv venv /opt/venv --python=python3.12 + +# Install minimal Trinity-RFT +RUN . /opt/venv/bin/activate && \ + uv pip install -e.[mm,dev] + +# Install flash_attn and Megatron +RUN . /opt/venv/bin/activate && \ + uv pip install -e.[flash_attn] && \ + uv pip install -e .[megatron] && \ + NVCC_APPEND_FLAGS="--threads 4" APEX_PARALLEL_BUILD=8 \ + uv pip install -v --no-build-isolation \ + --config-settings="--build-option=--cpp_ext" \ + --config-settings="--build-option=--cuda_ext" \ + git+https://github.com/NVIDIA/apex.git + +# Set Env variables + +# WANDB +# ENV WANDB_API_KEY= +# ENV WANDB_BASE_URL= + +# LLM API +# ENV OPENAI_API_KEY= +# ENV DASH_API_KEY= + +ENTRYPOINT ["/bin/bash", "-c", "source /opt/venv/bin/activate && exec \"$@\"", "--"] +CMD ["bash"] diff --git a/trinity/__init__.py b/trinity/__init__.py index 846d735fc0..3866a3cd5e 100644 --- a/trinity/__init__.py +++ b/trinity/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- """Trinity-RFT (Reinforcement Fine-Tuning)""" -__version__ = "0.3.2" +__version__ = "0.3.3"