Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate build data to pyproject.toml #1078

Closed
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4454fc0
Migrate from setup.py to pyproject.toml for PEP 660 editable install
matthewdouglas Feb 23, 2024
7bdc6e5
Update workflow to use pyproject.toml for build requirements
matthewdouglas Feb 23, 2024
11142a3
Fix setup for doc build
matthewdouglas Feb 23, 2024
636c62d
cleanup workflow
matthewdouglas Feb 26, 2024
f9c2cc5
Merge branch 'TimDettmers:main' into setup-pep660
matthewdouglas Feb 28, 2024
699f505
Add dependency constraints
matthewdouglas Feb 28, 2024
00497ab
Update pyproject.toml
matthewdouglas Mar 4, 2024
d23be94
Update pyproject.toml
matthewdouglas Mar 4, 2024
48ede4a
Revert "Update pyproject.toml"
matthewdouglas Mar 4, 2024
9fae8ee
Merge conflict
matthewdouglas Mar 18, 2024
9a6794b
Update dependencies in pyproject.toml
matthewdouglas Mar 18, 2024
399a494
Rebase on main
matthewdouglas Apr 8, 2024
0101f2f
Resolve conflict
matthewdouglas Apr 8, 2024
72342b5
Resolve conflict
matthewdouglas Apr 8, 2024
11165f8
Add dependency constraints
matthewdouglas Feb 28, 2024
646a86a
Update pyproject.toml
matthewdouglas Mar 4, 2024
5d6ce68
Update pyproject.toml
matthewdouglas Mar 4, 2024
c5fcfb8
Revert "Update pyproject.toml"
matthewdouglas Mar 4, 2024
19dcbd7
Update dependencies in pyproject.toml
matthewdouglas Mar 18, 2024
fd725cb
fix conflict
matthewdouglas Apr 8, 2024
98f73d5
Merge branch 'TimDettmers:main' into setup-pep660
matthewdouglas Apr 9, 2024
a04cd4d
Make wheel artifact name agnostic to python version
matthewdouglas Apr 10, 2024
da2dc69
Remove requirements-*.txt
matthewdouglas Apr 10, 2024
a0ae460
Merge branch 'main' into setup-pep660
matthewdouglas Apr 16, 2024
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
3 changes: 0 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ jobs:
- name: Install build package
shell: bash
run: pip install build
- name: Install Python test dependencies
shell: bash
run: pip install -r requirements-ci.txt
# TODO: How to run CUDA tests on GitHub actions?
#- name: Run unit tests
# if: ${{ matrix.arch == 'x86_64' }} # Tests are too slow to run in emulation. Wait for real aarch64 agents
Expand Down
4 changes: 4 additions & 0 deletions docs/source/contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions docs/source/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ You'll need to build bitsandbytes from source. To compile from source, you need

```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 .
matthewdouglas marked this conversation as resolved.
Show resolved Hide resolved
```

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.
Expand Down
75 changes: 74 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,80 @@
[build-system]
requires = [ "setuptools", "wheel" ]
requires = ["setuptools >= 63.0.0"]
matthewdouglas marked this conversation as resolved.
Show resolved Hide resolved
build-backend = "setuptools.build_meta"

[project]
name = "bitsandbytes"
dynamic = ["version"]
description = "k-bit optimizers and matrix multiplication routines."
authors = [{name="Tim Dettmers", email="[email protected]"}]
requires-python = ">=3.8"
matthewdouglas marked this conversation as resolved.
Show resolved Hide resolved
readme = "README.md"
license = {file="LICENSE"}
matthewdouglas marked this conversation as resolved.
Show resolved Hide resolved
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need any version constraint at all? Maybe at least a minimum version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think we should have at least minimums, but I'm not sure what they should be. I took these runtime dependencies out of setup.py just as they were.

If it were up to me, I would pin torch>=1.13.0 on the low end for all platforms/backends assuming everything works. Why?

  • Oldest release which did not ship any wheels with CUDA < 11
    • Migrated to CUDA 11.6 and 11.7, which is right in line where I think bitsandbytes cutoff should be [1]
    • Apple silicon support (MPS) promoted from experimental/prototype to beta
  • AWS has HuggingFace containerswith the oldest having torch==1.13.1+cu117 on py3.9
    ** In general, all of the Python 3.9+ containers with PyTorch appear to be torch>=1.13.0
  • Azure Container for PyTorch still has a 1.13. configuration

But it could also be a little more permissive for some environments; e.g. transformers recently adopted a constraint of torch>=1.11,!=1.12.0 in huggingface/transformers#28207, which was also adopted in UKPLab/sentence-transformers#2432.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO (and I recognize this might ba a bit controversial) we should set minimum to what we test on, then pin to these when we test. I don't think we should overstretch to keep supporting old versions of dependencies at the expense of stability or complexity. So I would say ideally we set minimum to what we currently build on and either no upper bound or < next major.

As a user of any package I prefer to know what works or not and not having to be the guinea pig.

But this is my personal opinion, not sure what the rest of you think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would have a CI setup that could test a wider matrix so we can be confident about how we pin these, for sure.

For me part of the point of this bitsandbytes project is to try and make things accessible for a wide range of users - so that's across hardware, software, and user's expertise. Since many people, particularly in academia, don't have much control over things like OS, python version, or even torch version, we've got to support a large range in order to make things easy for users. That does come at the cost of maintenance, obviously. Need to find a good balance here.

So at least with this change it's being restricted to torch>=1.11,!=1.12.0, which is in line with transformers. I don't know that all of those versions of torch will work, but it's an incremental step forward compared to install_requires=["torch", "numpy"], and given the lack of issues around torch versions it does seem likely that it would work.

"numpy"
]

[project.optional-dependencies]
benchmark = ["pandas", "matplotlib"]
docs = ["hf-doc-builder", "black"]
dev = [
"bitsandbytes[test]",
"build",
matthewdouglas marked this conversation as resolved.
Show resolved Hide resolved
"ruff",
"pre-commit",
"wheel"
]
test = [
"einops~=0.6.0",
"lion-pytorch==0.0.6",
"pytest<8",
"pytest-cases",
"pytest-sugar",
"scipy",
"transformers"
]
triton = ["triton; sys_platform=='linux' and platform_machine=='x86_64'"]
matthewdouglas marked this conversation as resolved.
Show resolved Hide resolved

[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",
Expand Down
7 changes: 0 additions & 7 deletions requirements-ci.txt

This file was deleted.

9 changes: 0 additions & 9 deletions requirements-dev.txt

This file was deleted.

33 changes: 1 addition & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,17 @@
#
# 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):
def has_ext_modules(self):
return True


setup(
name="bitsandbytes",
version="0.43.0.dev0",
author="Tim Dettmers",
author_email="[email protected]",
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,
distclass=BinaryDistribution
)
Loading