Skip to content

test(cuda.core): drop numba from test_occupancy_max_potential_block_size_b2dsize - #3599

Merged
mdboom merged 1 commit into
NVIDIA:mainfrom
mdboom:issue3566
Nov 30, 2026
Merged

mdboom merged 1 commit into
NVIDIA:mainfrom
mdboom:issue3566

Conversation

@mdboom

@mdboom mdboom commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Closes #3566. Part of #2077.

Summary

test_occupancy_max_potential_block_size_b2dsize used numba for one thing: compiling the size_t (*)(int) block-size-to-dynamic-shared-memory callback (CUoccupancyB2DSize). The test skipped when numba was missing. None of the CI jobs that run cuda_core/tests/test_module.py install numba, so it never ran.

The callback is now a ctypes function:

-@pytest.mark.skipif(numba is None, ...)
 def test_occupancy_max_potential_block_size_b2dsize(...):
-    shared_memory_needed = numba.cfunc(size_t(intc))(...)
+    @ctypes.CFUNCTYPE(ctypes.c_size_t, ctypes.c_int)
+    def shared_memory_needed(block_size):
+        queried_block_sizes.append(block_size)
+        return 1024 * (block_size // 32)
     max_potential_block_size(CUoccupancyB2DSize(_ptr=<callback address>), block_size_limit)
+    assert queried_block_sizes                     # the driver called the callback
     (existing checks on min_grid_size and max_block_size)
  • Why ctypes works: the driver calls the callback synchronously, on the calling thread, while cuOccupancyMaxPotentialBlockSize runs. cuda.core keeps the GIL held for that call.
  • New assertion: the test records the block sizes the driver queries and asserts the callback was called. The existing checks alone would still pass if the callback were ignored.
  • Cleanup: the numba import and the "not currently run in any CI job" marker are removed. Nothing else in cuda_core/tests uses numba, and the test needs no new dependency.
  • Bindings: the CUDA 12 and CUDA 13 bindings tests use CUoccupancyB2DSize only to check its string form, without numba, so neither needs a matching change.

Evidence

Locally, Linux, on an RTX 5070 (CC 12.0) and an RTX A400 (CC 8.6):

  • Before: all 7 block_size_limit cases SKIPPED ("Test requires numba to be installed").
  • After: all 7 PASSED on both GPUs. All 56 occupancy tests in test_module.py also pass; on the A400, 3 cluster tests skip because it doesn't support clusters.

Confirming it runs in CI: in this PR's CI run, every cuda.core test job should report test_occupancy_max_potential_block_size_b2dsize[...] PASSED for all 7 cases, where main reports them SKIPPED. For example:

gh run view <CI run id> --repo NVIDIA/cuda-python --log | grep -F "test_occupancy_max_potential_block_size_b2dsize"

Merge Danger

Door: two-way. Test-only change.

Blast Radius: one test, which now runs on every cuda.core CI row. Windows hasn't been tested locally. The callback uses CFUNCTYPE (cdecl), and the driver declares it __stdcall; both are the same calling convention on x64 Windows, which is what CI runs.

Reviewers: please feel free to push commits directly to this PR to improve it.

🤖 Generated with Claude Code

…ize_b2dsize

The test used numba only to compile the size_t (*)(int) block-size-to-
dynamic-shared-memory callback, and skipped when numba was missing. No CI
job that runs test_module.py installs numba, so it never ran.

Build the callback with ctypes instead. The driver calls it synchronously
on the calling thread while cuOccupancyMaxPotentialBlockSize runs. Record
the block sizes the driver queries and assert that the callback was
called, so the test fails if the callback is ignored.

Closes NVIDIA#3566.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mdboom mdboom added this to the cuda.core 1.4.0 milestone Nov 25, 2026
@mdboom mdboom added test Improvements or additions to tests cuda.core Everything related to the cuda.core module labels Nov 25, 2026
@mdboom mdboom self-assigned this Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated the block-size occupancy test to run without Numba and verify that the callback is invoked.

The occupancy test removes its optional Numba import and replaces the Numba-compiled callback with a ctypes callback. It records queried block sizes and asserts that the callback ran.

Changes: Occupancy test

Layer / File(s) Summary
Replace Numba callback
cuda_core/tests/test_module.py
The occupancy test uses a ctypes callback to record queried block sizes and checks that the driver invoked it.

Assessment against linked issues

Objective Addressed Explanation
[#3566] Remove the Numba requirement and skip from the occupancy test. ✅
[#3566] Remove the comment that says the test does not run in CI. ❓ The supplied change summaries do not state whether this comment was removed.

Suggested reviewers: oleksandr-pavlyk, jpascucci-nv

Change: Other · Severity of issue fixed: Low

Merge Risk: Minimal · up to 50137

This change only updates a test so that it runs without Numba and checks that the occupancy callback is invoked. It has no production impact, and merge risk is minimal.

Security architecture risk: Minimal · up to 50137

The change removes the test’s optional Numba dependency and verifies that the CUDA driver calls the callback. It does not change the shipped API or deployment behavior.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c29b214 and 50137d3.

Files selected for processing: 1

  • cuda_core/tests/test_module.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 6 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

@jpascucci-nv jpascucci-nv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sol 6.1 high finds no actionable findings, and it lgtm.

@mdboom
mdboom merged commit daeda6d into NVIDIA:main Nov 30, 2026
227 of 229 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(cuda.core): drop numba from test_occupancy_max_potential_block_size_b2dsize so it runs in CI

2 participants