jaxmg.polar¤
polar computes the polar decomposition of a tall or square matrix \(A\):
For a full-rank \(M \times N\) matrix with \(M \geq N\), the columns of \(U_p\) are
orthonormal and \(H\) is an \(N \times N\) Hermitian positive-definite matrix. Set
compute_h=False when only \(U_p\) is required; the \(H\) output and its reverse
redistribution are then omitted.
Use polar for a direct decomposition. Use polar_shardmap_ctx when the
decomposition is part of a larger caller-owned jax.jit. cuSOLVERMp overwrites
the input matrix with \(U_p\), so the context interface returns \(U_p\) directly as
the donated input alias rather than returning a separate work buffer.
jaxmg.polar(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, compute_h=True, return_status=False, pad=True, donate=True)
¤
Compute a distributed polar decomposition with cuSOLVERMp.
For a full-rank m x n matrix with m >= n, the decomposition is
A = Up @ H. Up has orthonormal columns and H is an n x n
Hermitian positive-definite matrix. Rank-deficient inputs instead produce
a positive-semidefinite H and may not yield orthonormal columns in the
null-space directions of Up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
A rank-2 real or complex tall or square matrix sharded over a one- or two-axis device mesh. |
required |
T_A
|
int
|
Square cuSOLVERMp tile width. |
required |
mesh
|
Mesh or AbstractMesh
|
JAX mesh used by
|
None
|
matrix_specs
|
PartitionSpec or tuple / list[PartitionSpec]
|
Rank-2 matrix sharding. If omitted, read from the sharding of
|
None
|
in_specs
|
P | Tuple[P] | List[P] | None
|
Backwards-compatible alias for |
None
|
compute_h
|
bool
|
Whether to compute and return |
True
|
return_status
|
bool
|
If True, append the native per-rank diagnostic status vector to the numerical outputs. |
False
|
pad
|
bool
|
If True (default), add tile-aligned local capacity
where required. If False, all participating local matrix shapes
must already be divisible by |
True
|
donate
|
bool
|
If True (default), the input may be donated
and overwritten by |
True
|
Returns:
| Type | Description |
|---|---|
Array | tuple[Array, ...]
|
|
Array | tuple[Array, ...]
|
|
Array | tuple[Array, ...]
|
Requested matrix outputs are restored to replicated sharding when |
Array | tuple[Array, ...]
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the dtype, static mode flag, or sharding specification is unsupported. |
ValueError
|
If the matrix is wide or its shape, tile size, process grid, or requested output layout is incompatible with cuSOLVERMp. |
Notes
- If the native solver fails,
UpandHare filled with NaN and the status is non-zero.
jaxmg.polar_shardmap_ctx(a, T_A, mesh=None, matrix_specs=None, *, in_specs=None, compute_h=True, pad=True)
¤
Compute a polar decomposition inside a caller-owned jax.jit.
This interface performs the same validation, redistribution, and native
computation as :func:jaxmg.polar, but leaves the outer compilation and
donation boundary to the caller. The native Up output aliases the input
work buffer before any final restoration of replicated sharding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Array
|
A rank-2 real or complex tall or square matrix sharded over a one- or two-axis device mesh. |
required |
T_A
|
int
|
Square cuSOLVERMp tile width. |
required |
mesh
|
Mesh or AbstractMesh
|
JAX mesh used by
|
None
|
matrix_specs
|
PartitionSpec or tuple / list[PartitionSpec]
|
Rank-2 matrix sharding. If omitted, read from the sharding of
|
None
|
in_specs
|
P | Tuple[P] | List[P] | None
|
Backwards-compatible alias for |
None
|
compute_h
|
bool
|
Whether to compute and return |
True
|
pad
|
bool
|
If True (default), add tile-aligned local capacity
where required. If False, all participating local matrix shapes
must already be divisible by |
True
|
Returns:
| Type | Description |
|---|---|
Array
|
|
...
|
otherwise. The status vector is always returned so an enclosing |
tuple[Array, ...]
|
compiled function can propagate native diagnostics. Requested matrix |
tuple[Array, ...]
|
outputs are restored when |
tuple[Array, ...]
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the dtype, static mode flag, or sharding specification is unsupported. |
ValueError
|
If the matrix is wide or its shape, tile size, process grid, or requested output layout is incompatible with cuSOLVERMp. |
Notes
- If the native solver fails,
UpandHare filled with NaN and the status is non-zero.