Linear Algebra#
Overview#
The Linear Algebra module nvmath. in nvmath-python leverages various NVIDIA
math libraries to support dense [1] linear algebra computations. As of version 1.0.0, we
offer matrix multiplication APIs as well as a dense direct linear solver API.
For matrix multiplication, we offer both a generic API based on the cuBLAS and NVPL
libraries and a specialized API (nvmath.) based on the cuBLASLt
library. See Generic and Specialized APIs for motivation.
At a high-level, if your use case is predominantly GEMM and requires particular flexibility
in matrix data layouts, input and/or compute types, and also in choosing the algorithmic
implementation, look at the specialized APIs. Otherwise, look at the generic APIs.
For solving dense square linear systems of the form a @ x = b via LU factorization,
we offer a generic dense direct solver (direct_solver() and the
stateful DirectSolver).
API Reference#
Generic Linear Algebra APIs (nvmath. linalg)#
The generic linear algebra module bundles host APIs that share a minimal, broadly applicable surface. Beyond that, each operation has its own operand model and configuration; the subsections below list each operation’s surface independently.
Matrix multiplication#
Accepts structured matrices via matrix qualifiers (general, triangular, symmetric, Hermitian, diagonal) in addition to dense full matrices. Runs on either CPU or CUDA execution.
|
Perform the specified matrix multiplication computation \(\alpha a @ b + \beta c\). |
|
Create a stateful object encapsulating the specified matrix multiplication computation \(\alpha a @ b + \beta c\) and the required resources to perform the operation. |
A NumPy custom dtype which describes a structured matrix. |
|
|
See |
A class which constructs and validates |
|
A class which constructs and validates |
|
A class which constructs and validates |
|
A class which constructs and validates |
|
A class which constructs and validates |
|
|
See |
|
See |
|
See |
|
A dataclass for providing options to a |
Direct linear solver#
Solves the dense system a @ x = b for a general square a and dense b
(including implicitly and explicitly batched inputs), via LU factorization on the GPU.
Execution is CUDA-only: host-side operands are copied to the selected device for
the factorization and solve using the triangular factors.
Native CPU execution is not available today but may be added in a future release.
|
Solve \(a @ x = b\) for \(x\). |
|
Create a stateful object that encapsulates the specified dense direct linear solver computations and required resources. |
Raised when a |
|
A data class for providing options to |
Specialized Linear Algebra APIs (nvmath. linalg. advanced)#
The specialized linear algebra module includes a matrix multiplication API which only accepts general matrices, but provides extra functionality such as epilog functions, more options and controls over computational precision, and control over algorithm selection and planning.
|
Perform the specified matrix multiplication computation \(\mathcal{F}(\alpha a @ b + \beta c)\), where \(\mathcal{F}\) is the epilog. |
NumPy dtype object that encapsulates the matrix qualifiers in linalg.advanced. |
|
|
An interface class to query algorithm capabilities and configure the algorithm. |
|
Create a stateful object encapsulating the specified matrix multiplication computation \(\alpha a @ b + \beta c\) and the required resources to perform the operation. |
alias of |
|
alias of |
|
|
See |
|
These flags can be combined with the | operator: OP_TYPE_FMA | OP_TYPE_TENSOR_HMMA ... |
alias of |
|
A data class for providing epilog options as part of |
|
A data class for providing options to the |
|
A data class for providing options to the |
|
A data class for providing quantization_scales to |
Helpers#
The Specialized Linear Algebra helpers module nvmath.
provides helper functions to facilitate working with some of the complex features of
nvmath. module.
Matmul helpers (nvmath. linalg. advanced. helpers. matmul)#
|
Block scaling format for microscaling data types. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Footnotes