jaxmg.potrf¤
potrf computes the lower Cholesky factor of a symmetric or Hermitian
positive-definite matrix \(A\):
Use potrf for a direct factorization. Use potrf_jit_ctx when the
factorization is part of a larger caller-owned jax.jit. The factor aliases
the input work buffer, so the context interface returns \(L\) directly rather
than a separate opaque work result.
Inside an existing jax.shard_map, use potrf_shardmap_ctx with local matrix
blocks. It returns local factor blocks and per-rank status.
Context API migration
The previous global-array potrf_shardmap_ctx is now named
potrf_jit_ctx, with the same arguments and outputs.
jaxmg.potrf(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, return_status=False, pad=True, donate=True)
¤
Compute the distributed Cholesky factor of a positive-definite matrix.
For a symmetric or Hermitian positive-definite n x n matrix A,
returns the lower-triangular matrix L such that A = L @ L^H. The
strict upper triangle of L is zero, as in
:func:jax.numpy.linalg.cholesky.
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, symmetric positive-definite 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[Array, Tuple[Array, Array]]
|
Array or (Array, Array): The Cholesky factor |
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
cusolverMpPotrf, and redistributes the factor back. - If the native solver fails, for example because
ais not positive definite,Lis filled with NaN andstatusis non-zero.
jaxmg.potrf_jit_ctx(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, pad=True, _prepared=None)
¤
Compute the Cholesky factor inside a caller-owned jax.jit.
This interface performs the same validation, redistribution, and native
computation as :func:jaxmg.potrf, but leaves the outer compilation and
donation boundary to the caller. The native factor output aliases the input
work buffer, so an outer jax.jit(..., donate_argnums=(0,)) can donate
a into L.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
2D, symmetric positive-definite 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
|
compiled function can propagate native diagnostics. |
Tuple[Array, Array]
|
when |
Raises:
| Type | Description |
|---|---|
TypeError
|
If dtypes or |
ValueError
|
If shapes, tile sizes, or mesh layouts are incompatible. |
Notes
- If the native solver fails,
Lis filled with NaN and the status is non-zero.
jaxmg.potrf_shardmap_ctx(a, T_A, matrix_specs=None, *, in_specs=None, pad=True)
¤
Compute local Cholesky-factor blocks inside a caller's jax.shard_map.
The enclosing mesh contains the matrix axes. The same native factorization
is used by :func:potrf and :func:potrf_jit_ctx; only the caller's
compilation and sharding context differs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
Local block of a symmetric or Hermitian positive-definite 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
|
diagnostic vector. The factor reuses the input work buffer, so no |
Tuple[Array, Array]
|
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. |