jaxmg.getrf¤
getrf computes the pivoted LU factorization of a square nonsingular matrix
\(A\):
The result lu stores the strictly lower part of the unit-lower factor \(L\)
and the upper-triangular factor \(U\). The replicated vector piv records the
zero-based row interchanges.
Use getrf for a direct factorization. Use getrf_jit_ctx when the
factorization is part of a larger caller-owned jax.jit. The packed factor
aliases the input work buffer, so no separate opaque work result is needed.
jaxmg.getrf(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, return_status=False, pad=True, donate=True)
¤
Compute the distributed pivoted LU factorization of a square matrix.
For a nonsingular n x n matrix A, computes P @ A = L @ U with
partial pivoting. The outputs follow :func:jax.scipy.linalg.lu_factor:
lu holds the strictly lower part of the unit-lower L and the upper
triangle of U, and piv holds 0-based pivot indices, meaning row
i was interchanged with row piv[i]. Use
:func:jax.lax.linalg.lu_pivots_to_permutation to obtain the permutation.
Note
If a local shard dimension is not divisible by T_A, pad=True
allocates additional tile-aligned capacity before the native call.
Choosing a tile size that divides the local dimensions avoids this
allocation. Performance depends on the matrix size, process grid, and
tile size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
2D, nonsingular input matrix sharded over a one- or two-axis
device mesh, for example with |
required |
T_A
|
int
|
Square tile width used by cuSOLVERMp. Each local shard
dimension must be a multiple of |
required |
mesh
|
Mesh or AbstractMesh
|
JAX mesh used for |
None
|
matrix_specs
|
PartitionSpec or tuple / list[PartitionSpec]
|
PartitionSpec describing the matrix sharding. If omitted, read
off the sharding of |
None
|
in_specs
|
P | Tuple[P] | List[P] | None
|
Backwards-compatible alias for |
None
|
return_status
|
bool
|
If True return |
False
|
pad
|
bool
|
If True (default) apply per-device padding so
each local shard length is compatible with |
True
|
donate
|
bool
|
If True (default) the input buffer may be
donated and overwritten by |
True
|
Returns:
| Type | Description |
|---|---|
Union[Tuple[Array, Array], Tuple[Array, Array, Array]]
|
|
Union[Tuple[Array, Array], Tuple[Array, Array, Array]]
|
|
Union[Tuple[Array, Array], Tuple[Array, Array, Array]]
|
|
Union[Tuple[Array, Array], Tuple[Array, Array, Array]]
|
replicated |
Raises:
| Type | Description |
|---|---|
TypeError
|
If dtypes or |
ValueError
|
If shapes, tile sizes, or mesh layouts are incompatible. |
Notes
- Unless
donate=False, theabuffer is donated for zero-copy interaction with the native library, so it is deleted and cannot be used after the call. - Native code converts row-major JAX local storage to cuSOLVERMp's
column-major local layout, redistributes to 2D block-cyclic layout,
calls
cusolverMpGetrf, and redistributes the factor back. - If the native solver fails, including when
Uhas an exactly zero diagonal entry,luis filled with NaN,pivis filled with-1, andstatusis non-zero.
jaxmg.getrf_jit_ctx(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, pad=True, _prepared=None)
¤
Compute the pivoted LU factorization inside a caller-owned jax.jit.
This interface performs the same validation, redistribution, and native
computation as :func:jaxmg.getrf, but leaves the outer compilation and
donation boundary to the caller. The native lu output aliases the input
work buffer, so an outer jax.jit(..., donate_argnums=(0,)) can donate
a into lu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
2D, nonsingular input matrix sharded over a one- or two-axis
device mesh, for example with |
required |
T_A
|
int
|
Square tile width used by cuSOLVERMp. |
required |
mesh
|
Mesh or AbstractMesh
|
JAX mesh used for |
None
|
matrix_specs
|
PartitionSpec or tuple / list[PartitionSpec]
|
PartitionSpec describing the matrix sharding. If omitted, read
off the sharding of |
None
|
in_specs
|
P | Tuple[P] | List[P] | None
|
Backwards-compatible alias for |
None
|
pad
|
bool
|
If True (default) apply per-device padding so
each local shard length is compatible with |
True
|
Returns:
| Type | Description |
|---|---|
Array
|
|
Array
|
enclosing compiled function can propagate native diagnostics. |
Array
|
is restored when |
Tuple[Array, Array, Array]
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If dtypes or |
ValueError
|
If shapes, tile sizes, or mesh layouts are incompatible. |
Notes
- If the native solver fails,
luis filled with NaN,pivis filled with-1, and the status is non-zero.
Use getrf_shardmap_ctx inside an existing jax.shard_map. It accepts a local
matrix block and returns a local factor block, replicated pivots and per-rank
status.
Context API migration
The previous global-array getrf_shardmap_ctx is now named getrf_jit_ctx,
with the same arguments and outputs.
jaxmg.getrf_shardmap_ctx(a, T_A, matrix_specs=None, *, in_specs=None, pad=True)
¤
Compute local LU-factor blocks inside a caller's jax.shard_map.
The enclosing mesh contains the matrix axes. Factor blocks are local, but the native backend returns the complete pivot vector on every rank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
Local block of a square, nonsingular global matrix. |
required |
T_A
|
int
|
Square tile width used by cuSOLVERMp. |
required |
matrix_specs
|
P | Tuple[P] | List[P] | None
|
A's partition specification in the enclosing shard map; defaults to the context mesh axes in order. |
None
|
in_specs
|
P | Tuple[P] | List[P] | None
|
Backwards-compatible alias for |
None
|
pad
|
bool
|
Allow tile-capacity padding; otherwise require aligned blocks. |
True
|
Returns:
| Type | Description |
|---|---|
Array
|
|
Array
|
zero-based pivots and this rank's diagnostic vector. The factor reuses |
Array
|
the input work buffer; no separate |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the dtype or partition specification is unsupported. |
ValueError
|
If called outside shard_map or the global matrix is invalid. |