Skip to content

Unify the async host runtime and remove cuda_async::simt - #1604

Open
elibol wants to merge 8 commits into
NVIDIA:pull-request/1603from
elibol:refactor/shared-cuda-async
Open

elibol wants to merge 8 commits into
NVIDIA:pull-request/1603from
elibol:refactor/shared-cuda-async

Conversation

@elibol

@elibol elibol commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Tile operations and SIMT launches currently use separate async runtimes and cannot compose through the same operation types. This change removes cuda_async::simt and routes both programming models through the shared DeviceOp, DeviceFuture, execution context, scheduler, errors and launch API.

Closes #1461. Stacked on #1603, which supplies the shared core types and storage. The base is its existing pull-request/1603 mirror so this diff contains only the async migration; retarget after the prerequisite merges. Both feature branches are hosted on the contributor's fork.

  • One KernelArgument blanket implementation uses DeviceCopy. Generic Tile scalars require DType + DeviceCopy; tensor-only type parameters retain their independent DType contract. The shared argument arena preserves inline storage, padded values, over-alignment and typed destruction for the explicit unsafe boxed-argument escape hatch.
  • An inert AsyncKernelLaunchBuilder requires unsafe finalization before becoming a schedulable, immutable launch. Generated typed launchers retain their checked boundaries. Tile PDL and SIMT cluster/cooperative launch paths are preserved. Raw async macros marshal slice pointers and lengths as direct scalar values; optional CPU-reference examples use the corresponding scalar bounds.
  • Launches retain their function/module, allocation owners and access leases before enqueueing work. Early future drop retires owners on completion without waiting on the GPU. Partial errors and panics retain submitted resources; unknown completion deliberately leaks owners and exclusion. Forgotten futures also retain their submissions indefinitely. Outputs can contain ordinary Rust borrows and must be valid to drop during submission, as required by host combinators.
  • Graphs retain captured resources and reacquire allocation access on every replay. DeviceBox transfers to/from shared typed buffers without copying and preserves ordinary read permissions. Existing DeviceOperation, and_then, apply and arc spellings delegate to the shared implementations.
  • cutile_inter_kernel now uses the normal shared launch API to update the Tile-produced allocation in place, checks its pointer and allocation identity, and verifies results. Consumers, generated-project templates, documentation, UI fixtures and GPU test entry points are migrated. AGENTS.md records that future branches must originate from the user's fork.

Validation: shared async tests and doctests; Tile unit, aggregate GPU, submission-lifetime, interop and UI tests; cuda-host/cuda-macros suites; 268 cargo-oxide tests; four explicit SIMT lifetime/concurrency GPU tests. Both cargo oxide run cutile_inter_kernel and cargo oxide run async_mlp pass. Miri passes all seven argument-storage tests, and Loom passes the completion-handoff model. Host/Tile/affected SIMT clippy checks, formatting, strict async rustdoc, SPDX/API-path guards and Tile dependency checks pass.

GPU execution was validated on one RTX 5090. This does not add multi-GPU/NVLink hardware coverage. API migration and custom-operation retention obligations are documented in cuda-async/README.md.

Additional validation: the full CPU runner passes (1,381 tests; 94 intentionally ignored), all top-level SIMT example workspaces pass Clippy with warnings denied, and all 144 macro unit tests pass. The host_closure GPU example also passes all 13 scenarios, covering the corrected async slice argument marshalling.

Current follow-up validation after incorporating the updated #1516/#1603 stack: all 1,394 CPU tests pass (95 intentionally ignored), as do 138 selected Tile GPU/interop/graph/view/lifetime tests and all four explicit SIMT lifetime/concurrency tests. The original stress reproducer reports no false negatives in 1,000,000 raw-buffer uniqueness checks and no false positives in 100,000 aliased-tensor partition attempts. Nihal's DeviceBox::from_raw_parts shared-read fix remains included.

Restored the original cutile-rs unsafe async_on() contract: the caller independently keeps all submitted resources alive and orders their accesses. On return, including an error, async_on() releases runtime owners and access leases without synchronization or background retention. Safe futures retain their nonblocking completion-based cleanup. The existing four-tensor launch benchmark now measures 1.88 µs/launch, down from 4.95 µs before this fix (earlier main baseline: 1.68 µs). No batching or new launch API is needed for this fix.

Current-main integration: Merged the updated #1603 prerequisite, including the CuTe host-consumer migration. The cuda-host, cuda-macros, ctm-rs and cute-rs suites pass (497 tests, 43 intentionally ignored), together with affected-package Clippy and all 16 CuTe example/model workspace Clippy checks. Fresh CI is running at 52dccfed1f; the preceding head had all 63 active checks passing.

Validation for b811b7067: all 133 cuda-async tests pass (14 intentionally ignored), all 11 Tile submission-lifetime tests and all four SIMT lifetime/concurrency GPU tests pass, and Clippy/formatting/rustdoc checks pass. Both new gated-stream regressions fail on the preceding code and pass here. Fresh CI is running.

Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
@elibol
elibol force-pushed the refactor/shared-cuda-async branch from e97d214 to fcfe932 Compare October 21, 2026 23:13
elibol and others added 2 commits October 21, 2026 16:22
…uncher

Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
…viceBox::from_raw_parts and update docs

Signed-off-by: nihalpasham <nihalp@nvidia.com>
@nihalpasham

Copy link
Copy Markdown
Collaborator

Looks good! Pushed a small commit (c68eee09e) on top:

  • DeviceBox::from_raw_parts had shared_access_writes: true, which caused concurrent read-only launches across streams to fail with CUDA_ERROR_NOT_READY (same thing device_box_preserves_concurrent_read_permissions checks for from_buffer). Bounded from_raw_parts on Copy and set shared_access_writes = false.
  • Updated the doc comment on pub use cuda_async; in cuda-host and a few DeviceBox::from_raw_parts snippets in the book/READMEs to pass stream.clone().

Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>

# Conflicts:
#	cutile-rs/cutile/src/tensor.rs
Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
@elibol

elibol commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator Author

@nihalpasham Thanks for the review and fixes. Your commit c68eee09e is preserved: DeviceBox::from_raw_parts has the Copy bound and ordinary shared-read permissions, and the documentation/examples include the stream.clone() updates.

The branch now includes the updated #1516/#1603 stack and its tensor/allocation uniqueness fixes. All of your feedback is incorporated, and all 63 active CI checks pass at 6d311cbc53, including CodeQL. The Tile/SIMT shared-allocation example, graph/lifetime tests, and explicit SIMT lifetime/concurrency GPU tests also pass.

The measured per-launch overhead remains a separate follow-up; these correctness fixes do not claim to resolve it.

Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
@elibol

elibol commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator Author

Restored the original cutile-rs unsafe async_on() behavior in b811b7067: caller-managed lifetimes and ordering, with no automatic retention after return. Safe-future cleanup remains nonblocking and protected. The existing launch benchmark improves from 4.95 to 1.88 µs (earlier baseline: 1.68 µs). Gated success/error regressions and Tile/SIMT lifetime tests pass, along with the full cuda-async suite and lint checks.

@nihalpasham nihalpasham added this to the cuda oxide v0.4.0 milestone Oct 25, 2026

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants