Hi,
Here is my test script, it seems to work fine no?
import torch

a = torch.rand(10, 2)

A = torch.mm(a, a.t()) # rank 2 input to have a nullspace of size 8


def my_nullspace(At, rcond=None):

    ut, st, vht = torch.Tensor.svd(At, some=False,compute_uv=True)
    vht=vht.T        
    Mt, Nt = ut.shape[0], vht.shape[1] 
    if rcond is None:
        rcondt = torch.finfo(st.dtype).eps * max(Mt, Nt)
    tolt = torch.max(st) * rcondt
    numt= torch.sum(st > tolt, dtype=int)
    nullspace = vht[numt:,:].T.cpu().conj()
    # nullspace.backward(torch.ones_like(nullspace),retain_graph=True)
    return nullspace

A.requires_grad_()
out = my_nullspace(A)

print("out size, should be 10x8: ", out.size())

out.sum().backward()
print("A.grad", A.grad)