Repository navigation
Conversation
…and VMM Audit follow-up for the `simt` compatibility surface in cuda-core and cuda-async and for both VMM modules. Kept separate from the host-runtime patch because it changes cuda-oxide-facing APIs and is not part of 0.3.1. Soundness - Synchronize wrappers reported the recorded (sticky) context error before the driver wait, so DeviceBuffer copies returned Err while the DMA still wrote the caller's host memory (reproduced). CudaStream, CudaContext and CudaEvent::synchronize now wait first and report the sticky error after; DeviceBuffer binds and drains the sticky state before enqueueing, and leaks host memory rather than free it when the driver wait itself fails. - CudaStream::launch_host_function requires F: 'static (a closure borrowing a local compiled and ran after its frame was gone), reclaims the box when the enqueue fails, and documents the callback rules. - cuda_async::simt::Empty and Value derive Send from their fields; the unconditional `unsafe impl Send` laundered !Send closures. - The execute-once unzip halves (SelectLeft/SelectRight) replace their unsynchronized UnsafeCell check-then-act with a mutex/condvar ExecuteOnce; a consumer on another stream waits on an event the producer records. - ConstantHandle carries its symbol size and an Arc<CudaModule>; oversize writes and foreign-context streams are rejected; it is no longer Copy. - DeviceCopy for raw pointers excludes unsized pointees (a wide pointer read back from device bytes carried an invalid vtable). - Mapping<'a> borrows its VirtualReservation and its PhysicalAllocation or MulticastObject, and MulticastBinding<'a> borrows its MulticastObject, in both cuda-core/src/vmm.rs and simt/vmm.rs; unmap is documented as not stream-ordered. Correctness - DeviceBuffer constructors bind the stream's context; they failed on an unbound thread and could allocate in a foreign context. - Drop paths release resources regardless of a sticky error; async buffers leaked while an error was recorded. - The thread-local device map survives failed lookups and re-entrant sync; SingleStream reports use-before-init instead of panicking; a colliding kernel-cache insert keeps the existing entry. - simt::vmm::align_size handles any granularity with checked arithmetic; streams are counted only after cuStreamCreate succeeds; PinnedHostBuffer checks the host pointer's alignment for T. Docs: stale "opaque CUlaunchAttribute_st" comments, the simt collision list, embedded-module docs, the CoordinateRequirement re-export, and the cuda-core README's description of the two host models. Breaking for cuda-oxide: ConstantHandle::from_raw(module, dptr, size) and write_blocking(src, len); Mapping::new(&reservation, va_offset, &phys, phys_offset, size) and new_multicast(...) with the new lifetimes; launch_host_function F: 'static; Empty F: Send. Tests: new GPU suites simt_module_globals and simt_execute_once, and new cases in simt_device_buffer, simt_device_buffer_leaks, simt_device_copy_impls, vmm and simt_vmm_p2p; the sticky-error and leak tests fail without the fixes. The simt_device_buffer file is serialized to avoid a pre-existing driver-level deadlock between a gated host callback and concurrent cuMemFree/cuStreamDestroy. Signed-off-by: Melih Elibol <elibol@users.noreply.github.com>
elibol
requested review from
kkraus14,
nihalpasham and
rparolin
as code owners
October 8, 2026 00:44
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transplant of NVlabs/cutile-rs#257 (NVlabs/cutile-rs#257) onto cuda-rust after the repository move: one commit, original author and sign-off, host-crate paths following the move to the repository root.
Audit follow-up for the
simtcompatibility surface in cuda-core and cuda-async and for both VMM modules. Separate from the host-runtime patch because it changes cuda-oxide-facing APIs and is not part of 0.3.1.Soundness
DeviceBuffercopies returnedErrwhile the DMA still wrote the caller's host memory (reproduced).CudaStream,CudaContext, andCudaEvent::synchronizenow wait first and report the sticky error after;DeviceBufferbinds and drains the sticky state before enqueueing, and leaks host memory rather than free it when the driver wait itself fails.CudaStream::launch_host_functionrequiresF: 'static, reclaims the box when the enqueue fails, and documents the callback rules.cuda_async::simt::EmptyandValuederiveSendfrom their fields instead of an unconditionalunsafe impl Send.UnsafeCellcheck-then-act with a mutex/condvarExecuteOnce; a consumer on another stream waits on an event the producer records.ConstantHandlecarries its symbol size and anArc<CudaModule>, rejects oversize writes and foreign-context streams, and is no longerCopy.DeviceCopyfor raw pointers excludes unsized pointees.Mapping<'a>borrows itsVirtualReservationand itsPhysicalAllocationorMulticastObject, andMulticastBinding<'a>borrows itsMulticastObject, in both VMM modules. Unmap is documented as not stream-ordered.Correctness
DeviceBufferconstructors bind the stream's context; drop paths release resources regardless of a sticky error; the thread-local device map survives failed lookups and re-entrantsync;SingleStreamerrors instead of panicking before init; a colliding kernel-cache insert keeps the existing entry;simt::vmm::align_sizeuses checked arithmetic for any granularity; streams are counted only after creation succeeds;PinnedHostBufferchecks host pointer alignment.Breaking for cuda-oxide
ConstantHandle::from_raw(module, dptr, size)andwrite_blocking(src, len);Mapping::new(&reservation, va_offset, &phys, phys_offset, size)andnew_multicast(...)with the new lifetimes;launch_host_functionF: 'static;EmptyF: Send.Verification on an RTX 5090 with CUDA 13.3: fmt, build, clippy with no new warnings, the CPU test script, and the GPU test script. New GPU suites
simt_module_globalsandsimt_execute_once, plus new cases insimt_device_buffer,simt_device_buffer_leaks,simt_device_copy_impls,vmm, andsimt_vmm_p2p; the sticky-error and leak tests fail without the fixes.simt_device_bufferis serialized to avoid a pre-existing driver-level deadlock between a gated host callback and concurrentcuMemFree/cuStreamDestroy.