From 0548b80d02f6aa9aa39f0622e8c65a166a429323 Mon Sep 17 00:00:00 2001 From: fw Date: Thu, 20 Jun 2024 08:07:35 +0000 Subject: [PATCH 1/7] remove dependencies & update installation guide --- docs/source/install.rst | 7 ++++--- docs/source/quickstart.rst | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index cd8ba8ee..7b9a4564 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -46,16 +46,17 @@ First, clone the repository and install all dependencies: .. code-block:: console + $ pip install -U pip $ git clone https://github.com/openpsi-project/ReaLHF $ cd ReaLHF $ python3 -m pip install -r requirements.txt -On a GPU machine, also install the requirement CUDA runtime packages: +On a GPU machine, also install the required runtime packages: .. code-block:: console - $ python3 -m pip install git+https://github.com/NVIDIA/TransformerEngine.git@v1.7 --no-deps - $ python3 -m pip install flash_attn --no-build-isolation + $ MAX_JOBS=8 python3 -m pip install git+https://github.com/NVIDIA/TransformerEngine.git@v1.4 --no-deps --no-build-isolation + $ MAX_JOBS=8 python3 -m pip install flash_attn==2.4.2 --no-build-isolation Install ReaLHF from PyPI: diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index 833e12bb..a2846fff 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -4,13 +4,9 @@ Quickstart Installation --------------- -First, clone the ReaL repository from GitHub: +First, clone the ReaL repository from GitHub and follow the installation instructions in :doc:`install`. +The following tutorial will run on a GPU machine in the repository directory. -.. code-block:: shell - - $ git clone https://github.com/openpsi-project/ReaLHF - $ cd ReaLHF - $ pip3 install -e . --no-build-isolation RLHF with 4x LLaMA-7B in 30min ------------------------------------------------ From d9dd80e02f123e20f95497adc59d24f8e3238e33 Mon Sep 17 00:00:00 2001 From: Wei Fu <36355462+garrett4wade@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:15:24 +0800 Subject: [PATCH 2/7] Update sphinx.yml --- .github/workflows/sphinx.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index ab4dcf5c..9080103e 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -9,6 +9,17 @@ jobs: contents: write steps: - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install build tools + run: sudo apt-get update && sudo apt-get install -y g++ make + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -e . - name: Build HTML uses: garrett4wade/sphinx-action@master - name: Upload artifacts @@ -21,4 +32,4 @@ jobs: if: github.ref == 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/build/html \ No newline at end of file + publish_dir: docs/build/html From 542d0e20f17ce85656cd2d3d04f9b926f8c6f1b5 Mon Sep 17 00:00:00 2001 From: Wei Fu <36355462+garrett4wade@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:28:19 +0800 Subject: [PATCH 3/7] Update sphinx.yml --- .github/workflows/sphinx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 9080103e..3bd23350 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -19,7 +19,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install -e . + pip install -e . --no-build-isolation - name: Build HTML uses: garrett4wade/sphinx-action@master - name: Upload artifacts From 40c4b604934ff4fbd92dee4a98a67cd6fba23f9d Mon Sep 17 00:00:00 2001 From: fw Date: Thu, 20 Jun 2024 08:35:26 +0000 Subject: [PATCH 4/7] update requirements --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 2aba5c38..0cb0223e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,9 @@ sphinx-nefertiti sphinx build>=1.2.1 +wheel>=0.43.0 +distro-info>=1.0 +python-debian>=0.1.49 huggingface_hub datasets accelerate From 4ad9c2895851dc6078aaa106c592c0e9f8e69b09 Mon Sep 17 00:00:00 2001 From: fw Date: Thu, 20 Jun 2024 08:45:37 +0000 Subject: [PATCH 5/7] fix docs github page --- .github/workflows/sphinx.yml | 2 +- docs/source/install.rst | 26 ++++++++++++++++++-------- setup.py | 3 +++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 3bd23350..ded1273e 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -19,7 +19,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install -e . --no-build-isolation + REAL_NO_EXT=1 pip install -e . --no-build-isolation - name: Build HTML uses: garrett4wade/sphinx-action@master - name: Upload artifacts diff --git a/docs/source/install.rst b/docs/source/install.rst index 7b9a4564..f4c00407 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -30,7 +30,12 @@ remember to rerun the editable installation command after mounting: .. code-block:: console - $ pip install -e /your/mounted/code/path --no-build-isolation + $ REAL_CUDA=1 pip install -e /your/mounted/code/path --no-build-isolation + + +.. note:: + + The ``REAL_CUDA`` environment variable is used to install the CUDA extension. Install From PyPI or Source @@ -40,7 +45,11 @@ If you prefer not to use Docker, you can also install ReaL from PyPI or from the .. note:: - We don't upload a pre-built wheel to PyPI, so the installation will require compiling the C++ and CUDA extensions. If CUDA is not available on your machine, only the C++ extension will be installed. + We don't upload a pre-built wheel to PyPI, so the installation will require compiling the C++ and CUDA extensions. + Control whether to install the extentions with environment variables ``REAL_CUDA`` and ``REAL_NO_EXT``. + + The CUDA extention will be installed only if ``REAL_CUDA`` is set to 1. + No extention will be installed if ``REAL_NO_EXT`` is set to 1. First, clone the repository and install all dependencies: @@ -49,27 +58,28 @@ First, clone the repository and install all dependencies: $ pip install -U pip $ git clone https://github.com/openpsi-project/ReaLHF $ cd ReaLHF - $ python3 -m pip install -r requirements.txt + $ pip install -r requirements.txt On a GPU machine, also install the required runtime packages: .. code-block:: console - $ MAX_JOBS=8 python3 -m pip install git+https://github.com/NVIDIA/TransformerEngine.git@v1.4 --no-deps --no-build-isolation - $ MAX_JOBS=8 python3 -m pip install flash_attn==2.4.2 --no-build-isolation + $ MAX_JOBS=8 pip install git+https://github.com/NVIDIA/TransformerEngine.git@v1.4 --no-deps --no-build-isolation + $ MAX_JOBS=8 pip install flash_attn==2.4.2 --no-build-isolation Install ReaLHF from PyPI: .. code-block:: console - $ python3 -m pip install realhf --no-build-isolation + $ REAL_CUDA=1 pip install realhf --no-build-isolation -The PyPI package allows you to launch existing experiments with the quickstart command. If you want to modify the code, you should clone the source code and install it from the source: +The PyPI package allows you to launch existing experiments with the quickstart command. +If you want to modify the code, you should clone the source code and install it from the source: .. code-block:: console $ git clone https://github.com/openpsi-project/ReaLHF $ cd ReaLHF - $ python3 -m pip install -e . --no-build-isolation + $ REAL_CUDA=1 pip install -e . --no-build-isolation Next, check :doc:`quickstart`` for instructions on running experiments. diff --git a/setup.py b/setup.py index 936364b5..f0a3d24c 100644 --- a/setup.py +++ b/setup.py @@ -283,6 +283,9 @@ def get_torch_arch_list() -> Set[str]: ) ext_modules.append(search_extension) +if os.getenv("REAL_NO_EXT", "0") == "1": + ext_modules = [] + setuptools.setup( name="realhf", ext_modules=ext_modules, From f2386412ff442ce4bbf5b3758fac0f11cec1c683 Mon Sep 17 00:00:00 2001 From: fw Date: Thu, 20 Jun 2024 09:49:19 +0000 Subject: [PATCH 6/7] fix docs github page --- .github/workflows/sphinx.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index ded1273e..70e57044 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -18,8 +18,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - REAL_NO_EXT=1 pip install -e . --no-build-isolation + pip install --no-cache-dir -r requirements.txt + REAL_NO_EXT=1 pip install -e . --no-build-isolation --no-cache-dir - name: Build HTML uses: garrett4wade/sphinx-action@master - name: Upload artifacts From 56464716d30efa5d8c142cd2ea07912b7c19f096 Mon Sep 17 00:00:00 2001 From: fw Date: Thu, 20 Jun 2024 09:56:12 +0000 Subject: [PATCH 7/7] fix docs github page --- .github/workflows/sphinx.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 70e57044..e40e1cc0 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -9,17 +9,6 @@ jobs: contents: write steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install build tools - run: sudo apt-get update && sudo apt-get install -y g++ make - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --no-cache-dir -r requirements.txt - REAL_NO_EXT=1 pip install -e . --no-build-isolation --no-cache-dir - name: Build HTML uses: garrett4wade/sphinx-action@master - name: Upload artifacts