Skip to content
Merged
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
67 changes: 67 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 并支持进阶的任务选择和调度。
Expand Down Expand Up @@ -129,7 +130,7 @@ Trinity-RFT 面向不同背景和目标的用户提供相应功能:
在安装之前,请确保您的系统满足以下要求:

- **Python**:版本 3.10 至 3.12(含)
- **CUDA**:版本 >= 12.6
- **CUDA**:版本 >= 12.8
- **GPU**:至少 2 块 GPU

## 源码安装(推荐)
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx_doc/source/tutorial/example_megatron.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_doc/source/tutorial/trinity_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

---
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx_doc/source_zh/tutorial/example_megatron.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 密钥。
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_doc/source_zh/tutorial/trinity_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
在安装前,请确保您的系统满足以下要求:

- **Python**:3.10 至 3.12(包含)
- **CUDA**:大于等于 12.6
- **CUDA**:大于等于 12.8
- **GPU**:至少 2 块 GPU

---
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]"},
]
Expand Down
3 changes: 2 additions & 1 deletion scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <Trinity-RFT root dir>
Expand All @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# This Dockerfile sets up a Trinity-RFT environment with Megatron-LM support.
# Build and run the docker image with the following command:
#
# cd <Trinity-RFT root dir>
# 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 <root_path_of_data_and_checkpoints>:/data trinity-rft-megatron:latest


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 \
Expand All @@ -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
Expand Down
62 changes: 62 additions & 0 deletions scripts/docker/Dockerfile.uv
Original file line number Diff line number Diff line change
@@ -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 <Trinity-RFT root dir>
# docker build -f scripts/docker/Dockerfile.uv -t trinity-rft:latest .
# docker run -it --gpus all --shm-size="64g" --rm -v $PWD:/workspace -v <root_path_of_data_and_checkpoints>:/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"]
2 changes: 1 addition & 1 deletion trinity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
"""Trinity-RFT (Reinforcement Fine-Tuning)"""

__version__ = "0.3.2"
__version__ = "0.3.3"