In this article
Changing the handle stream does not make outstanding uses of its workspace disappear; the selected allocation mode determines the supported transition.
Look beyond the stream field itself
A worker submits a matrix operation, changes its handle to another non-default stream and immediately submits more work. The handle can own temporary device storage shared by those submissions. Treating the setter as a harmless scheduling preference misses that resource relationship. Record the handle, its allocation mode and outstanding stream work before deciding whether the transition is safe for the exact library configuration in use.
Follow the ordinary transition rule explicitly
The rocBLAS programming guide requires completion of earlier work when switching ordinary handle-managed storage between non-default streams. It also documents a stream-ordered allocation exception. Keep those cases distinct rather than turning one rule into an unconditional claim for every release and allocator. Do not assume that application buffers being separate also makes the handle’s internal temporary allocation independent.
Track association before destroying a stream
The helper-function reference defines handle stream setters and queries. Preserve the actual association during teardown, and update the handle through the documented sequence before destroying an old stream. A dangling association can affect later calls even after the original operation seemed successful. Check each relevant return code instead of investigating only the eventual failure in an unrelated matrix operation.
Identify who manages temporary memory
The device-memory allocation reference describes per-handle workspace management and user-controlled alternatives. Keep the active scheme visible in a reproduction because changing it changes which assumptions justify the stream transition. A copied handle identifier or reused allocation address is not proof that concurrent work has independent scratch storage or that a previous owner has completed using it.
Test transition and arithmetic separately
Create a controlled test that alternates the selected streams while keeping matrix inputs fixed, and verify both completion and the intended teardown order. Repeat with the allocation mode explicitly recorded. The existing stream-ordering guide and software reproducibility material provide context. This separates a lifetime error during handle migration from a numerical or layout error, making the failure reproducible without relying on whichever scheduling order happened to hide it initially.
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.