acetn.linalg package
Submodules
acetn.linalg.fused_3matmul_svd_lowrank module
- acetn.linalg.fused_3matmul_svd_lowrank.fused_3matmul_svd_lowrank(A, B, C, D, q=6, niter=2)
Compute the randomized SVD of A @ B @ C @ D without forming the product explicitly.
This avoids materializing any intermediate or final product matrices, which is more memory efficient for large tensors.
- Args:
A (Tensor): First matrix of shape (m, k1). B (Tensor): Second matrix of shape (k1, k2). C (Tensor): Third matrix of shape (k2, k3). D (Tensor): Fourth matrix of shape (k3, n). q (int): Target rank for the approximation. Default: 6. niter (int): Number of power iterations for accuracy improvement. Default: 2.
- Returns:
- tuple[Tensor, Tensor, Tensor]:
U: Left singular vectors of shape (m, q).
S: Singular values of shape (q,).
V: Right singular vectors of shape (n, q).
- Note:
The returned V is not transposed, so A @ B @ C @ D ≈ U @ diag(S) @ V.T
acetn.linalg.fused_matmul_svd_lowrank module
- acetn.linalg.fused_matmul_svd_lowrank.fused_matmul_svd_lowrank(A, B, q=6, niter=2)
Compute the randomized SVD of the matrix product A @ B without forming it explicitly.
This is more memory efficient than computing A @ B followed by svd_lowrank, as it avoids materializing the full product matrix.
- Args:
A (Tensor): Left input matrix of shape (m, k). B (Tensor): Right input matrix of shape (k, n). q (int): Target rank for the approximation. Default: 6. niter (int): Number of power iterations for accuracy improvement. Default: 2.
- Returns:
- tuple[Tensor, Tensor, Tensor]:
U: Left singular vectors of shape (m, q).
S: Singular values of shape (q,).
V: Right singular vectors of shape (n, q).
- Note:
The returned V is not transposed, so A @ B ≈ U @ diag(S) @ V.T
acetn.linalg.svd_lowrank module
- acetn.linalg.svd_lowrank.svd_lowrank(A, q=6, niter=2)
Compute the randomized SVD of a matrix.
This function computes an approximate SVD using random projections, equivalent to torch.svd_lowrank.
- Args:
A (Tensor): Input matrix of shape (m, n). q (int): Target rank for the approximation. Default: 6. niter (int): Number of power iterations for accuracy improvement. Default: 2. M (Tensor, optional): Not used, included for API compatibility with torch.svd_lowrank.
- Returns:
- tuple[Tensor, Tensor, Tensor]:
U: Left singular vectors of shape (m, q).
S: Singular values of shape (q,).
V: Right singular vectors of shape (n, q).
- Note:
The returned V is not transposed (same as torch.svd_lowrank convention), so A ≈ U @ diag(S) @ V.T
Module contents
- acetn.linalg.fused_3matmul_svd_lowrank(A, B, C, D, q=6, niter=2)
Compute the randomized SVD of A @ B @ C @ D without forming the product explicitly.
This avoids materializing any intermediate or final product matrices, which is more memory efficient for large tensors.
- Args:
A (Tensor): First matrix of shape (m, k1). B (Tensor): Second matrix of shape (k1, k2). C (Tensor): Third matrix of shape (k2, k3). D (Tensor): Fourth matrix of shape (k3, n). q (int): Target rank for the approximation. Default: 6. niter (int): Number of power iterations for accuracy improvement. Default: 2.
- Returns:
- tuple[Tensor, Tensor, Tensor]:
U: Left singular vectors of shape (m, q).
S: Singular values of shape (q,).
V: Right singular vectors of shape (n, q).
- Note:
The returned V is not transposed, so A @ B @ C @ D ≈ U @ diag(S) @ V.T
- acetn.linalg.fused_matmul_svd_lowrank(A, B, q=6, niter=2)
Compute the randomized SVD of the matrix product A @ B without forming it explicitly.
This is more memory efficient than computing A @ B followed by svd_lowrank, as it avoids materializing the full product matrix.
- Args:
A (Tensor): Left input matrix of shape (m, k). B (Tensor): Right input matrix of shape (k, n). q (int): Target rank for the approximation. Default: 6. niter (int): Number of power iterations for accuracy improvement. Default: 2.
- Returns:
- tuple[Tensor, Tensor, Tensor]:
U: Left singular vectors of shape (m, q).
S: Singular values of shape (q,).
V: Right singular vectors of shape (n, q).
- Note:
The returned V is not transposed, so A @ B ≈ U @ diag(S) @ V.T
- acetn.linalg.svd_lowrank(A, q=6, niter=2)
Compute the randomized SVD of a matrix.
This function computes an approximate SVD using random projections, equivalent to torch.svd_lowrank.
- Args:
A (Tensor): Input matrix of shape (m, n). q (int): Target rank for the approximation. Default: 6. niter (int): Number of power iterations for accuracy improvement. Default: 2. M (Tensor, optional): Not used, included for API compatibility with torch.svd_lowrank.
- Returns:
- tuple[Tensor, Tensor, Tensor]:
U: Left singular vectors of shape (m, q).
S: Singular values of shape (q,).
V: Right singular vectors of shape (n, q).
- Note:
The returned V is not transposed (same as torch.svd_lowrank convention), so A ≈ U @ diag(S) @ V.T