Skip to content

fix(cuda.core): waive unsupported samples and isolate capture tests - #3487

Open
rwgk wants to merge 6 commits into
mainfrom
rwgk/fix-orin-sample-capabilities
Open

rwgk wants to merge 6 commits into
mainfrom
rwgk/fix-orin-sample-capabilities

Conversation

@rwgk

@rwgk rwgk commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

— codex GPT-6 on behalf of Ralf —

Summary

With optional sample dependencies installed, three cuda.core samples fail on a headless Jetson AGX Orin Developer Kit because they attempt unavailable memory-pool or display operations.

Check the specific host-pool and IPC-pool capabilities, and waive the MLIR fluid sample when Linux has no display. Add six behavioral regression cases covering unsupported states and error propagation on supported paths.

Also isolate the memory-resource capture test from delayed buffer finalizers and always close its graph builder.

The original-error excerpts below omit machine-specific path prefixes and intermediate frames.


Commit 498b134ab fixes copyImageArraytoGPU on devices that support device memory pools but do not support host memory pools. Check host_memory_pools_supported before constructing the stream or pinned memory resource, and return the negotiated sample waiver code when unavailable.

Original error
File "samples/cuda_core/copyImageArraytoGPU/copyImageArraytoGPU.py", line 106, in copy_image_to_gpu_cuda_core
    pinned_mr = PinnedMemoryResource()
File "cuda/core/_memory/_memory_pool.pyx", line 422, in cuda.core._memory._memory_pool.MP_init_current_pool
cuda.core._utils.cuda_utils.CUDAError: CUDA_ERROR_NOT_SUPPORTED: This error indicates that the attempted operation is not supported on the current system or device.

Commit 09c50aa1e fixes ipcMemoryPool on devices with generic POSIX file-descriptor handle support but no POSIX-FD support for memory-pool IPC. Check the POSIX-FD bit in mempool_supported_handle_types before creating the IPC-enabled pool.

Original error
File "samples/cuda_core/ipcMemoryPool/ipcMemoryPool.py", line 172, in main
    mr = DeviceMemoryResource(
File "cuda/core/_memory/_memory_pool.pyx", line 391, in cuda.core._memory._memory_pool.MP_init_create_pool
cuda.core._utils.cuda_utils.CUDAError: CUDA_ERROR_INVALID_VALUE: This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values.

Commit bcf02a82d fixes glInteropFluidNumbaCudaMlir on headless Linux systems. Return the negotiated waiver code when DISPLAY is unset, before querying CUDA or importing the OpenGL window backend.

Original error
File "samples/cuda_core/glInteropFluidNumbaCudaMlir/glInteropFluidNumbaCudaMlir.py", line 478, in main
    window, gl, pyglet = create_window()
File "samples/cuda_core/glInteropFluidNumbaCudaMlir/glInteropFluidNumbaCudaMlir.py", line 405, in create_window
    from pyglet.gl import gl as _gl
pyglet.display.xlib.NoSuchDisplayException: Cannot connect to "None"

Commit 5838c4ea8 fixes test isolation in test_device_memory_resource_first_touch_under_capture. Unrelated buffer finalizers could run during the worker's capture and invalidate it. Collect that garbage with the worker's CUDA context current before capture, then close the graph builder in finally so a failed case cannot leave capture state behind.

Original error
cuda_core/tests/graph/test_graph_memory_resource.py:390: in worker
    result["building"] = gb.is_building
E   RuntimeError: Build process encountered an error and has been invalidated. Call end_building() to end it; the error is raised there.

The invalidated capture also caused subsequent capture and teardown failures:

E   cuda.core._utils.cuda_utils.CUDAError: CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED: This error indicates that the operation is not permitted when the stream is capturing.

Validation

Before the main merge below, all exercised CUDA 13 test suites finished with zero failures:

Suite Result
Pathfinder Python tests 1,650 passed, 4 skipped
Bindings Python tests 712 passed, 113 skipped, 2 subtests passed
Core Python tests 4,053 passed, 571 skipped, 3 xfailed, 1 xpassed, 9 subtests passed
Bindings Cython tests 9 passed
Core Cython tests 4 passed

The three original sample cases now report waivers for unavailable hardware or display capabilities. Existing native builds were reused.

Local pre-commit hooks pass except the full-repository TruffleHog scan, which repeatedly exits with SIGSEGV. The remaining hooks pass with that hook skipped for the invocation only; repository configuration is unchanged. TruffleHog also passes against all five changed files with zero findings.

A final empty CI-control commit keeps copy-pr-bot CI subject to manual approval.

Main merge and post-merge checks

Merged upstream main at 320532eb1 in merge commit 825d029ce. None of the five PR files changed during the merge, and the four fix commits above retain their identities.

Post-merge sample regression/waiver tests and CI bindings-floor reader tests: 40 passed. Local source checks pass apart from the same full-repository TruffleHog crash noted above.

The table records the pre-merge local runs. Full hosted CI subsequently rebuilt the packages and passed the complete matrix at merge head 825d029ce. Hosted Linux and Windows pre-commit checks also pass, including TruffleHog.

The Windows L4 CTK 13.0.2 bindings-floor job passed on an unchanged rerun. Its initial teardown OOM matches the Windows pinned-memory failures tracked in #3472.

Checklist

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

rwgk added 5 commits November 18, 2026 00:08
— codex GPT-6 on behalf of Ralf —

Device memory-pool support does not imply host memory-pool support.
Waive the pinned-memory sample before stream creation when host pools
are unavailable, and cover the waiver and supported-path error behavior.
— codex GPT-6 on behalf of Ralf —

Generic POSIX file-descriptor handle support does not guarantee memory
pool IPC support. Check the pool-specific POSIX-FD bit before creating
the pool, and test masks with and without that bit.
— codex GPT-6 on behalf of Ralf —

On headless Linux, waive before CUDA setup or OpenGL window creation.
Cover the negotiated waiver code and preserve CUDA setup errors when
a display is present.
— codex GPT-6 on behalf of Ralf —

Collect unrelated buffer finalizers with the worker context current
before capture begins. Always close the graph builder so an invalidated
capture cannot cause cascading failures in later tests.
@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Nov 18, 2026
@rwgk rwgk added the bug Something isn't working label Nov 18, 2026
@rwgk rwgk self-assigned this Nov 18, 2026
@rwgk rwgk added example Improvements or additions to code examples test Improvements or additions to tests labels Nov 18, 2026
@rwgk rwgk added this to the cuda.core 1.3.1 milestone Nov 18, 2026
@rwgk
rwgk marked this pull request as ready for review November 18, 2026 00:17
@rwgk

rwgk commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@nikshayshrivastava for visibility.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • CUDA samples now exit with a waiver instead of proceeding when required host memory-pool support or Linux display access is unavailable.
    • IPC memory-pool support checks now account for whether the device supports the required POSIX file-descriptor handle type.
    • Image-copy and MLIR graphics samples report unsupported runtime conditions more clearly.

The sample entry points now check memory-pool, IPC handle, and display support before proceeding. Tests cover these checks. The graph memory-resource test now collects garbage before capture and closes the graph builder in a finally block.

Changes: CUDA sample checks

Layer / File(s) Summary
Memory-pool and IPC checks
samples/cuda_core/copyImageArraytoGPU/copyImageArraytoGPU.py, samples/cuda_core/ipcMemoryPool/ipcMemoryPool.py, cuda_core/tests/example_tests/test_sample_verification.py
The image sample waives execution when host memory pools are unsupported. The IPC sample reports unsupported status when POSIX-fd handles are unavailable. Tests cover these conditions and verify that stream-creation errors propagate when host memory pools are supported.
Linux display check
samples/cuda_core/glInteropFluidNumbaCudaMlir/glInteropFluidNumbaCudaMlir.py, cuda_core/tests/example_tests/test_sample_verification.py
The MLIR sample waives execution on Linux when DISPLAY is unset. Tests verify the waiver and confirm that the CUDA availability query runs when DISPLAY is set.

Graph capture test

Layer / File(s) Summary
Capture setup and cleanup
cuda_core/tests/graph/test_graph_memory_resource.py
The worker collects garbage before capture and closes the graph builder in a finally block.

Suggested reviewers: andy-jost

Change: Bug fix

Merge Risk: Minimal · up to 825d0

This change makes three samples waive cleanly when host memory pools, POSIX-fd IPC handles, or a Linux display are unavailable, and it makes a graph-capture test clean up more reliably. No merge-blocking risk was identified.

Security architecture risk: Minimal · up to 825d0

The changes avoid unsupported sample operations and improve cleanup in a graph-capture test. Inspection found no introduced or worsened risk materially affecting security, failure containment, rollback, or ownership guarantees.

- [ ] 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 320532e and 825d029.

Files selected for processing: 5

  • cuda_core/tests/example_tests/test_sample_verification.py
  • cuda_core/tests/graph/test_graph_memory_resource.py
  • samples/cuda_core/copyImageArraytoGPU/copyImageArraytoGPU.py
  • samples/cuda_core/glInteropFluidNumbaCudaMlir/glInteropFluidNumbaCudaMlir.py
  • samples/cuda_core/ipcMemoryPool/ipcMemoryPool.py

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

@rwgk

rwgk commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 825d029

@github-actions

Copy link
Copy Markdown
Contributor

@rwgk
rwgk requested a review from Andy-Jost November 18, 2026 02:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module example Improvements or additions to code examples test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant