-
Notifications
You must be signed in to change notification settings - Fork 170
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
[FEA]: Introduce Python module with CCCL headers #3201
base: main
Are you sure you want to change the base?
Changes from 8 commits
daab580
ef9d5f4
bc116dc
2913ae0
7dbb82b
0703901
fc0e543
2e64345
82467cd
f13a96b
9ed6036
c9a4d96
df943c0
40c8389
e3c7867
acbd477
06f575f
e747768
499b191
62ce2d3
65c5a15
bffece6
585447c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Is it possible that we consolidate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created #3212 to look into this later. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cuda/_include | ||
*egg-info |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `cuda.cccl`: Experimental CUDA Core Compute Library Python module with CCCL headers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we should consider the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have reservation on this, if considering the mirroring to conda packages (#3201 (comment)). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I waasn't aware there's a conda package called |
||
|
||
## Documentation | ||
|
||
Please visit the documentation here: https://nvidia.github.io/cccl/python.html. | ||
|
||
## Local development | ||
|
||
```bash | ||
pip3 install . | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it's appropriate to document that this package is currently for internal use only and not meant to be used/installed explicitly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: c9a4d96 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# This file is generated by ci/update_version.sh | ||
# Do not edit this file manually. | ||
__version__ = "0.1.2.8.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
[build-system] | ||
requires = ["packaging", "setuptools>=61.0.0", "wheel"] | ||
build-backend = "setuptools.build_meta" |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||||
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||||||||
# | ||||||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||||
|
||||||||
import os | ||||||||
import shutil | ||||||||
|
||||||||
from setuptools import setup, find_namespace_packages | ||||||||
|
||||||||
|
||||||||
project_path = os.path.abspath(os.path.dirname(__file__)) | ||||||||
cccl_path = os.path.abspath(os.path.join(project_path, "..", "..")) | ||||||||
cccl_headers = [["cub", "cub"], ["libcudacxx", "include"], ["thrust", "thrust"]] | ||||||||
__version__ = None | ||||||||
with open(os.path.join(project_path, "cuda", "cccl", "_version.py")) as f: | ||||||||
exec(f.read()) | ||||||||
assert __version__ is not None | ||||||||
ver = __version__ | ||||||||
del __version__ | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: These can be moved to pyproject.toml cleanly, see, e.g. how we do it in cuda.core: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: commit 40c8389 |
||||||||
|
||||||||
|
||||||||
with open("README.md") as f: | ||||||||
long_description = f.read() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this can be moved to pyproject.toml too, ex: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: commit 40c8389 |
||||||||
|
||||||||
|
||||||||
def copy_cccl_headers_to_cuda_include(): | ||||||||
inc_path = os.path.join(project_path, "cuda", "_include") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important: Can we please establish the right layout before merging? There is a new wheel layout being communicated internally. This should be something like
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done: commit e3c7867 I'm not sure about two aspects:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@rwgk we add path to CUDA Toolkit (CTK) headers here:
CTK provides CUB headers as well. Tests likely pass because they use CTK version of CUB. We should add a static assert somewhere in cuda.cooperative to check that we use version of CUB that cuda.cooperative was "build" with. |
||||||||
for proj_dir, header_dir in cccl_headers: | ||||||||
src_path = os.path.abspath(os.path.join(cccl_path, proj_dir, header_dir)) | ||||||||
dst_path = os.path.join(inc_path, proj_dir) | ||||||||
if os.path.exists(dst_path): | ||||||||
shutil.rmtree(dst_path) | ||||||||
shutil.copytree(src_path, dst_path) | ||||||||
init_py_path = os.path.join(inc_path, "__init__.py") | ||||||||
with open(init_py_path, "w") as f: | ||||||||
print("# Intentionally empty.", file=f) | ||||||||
|
||||||||
|
||||||||
copy_cccl_headers_to_cuda_include() | ||||||||
|
||||||||
setup( | ||||||||
name="cuda-cccl", | ||||||||
version=ver, | ||||||||
description="Experimental Package with CCCL headers to support JIT compilation", | ||||||||
long_description=long_description, | ||||||||
long_description_content_type="text/markdown", | ||||||||
author="NVIDIA Corporation", | ||||||||
classifiers=[ | ||||||||
"Programming Language :: Python :: 3 :: Only", | ||||||||
"Environment :: GPU :: NVIDIA CUDA", | ||||||||
], | ||||||||
packages=find_namespace_packages(include=["cuda.*"]), | ||||||||
python_requires=">=3.9", | ||||||||
include_package_data=True, | ||||||||
license="Apache-2.0 with LLVM exception", | ||||||||
license_files=("../../LICENSE",), | ||||||||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
cuda/_include | ||
env | ||
*egg-info |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
cuda/_include | ||
env | ||
*egg-info | ||
*so |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,16 @@ Please visit the documentation here: https://nvidia.github.io/cccl/python.html. | |
|
||
## Local development | ||
|
||
First-time installation: | ||
|
||
```bash | ||
pip3 install ./cuda_cccl | ||
pip3 install ./cuda_parallel[test] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be editable if necessary? Wouldn't a regular install here and then an editable install below would lead to two copies of the package in the environment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can! Thanks for asking. Previously I was incorrectly thinking that one pass without I restored the original README.md: commit 9ed6036
From what I can tell, the 2nd install clobbers the previous one. |
||
pytest -v ./cuda_parallel/tests/ | ||
``` | ||
|
||
For faster iterative development: | ||
|
||
```bash | ||
pip3 install -e .[test] | ||
pytest -v ./tests/ | ||
pip3 install -e ./cuda_parallel[test] | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong, we need the headers to track C++ versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: commit df943c0