Skip to content

jaxmg.getri¤

getri computes the full inverse of a general nonsingular matrix \(A\) using a distributed LU factorization:

\[ PA=LU,\qquad A^{-1}=U^{-1}L^{-1}P. \]

Pass the original matrix \(A\), not precomputed factors. Factorization and inversion run in one native call and reuse the same matrix buffer. Use lu_solve when only a linear solve is needed.

Use getri_jit_ctx inside a caller-owned jax.jit, or getri_shardmap_ctx for local matrix blocks inside an existing jax.shard_map. Both return (inverse, status); no separate work-matrix result is needed.

jaxmg.getri(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, return_status=False, pad=True, donate=True) ¤

Compute the distributed inverse of a general nonsingular matrix.

Returns the full inverse of a square matrix A. Unlike NVIDIA's factor-based GETRI interface, this routine accepts the original matrix and performs pivoted LU factorization and inversion in one native call.

Parameters:

Name Type Description Default
a Array

Original square matrix, sharded over a one- or two-axis mesh or replicated. Supports float32, float64, complex64 and complex128.

required
T_A int

Square tile dimension used by cuSOLVERMp.

required
mesh Mesh | AbstractMesh | None

Device mesh. If omitted, inferred from A or the active context.

None
matrix_specs P | tuple[P] | list[P] | None

Matrix partition specification. If omitted, inferred from A, defaulting to the mesh axes in order.

None
in_specs P | tuple[P] | list[P] | None

Backwards-compatible alias for matrix_specs.

None
return_status bool

Return (inverse, status) rather than just the inverse.

False
pad bool

Allow local tile-capacity padding; otherwise require alignment.

True
donate bool

Reuse A's storage by default. Donated inputs cannot be used again. Pass False to preserve A with an additional matrix buffer.

True

Returns:

Type Description
Array | tuple[Array, Array]

The full inverse with A's shape and result sharding, including

Array | tuple[Array, Array]

replication when A was replicated. Optional status contains per-rank

Array | tuple[Array, Array]

native diagnostics. Numerical failure returns NaNs and nonzero status.

Raises:

Type Description
TypeError

If the dtype or partition specification is unsupported.

ValueError

If shapes, tile sizes, or mesh layouts are incompatible.

Notes

Prefer :func:jaxmg.lu_solve when only A x = B is required. GETRF and GETRI reuse one matrix allocation and release factorization workspace before allocating inversion workspace.


jaxmg.getri_jit_ctx(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, pad=True, _prepared=None) ¤

Invert A inside a caller-owned jax.jit using pivoted LU.

Accepts the original general nonsingular matrix, as in :func:jaxmg.getri. The caller controls compilation and donation; jax.jit(..., donate_argnums=(0,)) can reuse A's storage.

Parameters:

Name Type Description Default
a Array

Original square global matrix.

required
T_A int

Square tile dimension.

required
mesh Mesh | AbstractMesh | None

Mesh inferred from A or the active context when omitted.

None
matrix_specs P | tuple[P] | list[P] | None

Matrix partition specification, inferred when omitted.

None
in_specs P | tuple[P] | list[P] | None

Backwards-compatible alias for matrix_specs.

None
pad bool

Allow tile-capacity padding.

True

Returns:

Type Description
Array

(inverse, status). The full inverse follows A's result sharding,

Array

including replication. Status retains diagnostics from every rank.

Raises:

Type Description
TypeError

If the dtype or partition specification is unsupported.

ValueError

If shapes, tile sizes, or mesh layouts are incompatible.

jaxmg.getri_shardmap_ctx(a, T_A, matrix_specs=None, *, in_specs=None, pad=True) ¤

Invert local matrix blocks inside a caller's jax.shard_map.

Uses the same fused pivoted LU factorization and inversion as :func:jaxmg.getri, with compilation and sharding owned by the caller.

Parameters:

Name Type Description Default
a Array

Local block of the original general nonsingular matrix.

required
T_A int

Square tile dimension.

required
matrix_specs P | tuple[P] | list[P] | None

A's specification in the enclosing shard map; defaults to the context mesh axes in order. Must describe the actual blocks, since the global matrix shape is reconstructed from this metadata.

None
in_specs P | tuple[P] | list[P] | None

Backwards-compatible alias for matrix_specs.

None
pad bool

Allow tile-capacity padding.

True

Returns:

Type Description
Array

(inverse, status): the unpadded local inverse block and this rank's

Array

diagnostic vector. The inverse aliases the input work buffer, so no

tuple[Array, Array]

separate a_work result is required.

Raises:

Type Description
TypeError

If the dtype or partition specification is unsupported.

ValueError

If called outside shard_map or the global matrix is invalid.