Skip to content

unstable torch.potrs, torch.trtrs ops #4296

@fehiepsi

Description

@fehiepsi

The following simple script says that the current implementations of torch.trtrs, torch.potrs are not stable with high dimensional linear equations. These methods are useful, especially when working with Cholesky decomposition.

import torch

A = torch.randn(100, 100).tril()
B = torch.randn(100, 1)
X = torch.gesv(B, A)[0]
X_ = torch.trtrs(B, A, False)[0]
X__ = torch.potrs(B, A, False)   # solution for (A.A_t)X = B
print("gesv error: ", torch.dist(A.matmul(X), B))
print("trtrs error: ", torch.dist(A.matmul(X_), B))
print("potrs error: ", torch.dist(A.matmul(A.t()).matmul(X__), B))

Output:

gesv error:  80.30836486816406
trtrs error:  inf
potrs error:  nan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions