Skip to content

fix: prevent allocation retirement from blocking unrelated streams - #1839

Open
Ninzore wants to merge 6 commits into
NVIDIA:mainfrom
Ninzore:fix/stream-retirement
Open

Ninzore wants to merge 6 commits into
NVIDIA:mainfrom
Ninzore:fix/stream-retirement

Conversation

@Ninzore

@Ninzore Ninzore commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary
Prevent owned stream destruction from blocking on queued GPU work or driver contention, while keeping stream resources and context owners alive until completion. Free synchronous allocations with cuMemFreeAsync on a private stream when supported, avoiding context-wide stalls. Fix #1768
Changes

  • Move owned stream retirement to a background worker.
  • Separate completion polling from resource cleanup.
  • Make completion cleanup capture-safe.
  • Retain per-thread stream owners until context-wide work completes.

Testing
Validated on an NVIDIA RTX PRO 4500 Blackwell.

  • Each commit passes 112 existing cuda-core tests; 2 ignored.
  • Each commit passes formatting and Clippy with warnings denied.
  • Reproduced the original failure; the fixed version passes 20 rounds of the same shared-allocation tests.
  • Existing device-buffer tests pass 5 rounds.

Checklist

  • All four new commits signed off (git commit -s).
  • All commits cryptographically signed and shown as Verified on GitHub — the four new commits are signed locally; GitHub verification remains pending.
  • SPDX headers on new source files — not applicable; no new source files committed.

Free synchronous allocations with cuMemFreeAsync on a separate nonblocking stream. Wait on the background worker to avoid blocking unrelated stream operations.

Fall back to cuMemFree if unsupported or stream creation fails.
Restore capture mode after querying or waiting for retirement events.
Destroy completion events before releasing external context owners.

Signed-off-by: ruolingp <33434617+Ninzore@users.noreply.github.com>
Separate completion polling from owner cleanup.
Keep blocking resource destruction away from completion polling.

Signed-off-by: ruolingp <33434617+Ninzore@users.noreply.github.com>
Move driver queries, event recording, and recycling out of Stream::drop.
Keep stream resources alive until queued GPU work completes.

Signed-off-by: ruolingp <33434617+Ninzore@users.noreply.github.com>
Snapshot context-wide completion before retiring per-thread streams.
Isolate context cleanup so one blocked owner cannot delay another context.

Signed-off-by: ruolingp <33434617+Ninzore@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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.

[BUG]: shared_allocation pending_copy test fails under parallel test threads

1 participant