Skip to content

Fix invalid device context error in ValidIfTest.ExplicitMemoryResourcesEmptyRange - #23704

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
davidwendt:valid-if-memcheck
Aug 18, 2026
Merged

Fix invalid device context error in ValidIfTest.ExplicitMemoryResourcesEmptyRange#23704
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
davidwendt:valid-if-memcheck

Conversation

@davidwendt

Copy link
Copy Markdown
Contributor

Description

Fixes the BITMASK_TEST ValidIfTest.ExplicitMemoryResourcesEmptyRange failure when run with the cuda memory resource:

$ gtests/BITMASK_TEST --gtest_filter=ValidIfTest.ExplicitMemoryResourcesEmptyRange --rmm_mode=cuda
Note: Google Test filter = ValidIfTest.ExplicitMemoryResourcesEmptyRange
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ValidIfTest
[ RUN      ] ValidIfTest.ExplicitMemoryResourcesEmptyRange
unknown file: Failure
C++ exception with description "/cudf/cpp/build/_deps/cccl-src/lib/cmake/libcudacxx/../../../libcudacxx/include/cuda/__driver/driver_api.h:664 invalid device context(201): Failed to synchronize a stream" thrown in the test body.

[  FAILED  ] ValidIfTest.ExplicitMemoryResourcesEmptyRange (3 ms)

The ExplicitMemoryResourcesEmptyRange test was calling harness.synchronize(stream) and harness.expect_no_live_allocations(stream) — both of which invoke cuda::stream_ref::sync() (which uses the CUDA driver API cuStreamSynchronize). Unlike the runtime API, the driver API requires an active CUDA context. For the empty-range case, valid_if makes no GPU calls at all (zero-size buffer, no kernel), so the context is never initialized, causing CUDA_ERROR_INVALID_CONTEXT (201).

The fix removes both sync calls — they're unnecessary because an empty range produces no GPU work and no allocations. The existing .total == 0 counter assertions are stricter than what expect_no_live_allocations checked .value == 0, so test coverage is preserved.

Error introduced by #23490

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@davidwendt davidwendt self-assigned this Aug 18, 2026
@davidwendt
davidwendt requested a review from a team as a code owner August 18, 2026 14:57
@davidwendt davidwendt added bug Something isn't working 3 - Ready for Review Ready for review by team libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a1a8345c-fd3c-4497-8823-ae2f5dc0d206

📥 Commits

Reviewing files that changed from the base of the PR and between a98ad61 and d7a387a.

📒 Files selected for processing (1)
  • cpp/tests/bitmask/valid_if_tests.cu

Included review availability: Your plan includes up to 12 reviews per rolling hour; 11 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Updated an empty-range memory-resource test to correctly handle cases where no GPU operations or allocations occur.
    • Removed unnecessary synchronization and allocation checks, improving test reliability.

Walkthrough

The empty-range memory-resource test now returns the scoped valid_if result directly. It removes synchronization and live-allocation checks because the empty range performs no GPU work or allocations.

Changes

valid_if test update

Layer / File(s) Summary
Empty-range test behavior
cpp/tests/bitmask/valid_if_tests.cu
The test removes explicit stream synchronization and the live-allocation assertion. It documents the absence of GPU work and allocations for an empty range.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to d7a38

This localized test-only change removes unnecessary synchronization for an empty-range case without changing product behavior. No actionable merge-blocking risk remains, so it is merge-ready after normal checks and review.

Suggested reviewers: abigalekim, pointkernel, bdice

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the invalid device context failure and the removal of unnecessary synchronization calls.
Title check ✅ Passed The title clearly identifies the invalid device context error and the affected ValidIfTest test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@davidwendt

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 0304fb0 into NVIDIA:main Aug 18, 2026
153 checks passed
@davidwendt
davidwendt deleted the valid-if-memcheck branch August 18, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review Ready for review by team bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants