Skip to content

Add borrowed DeviceBuffer subviews for typed kernel launches - #1081

Closed
uurl wants to merge 1 commit into
NVIDIA:mainfrom
uurl:feat/device-buffer-subviews-968
Closed

uurl wants to merge 1 commit into
NVIDIA:mainfrom
uurl:feat/device-buffer-subviews-968

Conversation

@uurl

@uurl uurl commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

Borrowed DeviceBuffer subviews let a typed kernel operate on part of an allocation while the parent buffer retains ownership. Partially addresses #968.

Shape of the change

  • Add immutable and mutable views with checked ranges and consuming mutable splits.
  • Pass each view through the existing pointer/length launch packet.
  • Extend generated synchronous launchers to accept the new slice argument traits.
parent allocation: [ a b | c d e | f ]
borrowed view:            c d e
kernel packet:           pointer + length 3

Validation

  • Focused runtime, host and macro checks passed on the submitted head.
  • Borrowing controls cover parent lifetimes and disjoint mutable views.

Remaining work

The runtime API must first land in its current owner, cutile-rs. Main now consumes cuda-core 0.3.1 from that project; the local runtime crates changed here were removed. Publish the view API there, update the shared dependency pins, then port the launcher integration to current main. GPU validation remains pending that integration.

@nihalpasham nihalpasham added enhancement New feature or request host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) on-hold Paused: valid but deferred until a prerequisite decision or dependency resolves labels Aug 20, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Putting this on hold, not for code reasons: the host crates (cuda-core, cuda-host, cuda-async) are effectively frozen while we move to shared, published host crates ahead of the mono-repo consolidation. The substantive new surface here (DeviceSlice, DeviceSliceMut, slice/slice_mut on DeviceBuffer) lands in cuda-core, which is the crate being replaced, so merging now means re-porting the API immediately after.
  • The work itself held up under review: all offset arithmetic is checked, mutable views have no Copy/Clone and split by value so overlapping mutable views cannot exist, the generated-launcher change to impl KernelSliceArg broke no example in the full corpus, and the GPU-backed subview tests pass locally (RTX 5090), with cuda_module_api green with and without --features async.
  • Once the shared crates are in place we would take a re-targeted version of this; the borrowck-enforced disjoint-halves launch model is the right design for Feature request: borrowed DeviceBuffer subviews for typed kernel launches #968.

@nihalpasham nihalpasham added post-migration-pr Depends Blocked on another PR/issue or an upstream dependency labels Aug 20, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

This PR remains on hold for the host-API migration described above; this is not a code-quality hold and is separate from #413.

  • Review can resume after the shared host crates stabilize and this API is retargeted onto them.
  • The refreshed branch should include a real middle-subview/async runtime case and compile-fail lifetime coverage on the final API.
  • Until then, merging would create an API that immediately needs to be ported again.

When the work is retargeted, please keep the scope and before/after evidence aligned with the current acceptance criteria.

@uurl

uurl commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Understood. I’ll land the borrowed DeviceSlice / DeviceSliceMut API in cutile-rs first and wait for the shared-crate release. After that I’ll update the shared pins here, port the launcher integration to the current macro structure, rebase this PR, and keep the revised commits signed off.

drbh added a commit to drbh/cuda-oxide that referenced this pull request Sep 17, 2026
Sync launchers now accept impl KernelSliceArg and impl KernelSliceArgMut, matching the generic async slice contracts.

RowWidth gains a defaulted buffer type parameter, so existing RowWidth::new(&mut c, n) calls remain unchanged. The slice traits are available without the async feature. Caller-defined views now typecheck through sync, async, and owned launchers.

Retargets the launcher half of NVIDIA#1081 and NVIDIA#968.

Signed-off-by: David Holtz <[email protected]>
@nihalpasham nihalpasham added the device-apis User-facing device-side and kernel-authoring APIs (cuda-device, cuda-macros) label Sep 23, 2026
@uurl

uurl commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Understood. I’ll move the borrowed view API and its lifetime/disjoint-range coverage to cutile-rs first. Once that shared runtime API is merged and published, I’ll update the dependency pins here, rebase this branch onto current main, and port the typed-launch integration and regressions to the current launcher/macro structure with signed commits.

@nihalpasham
nihalpasham dismissed stale reviews from themself September 23, 2026 08:21

Withdrawn: this host-crate API belongs in cutile-rs. Leave this PR on hold without changes requested here.

@nihalpasham nihalpasham removed needs-changes Review found changes required before this PR can land device-apis User-facing device-side and kernel-authoring APIs (cuda-device, cuda-macros) labels Sep 23, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Closing this as we'll anyway need to move this over post mono-repo migration

@uurl
uurl deleted the feat/device-buffer-subviews-968 branch November 21, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Depends Blocked on another PR/issue or an upstream dependency enhancement New feature or request host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) on-hold Paused: valid but deferred until a prerequisite decision or dependency resolves post-migration-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants