TECHNOLOGY

ONNX Runtime reused streams: select the owning GPU before allocating the next input

In this article
THE QUICK TAKE

The 1.32 reused-stream path restores device ownership before dependent work; test nondefault GPUs and caller exit with pending asynchronous transfers.

ONNX Runtime 1.32.0’s stream-reuse work includes selecting a reused stream’s owning device before input allocation and notification creation. The linked PR tests a nondefault GPU path. Reusing a stream is therefore a device-state transition as well as a pooling action; thread-local current-device state cannot be assumed to follow the borrowed resource automatically.

A stream handle does not set thread state

A caller can arrive with a different current GPU from the one owning a pooled stream. If input allocation occurs first, storage can be associated with the wrong device. The release work orders device selection before that dependent action. A proposed test begins on another device, acquires a reused stream and verifies allocation and execution on the intended owner. A one-GPU test cannot expose this class of mismatch.

Notification creation has the same dependency

Completion notifications can also depend on current device context. Correcting only the allocation site would leave a later context-sensitive operation vulnerable. A local suite should cover the whole acquisition-to-completion path, including notification destruction after the caller exits. Preserve actual asynchronous work so the notification has something to order. A synchronous trivial kernel may complete too early to exercise deferred resource ownership.

Pending host staging must remain owned

The PR includes deferred pinned-memory lifetime during asynchronous copies. Keep a distinct pattern in source staging and verify the destination after completion. Do not release or repurpose storage merely because the initiating caller thread has ended. A proposed check observes that resources are retained while transfer is pending and released afterward, covering both early-free safety and eventual cleanup in the reused-stream scenario.

Keep the hardware claim specific

The release changes runtime ownership and context handling, not the arithmetic of a model. Upstream reports a focused CUDA validation; it should not be retold as testing every provider or operating system. This article reports the ordering contract and proposed multi-GPU lifecycle case without new measurements. The transferable rule is to restore resource ownership context before dependent allocation or synchronization work, not merely before the final kernel launch.

Sources

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles