diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 72e1b099a..b2227a8d8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -122,37 +122,44 @@ jobs: arch: aarch64 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - merge-multiple: true - pattern: "shared_library*_${{ matrix.os }}_${{ matrix.arch }}*" - path: output/ - - name: Copy correct platform shared library - shell: bash - run: | - ls -lR output/ - cp output/${{ matrix.os }}/${{ matrix.arch }}/* bitsandbytes/ - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip - - run: pip install build wheel - - run: python -m build . - - name: Determine and Set Platform Tag, then Tag Wheel - shell: bash - run: | - PLATFORM_TAG=$(python .github/scripts/set_platform_tag.py "${{ matrix.arch }}") - echo "PLATFORM_TAG=$PLATFORM_TAG" - wheel tags --remove --abi-tag=none --python-tag=py3 --platform-tag=$PLATFORM_TAG dist/bitsandbytes-*.whl - - name: Upload build artifact - uses: actions/upload-artifact@v4 - with: - name: bdist_wheel_${{ matrix.os }}_${{ matrix.arch }} - path: dist/bitsandbytes-*.whl - retention-days: 7 + # Check out code + - uses: actions/checkout@v4 + # Download shared libraries + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + merge-multiple: true + pattern: "shared_library*_${{ matrix.os }}_${{ matrix.arch }}*" + path: output/ + - name: Copy correct platform shared library + shell: bash + run: | + ls -lR output/ + cp output/${{ matrix.os }}/${{ matrix.arch }}/* bitsandbytes/ + # Set up the Python version needed + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + - name: Install build package + shell: bash + run: pip install build wheel + - name: Build wheel + shell: bash + run: python -m build . + - name: Determine and Set Platform Tag, then Tag Wheel + shell: bash + run: | + PLATFORM_TAG=$(python .github/scripts/set_platform_tag.py "${{ matrix.arch }}") + echo "PLATFORM_TAG=$PLATFORM_TAG" + wheel tags --remove --abi-tag=none --python-tag=py3 --platform-tag=$PLATFORM_TAG dist/bitsandbytes-*.whl + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: bdist_wheel_${{ matrix.os }}_${{ matrix.arch }} + path: dist/bitsandbytes-*.whl + retention-days: 7 audit-wheels: needs: build-wheels diff --git a/docs/source/contributing.mdx b/docs/source/contributing.mdx index 4fe6b7541..103c38209 100644 --- a/docs/source/contributing.mdx +++ b/docs/source/contributing.mdx @@ -3,6 +3,10 @@ ## Setup +### Editable install +- Create an editable installation for development with `pip install -e ".[dev]"` +- Optional extras: `benchmark`, `docs` + ### Setup pre-commit hooks - Install pre-commit hooks with `pip install pre-commit`. - Run `pre-commit autoupdate` once to configure the hooks. diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index caf22488f..ddc11cf28 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -80,10 +80,9 @@ Refer to the following table if you're using another CUDA Toolkit version. ```bash git clone https://github.com/TimDettmers/bitsandbytes.git && cd bitsandbytes/ -pip install -r requirements-dev.txt cmake -DCOMPUTE_BACKEND=cuda -S . cmake --build . --config Release -python -m build --wheel +pip install . ``` Big thanks to [wkpark](https://github.com/wkpark), [Jamezo97](https://github.com/Jamezo97), [rickardp](https://github.com/rickardp), [akx](https://github.com/akx) for their amazing contributions to make bitsandbytes compatible with Windows. diff --git a/pyproject.toml b/pyproject.toml index 609ff84fa..9eae7c00b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,79 @@ [build-system] -requires = [ "setuptools", "wheel" ] +requires = ["setuptools >= 63.0.0"] build-backend = "setuptools.build_meta" +[project] +name = "bitsandbytes" +dynamic = ["version"] +description = "k-bit optimizers and matrix multiplication routines." +authors = [{name="Tim Dettmers", email="dettmers@cs.washington.edu"}] +requires-python = ">=3.8" +readme = "README.md" +license = {file="LICENSE"} +keywords = [ + "gpu", + "optimizers", + "optimization", + "8-bit", + "quantization", + "compression" +] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Environment :: GPU :: NVIDIA CUDA :: 11", + "Environment :: GPU :: NVIDIA CUDA :: 12", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Programming Language :: C++", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering :: Artificial Intelligence" +] +dependencies = [ + "torch>=1.11,!=1.12.0", + "numpy>=1.17" +] + +[project.optional-dependencies] +benchmark = ["pandas", "matplotlib"] +docs = ["hf-doc-builder==0.5.0"] +dev = [ + "bitsandbytes[test]", + "build>=1.0.0,<2", + "ruff==0.3.2", + "pre-commit>=3.5.0,<4", + "wheel>=0.42,<1" +] +test = [ + "einops~=0.6.0", + "lion-pytorch==0.0.6", + "pytest~=7.4", + "scipy>=1.10.1,<2; python_version < '3.9'", + "scipy>=1.11.4,<2; python_version >= '3.9'", + "transformers>=4.30.1,<5" +] +triton = ["triton~=2.0.0; sys_platform=='linux' and platform_machine=='x86_64'"] + +[project.urls] +homepage = "https://github.com/TimDettmers/bitsandbytes" +changelog = "https://github.com/TimDettmers/bitsandbytes/blob/main/CHANGELOG.md" +docs = "https://huggingface.co/docs/bitsandbytes/main" +issues = "https://github.com/TimDettmers/bitsandbytes/issues" + +[tool.setuptools] +package-data = { "*" = ["libbitsandbytes*.*"] } + +[tool.setuptools.dynamic] +version = {attr = "bitsandbytes.__version__"} + [tool.ruff] src = [ "bitsandbytes", diff --git a/requirements-ci.txt b/requirements-ci.txt deleted file mode 100644 index 906c6643e..000000000 --- a/requirements-ci.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Requirements used for GitHub actions -pytest==8.1.1 -einops==0.7.0 -lion-pytorch==0.1.4 -scipy==1.10.1; python_version < "3.9" -scipy==1.13.0; python_version >= "3.9" diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 4ee8bf543..000000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Requirements used for local development -setuptools>=63 -pytest~=8.1.1 -einops~=0.7.0 -wheel~=0.43.0 -lion-pytorch~=0.1.4 -scipy~=1.13.0 -pandas~=2.2.1 -matplotlib~=3.8.4 diff --git a/setup.py b/setup.py index f8d6a92a1..3b8f03640 100644 --- a/setup.py +++ b/setup.py @@ -2,20 +2,9 @@ # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -import glob -import os - from setuptools import find_packages, setup from setuptools.dist import Distribution -libs = list(glob.glob("./bitsandbytes/libbitsandbytes*.*")) -libs = [os.path.basename(p) for p in libs] -print("libs:", libs) - - -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - # Tested with wheel v0.29.0 class BinaryDistribution(Distribution): @@ -23,27 +12,4 @@ def has_ext_modules(self): return True -setup( - name="bitsandbytes", - version="0.43.2.dev", - author="Tim Dettmers", - author_email="dettmers@cs.washington.edu", - description="k-bit optimizers and matrix multiplication routines.", - license="MIT", - keywords="gpu optimizers optimization 8-bit quantization compression", - url="https://github.com/TimDettmers/bitsandbytes", - packages=find_packages(), - package_data={"": libs}, - install_requires=["torch", "numpy"], - extras_require={ - "benchmark": ["pandas", "matplotlib"], - "test": ["scipy"], - }, - long_description=read("README.md"), - long_description_content_type="text/markdown", - classifiers=[ - "Development Status :: 4 - Beta", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - ], - distclass=BinaryDistribution, -) +setup(version="0.43.2.dev0", packages=find_packages(), distclass=BinaryDistribution)