Skip to content

Commit 5706a93

Browse files
authored
refactor(aggregation): Remove exception re-raising with svd (#270)
* Remove exception re-raising when torch.linalg.svd raises a LinalgError in _compute_normalized_gramian
1 parent 6da02d4 commit 5706a93

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/torchjd/aggregation/_gramian_utils.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import torch
22
from torch import Tensor
3-
from torch.linalg import LinAlgError
43

54

65
def _compute_gramian(matrix: Tensor) -> Tensor:
@@ -33,13 +32,7 @@ def _compute_normalized_gramian(matrix: Tensor, eps: float) -> Tensor:
3332
:math:`n` through the SVD algorithm which is efficient, therefore this is rather fast.
3433
"""
3534

36-
try:
37-
left_unitary_matrix, singular_values, _ = torch.linalg.svd(matrix, full_matrices=False)
38-
except LinAlgError as error: # Not sure if this can happen
39-
raise ValueError(
40-
f"Unexpected failure of the svd computation on matrix {matrix}. Please open an "
41-
"issue on https://github.com/TorchJD/torchjd/issues and paste this error message in it."
42-
) from error
35+
left_unitary_matrix, singular_values, _ = torch.linalg.svd(matrix, full_matrices=False)
4336
max_singular_value = torch.max(singular_values)
4437
if max_singular_value < eps:
4538
scaled_singular_values = torch.zeros_like(singular_values)

0 commit comments

Comments
 (0)