From 40cf06b2d15ea4210190befed28123f6efb5fcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9rian=20Rey?= Date: Tue, 25 Mar 2025 14:03:07 +0100 Subject: [PATCH] Remove exception re-raising in _compute_normalized_gramian --- src/torchjd/aggregation/_gramian_utils.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/torchjd/aggregation/_gramian_utils.py b/src/torchjd/aggregation/_gramian_utils.py index bb12fb4ef..11c31fd81 100644 --- a/src/torchjd/aggregation/_gramian_utils.py +++ b/src/torchjd/aggregation/_gramian_utils.py @@ -1,6 +1,5 @@ import torch from torch import Tensor -from torch.linalg import LinAlgError def _compute_gramian(matrix: Tensor) -> Tensor: @@ -33,13 +32,7 @@ def _compute_normalized_gramian(matrix: Tensor, eps: float) -> Tensor: :math:`n` through the SVD algorithm which is efficient, therefore this is rather fast. """ - try: - left_unitary_matrix, singular_values, _ = torch.linalg.svd(matrix, full_matrices=False) - except LinAlgError as error: # Not sure if this can happen - raise ValueError( - f"Unexpected failure of the svd computation on matrix {matrix}. Please open an " - "issue on https://github.com/TorchJD/torchjd/issues and paste this error message in it." - ) from error + left_unitary_matrix, singular_values, _ = torch.linalg.svd(matrix, full_matrices=False) max_singular_value = torch.max(singular_values) if max_singular_value < eps: scaled_singular_values = torch.zeros_like(singular_values)