﻿# rocSOLVER workspace queries: a sequential solve needs a reusable maximum, not a blind sum

Query the intended rocSOLVER operation sequence through its rocBLAS handle, distinguishing size-query mode, reusable workspace and concurrent ownership.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-rocsolver-workspace-query-maximum-not-sequence-sum/
Language: en

## Describe the sequence before budgeting scratch

A factorization followed by a solve can reuse temporary memory when the operations execute in the intended sequence on the same handle stream. Adding every independently reported temporary size may overstate the reusable requirement. Conversely, taking one observed size from an unrelated shape can understate it. Specify the actual operations, problem dimensions and handle configuration whose requirement the application intends to provision before replacing automatic workspace management.

## Use the library's query boundary

The [rocSOLVER memory-model guide](https://rocm.docs.amd.com/projects/rocSOLVER/en/latest/howto/memory.html) explains how rocBLAS query mode collects requirements for a selected sequence. The documented query calls describe sizes without performing the real numerical computation. Keep query-mode entry and exit paired, and do not treat untouched outputs from a sizing pass as a completed factorization. A diagnostic can verify that the numerical execution occurs later with valid allocated input and output storage.

## Understand why the result is a maximum

The [rocBLAS helper reference](https://rocmdocs.amd.com/projects/rocBLAS/en/latest/reference/helper-functions.html) documents collecting the maximum optimal device-memory requirement because sequential calls can reuse scratch on the same stream. That reasoning does not authorize sharing one buffer between independently concurrent handles or streams. Preserve the intended execution relationship with the resulting allocation record rather than storing a bare byte count detached from the sequence that produced it.

## Bind and release user-owned storage deliberately

The [rocBLAS allocation reference](https://rocm.docs.amd.com/projects/rocBLAS/en/latest/reference/memory-alloc.html) describes user-owned workspace and insufficient-memory behavior. After allocating the required storage, bind it through the documented handle interface and retain it until its users complete. Detach it before releasing its backing allocation. Changing ownership is a state transition for future library calls, not evidence that earlier asynchronous work has ceased accessing the same memory.

## Requery when the problem contract changes

Exercise a larger shape and a changed operation sequence to confirm the application updates its requirement before reuse. Test concurrent execution separately with independent ownership. The existing [stream-dependency guide](/journal/learn-stream-ordering-dependencies/) and [software reproducibility guide](/journal/software-stack-reproducibility/) provide context. A useful memory budget therefore records the query sequence, shape, library configuration and lifetime boundary, distinguishing reusable sequential scratch from aggregate memory needed by simultaneous work.
