feat(cuda-core): borrow external streams as CudaStream
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 20/100
Research direction
The proposed behavior is described for CudaStream::borrow_raw, with a test named cuda-core/tests/borrow_raw.rs and a required CHANGELOG entry. Start by reading AGENTS.md's “Transplanting a cutile-rs pull request” section: this issue tracks an existing pull request from the archived repository, and the work is already implemented there. The issue asks for that pull request to be recreated against this repository; check the transplant instructions and verify the tests and checks listed in the original description.
Written by the indexing model from the issue text.
Description
Tracks pull request NVlabs/cutile-rs#315 (https://github.com/NVlabs/cutile-rs/pull/315) by @lucifer1004, opened 2026-09-25: feat(cuda-core): borrow external streams as CudaStream. The branch was rebased onto cutile-rs main on 2026-10-07 and merges cleanly.
@lucifer1004: 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/315/head from NVlabs/cutile-rs, keeps your authorship and sign-off, and maps the moved paths).
Original description:
Why
runtime::Stream::borrow_raw wraps a stream owned by another library. The SIMT layer's CudaStream, however, can only be created by cuda-core, and dropping it destroys the handle. Code that launches through the SIMT layer therefore cannot enqueue work on a caller's stream. This includes the typed launchers cuda-oxide generates, which take &CudaStream. Examples of such caller streams are a framework's current stream and the tvm-ffi environment stream, the stream a tvm-ffi exported kernel entry must launch on.
What
CudaStream::borrow_raw(cu_stream, ctx) wraps such a stream without taking ownership, mirroring Stream::borrow_raw. A new owned flag records ownership. Dropping a borrowed stream neither destroys the handle nor changes the context's stream count. Streams created by cuda-core are unchanged. There is a CHANGELOG entry.
Tests
cuda-core/tests/borrow_raw.rs: repeatedly borrowing and dropping a stream leaves the source stream usable. cargo fmt, cargo clippy -p cuda-core --all-targets -D warnings and cargo test -p cuda-core pass on an RTX PRO 6000 (sm_120).
Also checked: the same commit cherry-picked onto v0.3.1, which cuda-oxide main depends on, lets cuda-oxide's generated module.<kernel>(&stream, config, ...) launch on a borrowed tvm-ffi environment stream. With it, a tvm-ffi entry for a cuda-oxide kernel needs no hand-marshalled cuLaunchKernel.
🤖 Generated with Claude Code
- Dominant language
- Rust
- Stars
- 3.8k
- Forks
- 325
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 66
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/cuda-rust
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NVIDIA/cuda-rust#1568 · 1 comment ·
Maintainers usually reply within 2 days
-
[BUG]: The doc of trait `LoadTileLike` is incorrectMay be free again @akhil9tiet claimed this 7 days ago, and no pull request is open. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 72/100
NVIDIA/cuda-rust#1523 · 2 comments ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NVIDIA/cuda-rust#1303 · 1 comment ·
Maintainers usually reply within 2 days
All issues in NVIDIA/cuda-rust
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
area:sim good first issue kind:feature
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
The demo's interval button and chart legend keep the previous interval after an interval changeOpenbug ui
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
userFRM/egui-charts#670 ·
Maintainers usually reply within 1 day
-
docs good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Usenova-Labs/usenova-backend#35 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
lugassawan/swe-workbench#823 ·
Maintainers usually reply within 1 day