warp.optim.linear.MultiRHSOperator#

class warp.optim.linear.MultiRHSOperator(A, nrhs, algorithm='auto')[source]#

Repeat one sparse matrix or linear operator over independent RHS rows.

This is a logical block-diagonal operator, with no duplicated matrix storage. Inputs to matvec are contiguous flat scalar arrays representing (nrhs, n). Sparse matrices use the batched warp.sparse.bsr_mv() strategies; other operators are applied to each RHS row in turn. Exact aliases are supported; shifted output overlap and strided storage are rejected before launching.

Each object owns its scratch. with_nrhs creates smaller capacities sharing it. Eager applications issued from different CUDA streams are ordered with an event; simultaneously executing graphs that share scratch require caller ordering. Value updates in existing buffers are observed on replay; topology/address changes require recapture. No adjoint is supplied.

Parameters:
  • A – Square sparse matrix or a single-system LinearOperator.

  • nrhs (int) – Positive RHS count.

  • algorithm (Literal['auto', 'loop', 'rows', 'columns']) – Batched product strategy for a sparse A, fixed at construction and kept by with_nrhs: "auto", "loop", "rows" or "columns", as in warp.sparse.bsr_mv(). "auto" reads back the mean row length once, so unlike per-call warp.sparse.bsr_mv() it can also choose "columns" for CSR rows averaging more than 16 entries. Explicit strategies pin a kernel and raise ValueError where unsupported. Other operators accept only "auto" or "loop". The chosen strategy is available as algorithm.

Methods

with_nrhs(nrhs)

Prepare a smaller capacity sharing scratch, strategy and stream ordering.

Attributes

batch_count

Number of independent subproblems.

batch_offsets

Array partitioning the active scalar degrees of freedom, or None.

device

Device on which computations involving the operator are performed.

dtype

Type of the operator elements, such as a scalar type or a matrix block type.

matvec

Matrix-vector multiplication function.

max_batch_length

Upper bound on the number of scalar degrees of freedom in any subproblem, or None.

scalar_type

Scalar component type of the operator's elements.

shape

Number of rows and columns of the operator.

with_nrhs(nrhs)[source]#

Prepare a smaller capacity sharing scratch, strategy and stream ordering.

Parameters:

nrhs (int) – Positive capacity no greater than this operator’s nrhs.

Returns:

A MultiRHSOperator acting on nrhs RHS rows.