Skip to content

Add back CuPy as an optional test dependency + Fix an example bug #334

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

Merged
merged 6 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
9 changes: 3 additions & 6 deletions .github/workflows/gh-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ jobs:
- name: Run cuda.core tests
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then
if [[ ${{ matrix.python-version }} == "3.13" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious, what was the motivation for switching the order of ifs around here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I wrote this check and I got myself confused about what it meant. In a few weeks this part will be nuked.

# TODO: remove this hack once cuda-python has a cp313 build
if [[ ${{ matrix.python-version }} == "3.13" ]]; then
if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then
echo "Python 3.13 + cuda-python ${{ matrix.cuda-version }} is not supported, skipping the test..."
exit 0
fi
Expand All @@ -316,9 +316,6 @@ jobs:
popd

pushd ./cuda_core
# TODO: add requirements.txt for test deps?
pip install pytest
# TODO: add CuPy to test deps (which would require cuRAND)
# pip install "cupy-cuda${TEST_CUDA_MAJOR}x"
pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt"
pytest -rxXs tests/
popd
9 changes: 5 additions & 4 deletions cuda_core/examples/saxpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
# prepare input/output
size = cp.uint64(64)
a = dtype(10)
x = cp.random.random(size, dtype=dtype)
y = cp.random.random(size, dtype=dtype)
rng = cp.random.default_rng()
x = rng.random(size, dtype=dtype)
y = rng.random(size, dtype=dtype)
out = cp.empty_like(x)
dev.sync() # cupy runs on a different stream from s, so sync before accessing

Expand All @@ -73,8 +74,8 @@
# prepare input
size = cp.uint64(128)
a = dtype(42)
x = cp.random.random(size, dtype=dtype)
y = cp.random.random(size, dtype=dtype)
x = rng.random(size, dtype=dtype)
y = rng.random(size, dtype=dtype)
dev.sync()

# prepare output
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/examples/strided_memory_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
gpu_prog = Program(gpu_code, code_type="c++")
# To know the GPU's compute capability, we need to identify which GPU to use.
dev = Device(0)
dev.set_current()
arch = "".join(f"{i}" for i in dev.compute_capability)
mod = gpu_prog.compile(
target_type="cubin",
Expand Down Expand Up @@ -156,7 +157,6 @@ def my_func(arr, work_stream):

# This takes the GPU path
if cp:
dev.set_current()
s = dev.create_stream()
# Create input array on GPU
arr_gpu = cp.ones(1024, dtype=cp.int32)
Expand Down
5 changes: 3 additions & 2 deletions cuda_core/examples/vector_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@

# prepare input/output
size = 50000
a = cp.random.random(size, dtype=dtype)
b = cp.random.random(size, dtype=dtype)
rng = cp.random.default_rng()
a = rng.random(size, dtype=dtype)
b = rng.random(size, dtype=dtype)
c = cp.empty_like(a)

# cupy runs on a different stream from s, so sync before accessing
Expand Down
3 changes: 3 additions & 0 deletions cuda_core/tests/requirements-cu11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
# TODO: remove this hack once cupy has a cp313 build
cupy-cuda12x; python_version < "3.13"
3 changes: 3 additions & 0 deletions cuda_core/tests/requirements-cu12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
# TODO: remove this hack once cupy has a cp313 build
cupy-cuda12x; python_version < "3.13"
Loading