diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..22720a5c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish Python Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' # Specify the Python version you need + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements.txt + + - name: Build package + run: python3 -m build -n --sdist + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PIP_TOKEN }} + run: | + python3 -m pip install twine + twine upload dist/* \ No newline at end of file diff --git a/docs/source/install.rst b/docs/source/install.rst index 0b7867d5..cd8ba8ee 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -42,7 +42,22 @@ If you prefer not to use Docker, you can also install ReaL from PyPI or from the 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. -Install from PyPI: +First, clone the repository and install all dependencies: + +.. code-block:: console + + $ 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: + +.. 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 + +Install ReaLHF from PyPI: .. code-block:: console diff --git a/pyproject.toml b/pyproject.toml index 289954c8..cb7ddb38 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "realhf" description = "ReaL: Efficient RLHF Training of Large Language Models with Parameter Reallocation" readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.10,<3.12" dynamic = ["version"] authors = [ { name = "Zhiyu Mei", email = "meizy20@mails.tsinghua.edu.cn" }, diff --git a/realhf/__init__.py b/realhf/__init__.py index d57fd414..f5e38bbc 100644 --- a/realhf/__init__.py +++ b/realhf/__init__.py @@ -14,11 +14,11 @@ OptimizerConfig, ParallelismConfig, ) +from .base.namedarray import NamedArray from .experiments.common.common import CommonExperimentConfig from .experiments.common.dpo_exp import DPOConfig from .experiments.common.ppo_exp import PPOConfig, PPOHyperparameters from .experiments.common.rw_exp import RWConfig from .experiments.common.sft_exp import SFTConfig -from .base.namedarray import NamedArray __version__ = "0.1.0" diff --git a/setup.py b/setup.py index 340f6057..936364b5 100644 --- a/setup.py +++ b/setup.py @@ -212,9 +212,6 @@ def get_torch_arch_list() -> Set[str]: with contextlib.suppress(ValueError): torch_cpp_ext.COMMON_NVCC_FLAGS.remove(flag) -with open("requirements.txt", "r") as f: - dependencies = f.read().splitlines() - os.makedirs(os.path.join(ROOT_DIR, "realhf", "_C"), exist_ok=True) if _is_cuda(): cr_extension = CUDAExtension( @@ -291,5 +288,4 @@ def get_torch_arch_list() -> Set[str]: ext_modules=ext_modules, cmdclass={"build_ext": BuildExtension}, packages=setuptools.find_packages(), - install_requires=dependencies, )