Skip to content

Fix minimum-norm least squares for rank-deficient inputs - #12613

Open
loaff123 wants to merge 1 commit into
dask:mainfrom
loaff123:fix-lstsq-rank-deficient
Open

loaff123 wants to merge 1 commit into
dask:mainfrom
loaff123:fix-lstsq-rank-deficient

Conversation

@loaff123

@loaff123 loaff123 commented Oct 1, 2026

Copy link
Copy Markdown

Fixes #12610.
The QR-based least-squares implementation unconditionally uses a triangular solve. Rank-deficient coefficient matrices can raise a singular-matrix error or produce unstable coefficients instead of a minimum-norm solution. Computing singular values from RᴴR also loses numerical accuracy by squaring the spectrum.
Changes:

  • Retain distributed QR and compute one shared reduced SVD of the small R block
  • Use the original matrix dimensions and QR precision for the solution/rank cutoff
  • Preserve residual norms, RHS column chunks, complex conjugation, and scalar int64 rank metadata
  • Compute unknown row counts through scalar shape tasks without gathering the full input matrix
  • Handle real and complex subnormal scales without unstable singular-value reciprocals
  • Make unsupported coefficient layouts explicit
    Validation:
  • All 452 linalg tests passed on both current and minimum dependency environments
  • Independent numerical and graph review passed
  • Configured pre-commit hooks passed for changed files
  • Array suite: 4,915 passed, 551 skipped, 16 xfailed; two memory-heavy tests excluded
  • Whole-project collection was blocked by missing optional pyarrow; no full-project pass is claimed
  • GPU/CuPy execution was not tested

Use a shared small-R SVD with an original-matrix cutoff, preserve lazy graph sharing, and cover numerical and layout edge cases.

AI-assisted reconstruction; requires human review before an upstream ready-for-review submission.
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

     25 files  ±    0       25 suites  ±0   6h 56m 7s ⏱️ + 7m 51s
 19 968 tests +   54   18 535 ✅ + 54   1 433 💤 ± 0  0 ❌ ±0 
380 379 runs  +1 026  333 056 ✅ +974  47 323 💤 +52  0 ❌ ±0 

Results for commit 3db4686. ± Comparison against base commit 6ce3740.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dask.array.linalg.lstsq raises LinAlgError on rank-deficient input (numpy returns minimum-norm solution)

1 participant