cuda.core: VirtualMemoryResource.deallocate() unmaps without ordering on the stream

Open Beginner friendly
#2,886 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start at VirtualMemoryResource.deallocate() and compare its handling of stream validation and cuMemUnmap with _SynchronousMemoryResource and LegacyPinnedMemoryResource. Confirm Buffer.close()'s stream-ordering documentation, then verify that deallocation synchronizes the stream before unmapping and that the slow-path grow behavior remains correct.

Written by the indexing model from the issue text.

Description

bug cuda.core

Summary

VirtualMemoryResource.deallocate() validates its stream argument and then calls cuMemUnmap at once. The VMM unmap does not synchronize, so work still in flight on the buffer accesses an unmapped range.

Buffer.close() documents stream-ordered deallocation, and the two synchronous resources (_SynchronousMemoryResource, LegacyPinnedMemoryResource) call stream.sync() before they free. VirtualMemoryResource is the only synchronous resource that skips this.

Suggested fix

Sync the stream before cuMemUnmap, as the siblings do. After #2880 the slow-path grow closes the old buffer through deallocate(), so a grow will sync once; that is the correct cost for a synchronous resource.

Refs: found while analyzing #2882.

Dominant language
Cython
Stars
3.4k
Forks
329
Avg merge
1d 21h
Merged PRs (30d)
113

Contributor guide

Open the contributing guide

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-python

All issues in NVIDIA/cuda-python

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.