Fix host copy source lifetime

Open
#1,421 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

The referenced work is in cuda-core/src/runtime.rs, cutile/src/api.rs, and a GPU execution test for copy_host_vec_to_device_keeps_source_alive_until_stream_completion. First read the “Transplanting a cutile-rs pull request” section in AGENTS.md; the prior pull request is closed in the archived repository, and its branch conflicts in the listed files. Done means recreating the work against this repository and validating it, though the reported CUDA toolkit requirement may block local tests.

Written by the indexing model from the issue text.

Description

cutile-rs post-migration-pr

Tracks pull request NVlabs/cutile-rs#168 (https://github.com/NVlabs/cutile-rs/pull/168) by @fallintoplace, opened 2026-06-19: Fix host copy source lifetime. As of 2026-10-07 the branch conflicts with cutile-rs main in: cuda-core/src/runtime.rs, cutile/src/api.rs.

@fallintoplace: that repository has moved here and is being archived, so the pull request is closed there, not rejected. If you want to continue the work, please recreate it against NVIDIA/cuda-rust. AGENTS.md in NVIDIA/cuda-rust has a "Transplanting a cutile-rs pull request" section that lets an agent do the replay (it fetches pull/168/head from NVlabs/cutile-rs, keeps your authorship and sign-off, and maps the moved paths).


Original description:

Summary

  • Keep the Arc<Vec<T>> source for copy_host_vec_to_device alive until the CUDA stream reaches a host callback queued after the H→D copy.
  • Tighten Stream::launch_host_function so callbacks must be 'static and the boxed callback is reclaimed if enqueueing fails.
  • Add a regression test that blocks the stream before the copy, drops the caller's Arc, and verifies the source stays alive until stream completion.

Root Cause

CopyHostVecToDevice::execute enqueued memcpy_htod_async with vec.as_ptr() and then returned a Tensor, letting the operation-owned Arc<Vec<T>> drop immediately. Awaiting the DeviceFuture waited for stream completion, but nothing kept the host source buffer alive while the copy was still pending.

Validation

  • cargo fmt --check
  • git diff --check
  • cargo test -p cutile --test gpu_execution_ops copy_host_vec_to_device_keeps_source_alive_until_stream_completion -- --nocapture blocked locally because CUDA_TOOLKIT_PATH is unset and no CUDA 13.2+ toolkit exists at the default /usr/local/cuda* paths.
  • cargo check -p cutile blocked for the same missing CUDA toolkit.
Dominant language
Rust
Stars
3.9k
Forks
349
Avg merge
3d 18h
Merged PRs (30d)
83

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/cuda-rust

All issues in NVIDIA/cuda-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.