diff --git a/.dockerignore b/.dockerignore index 836364a..3c3012e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ * -!requirements*.txt +!requirements-dev.txt diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62bc51f..11fd8b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,12 +18,14 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Build Docker Image - run: | - docker build -t unit-scaling-dev:latest . + - name: Build Docker image + run: docker build -t unit-scaling-dev:latest . + + - name: Local unit_scaling install + run: docker run -v $(pwd):/home/developer/unit-scaling unit-scaling-dev:latest pip install --user -e . - name: Run CI - run: docker run --rm -v $(pwd):/home/developer/unit-scaling unit-scaling-dev:latest ./dev ci + run: docker run -v $(pwd):/home/developer/unit-scaling unit-scaling-dev:latest ./dev ci - name: Publish documentation if: ${{github.ref == 'refs/heads/main'}} diff --git a/.gitignore b/.gitignore index c42bf14..26e093e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ __pycache__ .venv .venvs .vscode +unit_scaling/_version.py /build /dist diff --git a/Dockerfile b/Dockerfile index ec6826a..e31a292 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ ENV PATH="$PATH:/home/$USERNAME/.local/bin" \ # Install Python dependencies COPY requirements-dev.txt . -RUN pip install -r requirements-dev.txt +RUN pip install --user -r requirements-dev.txt # Creates basic .zshrc RUN sudo cp /etc/zsh/newuser.zshrc.recommended /home/$USERNAME/.zshrc diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index f9bd145..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include requirements.txt diff --git a/NOTICE.md b/NOTICE.md index 9271010..5f4af62 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -2,7 +2,7 @@ Copyright (c) 2023 Graphcore Ltd. Licensed under the Apache 2.0 License. The included code is released under an Apache 2.0 license, (see [LICENSE](LICENSE)). -Our dependencies are (see [requirements.txt](requirements.txt)): +Our dependencies are (see [pyproject.toml](pyproject.toml)): | Component | About | License | | --- | --- | --- | diff --git a/README.md b/README.md index 24526da..2644df3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Unit-Scaled Maximal Update Parameterization (u-μP) +[![tests](https://github.com/graphcore-research/unit-scaling/actions/workflows/ci.yaml/badge.svg)](https://github.com/graphcore-research/unit-scaling/actions/workflows/ci-public.yaml) +![PyPI version](https://img.shields.io/pypi/v/unit-scaling) +[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/graphcore-research/unit-scaling/blob/main/LICENSE) +[![GitHub Repo stars](https://img.shields.io/github/stars/graphcore-research/unit-scaling)](https://github.com/graphcore-research/unit-scaling/stargazers) + A library for unit scaling in PyTorch, based on the paper [u-μP: The Unit-Scaled Maximal Update Parametrization](https://arxiv.org/abs/2407.17465) and previous work [Unit Scaling: Out-of-the-Box Low-Precision Training](https://arxiv.org/abs/2303.11257). Documentation can be found at @@ -14,7 +19,12 @@ We're keen to help users with any problems they encounter. To install the `unit-scaling` library, run: ```sh -pip install git+https://github.com/graphcore-research/unit-scaling.git +pip install unit-scaling +``` +or for a local editable install (i.e. one which uses the files in this repo), run: + +```sh +pip install -e . ``` ## Development diff --git a/dev b/dev index 82f6566..cdfa754 100755 --- a/dev +++ b/dev @@ -85,8 +85,8 @@ def format(check: bool) -> None: def copyright() -> None: """check for Graphcore copyright headers on relevant files""" command = ( - f"find {' '.join(PYTHON_ROOTS)} -type f" - " -not -name *.pyc -not -name *.json -not -name .gitignore" + f"find {' '.join(PYTHON_ROOTS)} -type f -not -name *.pyc -not -name *.json" + " -not -name .gitignore -not -name *_version.py" " | xargs grep -L 'Copyright (c) 202. Graphcore Ltd[.] All rights reserved[.]'" ) print(f"$ {command}", file=sys.stderr) diff --git a/docs/index.rst b/docs/index.rst index de8eafe..13e9610 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,7 +18,7 @@ To install :code:`unit-scaling`, run: .. code-block:: - pip install git+https://github.com/graphcore-research/unit-scaling.git + pip install unit-scaling Getting Started --------------- diff --git a/docs/user_guide.rst b/docs/user_guide.rst index a8ec322..1a85eea 100644 --- a/docs/user_guide.rst +++ b/docs/user_guide.rst @@ -19,7 +19,7 @@ To install the :code:`unit-scaling` library, run: .. code-block:: - pip install git+https://github.com/graphcore-research/unit-scaling.git + pip install unit-scaling For those who wish to develop on the :code:`unit-scaling` codebase, clone or fork our `GitHub repo `_ and follow the diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5997432 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,57 @@ +# Configuration inspired by official pypa example: +# https://github.com/pypa/sampleproject/blob/main/pyproject.toml + +[build-system] +requires = ["setuptools>=68.2.2", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "unit-scaling" +description = "A library for unit scaling in PyTorch, based on the paper 'u-muP: The Unit-Scaled Maximal Update Parametrization.'" +readme = "README.md" +authors = [ + { name = "Charlie Blake", email = "charlieb@graphcore.ai" }, + { name = "Douglas Orr", email = "douglaso@graphcore.ai" }, +] +requires-python = ">=3.9" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] +dependencies = [ + "datasets", + "docstring-parser", + "einops", + "numpy<2.0.0", + "seaborn", + "tabulate", + "torch>=2.2", +] +dynamic = ["version"] + +[project.urls] +"Homepage" = "https://github.com/graphcore-research/unit-scaling/#readme" +"Bug Reports" = "https://github.com/graphcore-research/unit-scaling/issues" +"Source" = "https://github.com/graphcore-research/unit-scaling/" + +[project.optional-dependencies] +dev = ["check-manifest"] +test = ["pytest"] + +[tool.setuptools] +packages = ["unit_scaling", "unit_scaling.core", "unit_scaling.transforms"] + +[tool.setuptools.dynamic] +version = {attr = "unit_scaling._version.__version__"} + +[tool.setuptools_scm] +version_file = "unit_scaling/_version.py" diff --git a/requirements-dev.txt b/requirements-dev.txt index 79b4f12..f893d36 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,11 +2,11 @@ --index-url https://download.pytorch.org/whl/cpu --extra-index-url=https://pypi.org/simple -# Same as requirements.txt, but with versions locked-in +# Same as pyproject.toml, but with versions locked-in datasets==3.1.0 docstring-parser==0.16 einops==0.8.0 -numpy==2.1.3 +numpy==1.26.4 seaborn==0.13.2 tabulate==0.9.0 torch==2.5.1+cpu @@ -20,6 +20,7 @@ myst-parser==4.0.0 pandas-stubs==2.2.3.241009 pytest==8.3.3 pytest-cov==6.0.0 +setuptools==68.2.2 sphinx==8.1.3 sphinx-rtd-theme==3.0.1 transformers==4.46.1 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5271610..0000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -datasets -docstring-parser -einops -numpy -seaborn -tabulate -torch>=2.2 diff --git a/setup.cfg b/setup.cfg index b91579c..77800de 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,3 @@ -[options] -packages = - unit_scaling - [mypy] pretty = true show_error_codes = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 8608eb2..0000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2023 Graphcore Ltd. All rights reserved. - -from pathlib import Path -import re -import setuptools - -requirements = Path("requirements.txt").read_text().rstrip("\n").split("\n") - -version = re.search("__version__ = \"(.+)\"", Path("unit_scaling/_version.py").read_text()).group(1) - -setuptools.setup( - name="unit-scaling", - version=version, - description="A library for unit scaling in PyTorch.", - packages=["unit_scaling", "unit_scaling.core", "unit_scaling.transforms"], - install_requires=requirements, -) diff --git a/unit_scaling/_version.py b/unit_scaling/_version.py deleted file mode 100644 index b971454..0000000 --- a/unit_scaling/_version.py +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (c) 2024 Graphcore Ltd. All rights reserved. - -__version__ = "0.3"