oneflow icon indicating copy to clipboard operation
oneflow copied to clipboard

[bug] flow.inverse on singular matrix triggers FATAL abort instead of raising RuntimeError

Open tinywisdom opened this issue 2 months ago • 0 comments

Summary

When calling flow.inverse on a singular matrix, OneFlow immediately triggers a FATAL C++ abort (LogMessageFatal), terminating the process.

This is inconsistent with expected behavior (e.g., PyTorch raises RuntimeError: singular matrix). Frameworks should report the error to Python gracefully, rather than aborting the interpreter.

Code to reproduce bug

import oneflow as flow
import oneflow.nn as nn

class ModelWithInterpolation(nn.Module):
    def forward(self, x):
        # Interpolate to (64, 64) but input is constant, leading to singular matrices
        x = nn.functional.interpolate(x, size=(64, 64), mode='bilinear', align_corners=True)
        x = flow.inverse(x)  #  will crash due to singularity
        return x

if __name__ == "__main__":
    flow.manual_seed(0)
    x = flow.ones(8, 32, 1, 1, dtype=flow.float32)  # [N=8, C=32, H=1, W=1], all ones
    m = ModelWithInterpolation()
    y = m(x)  # never reaches here
    _ = y.numpy()

System Information

  • OS: Ubuntu 22.04.4 LTS (x86_64)
  • OneFlow version : 1.0.0.dev20250921+cpu
  • Python version: 3.10.16

tinywisdom avatar Oct 01 '25 14:10 tinywisdom