Skip to content

Fix: MPS compatibility issues and invalid demosaic method#94

Merged
singer-yang merged 5 commits intovccimaging:mainfrom
BecIcan:fix-demosaic-method
Dec 31, 2025
Merged

Fix: MPS compatibility issues and invalid demosaic method#94
singer-yang merged 5 commits intovccimaging:mainfrom
BecIcan:fix-demosaic-method

Conversation

@BecIcan
Copy link
Copy Markdown
Contributor

@BecIcan BecIcan commented Dec 31, 2025

Fix: Change invalid demosaic method from '3x3' to 'malvar'
The Demosaic class only supports 'bilinear' and 'malvar' methods.

Fix: Add CPU fallback for torch.linalg.lstsq on MPS device
The aten::linalg_lstsq.out operator is currently not implemented for the MPS device in PyTorch.Added a try-except block in geolens.py to automatically fallback to CPU for this specific calculation.


Note

Compatibility and correctness fixes

  • In deeplens/geolens.py, compute_intersection_points_2d now falls back to CPU for torch.linalg.lstsq when running on MPS (A.device.type == "mps"), then moves results back to the original device.
  • In deeplens/sensor/isp.py, updates InvertibleISP to use a valid Demosaic method "malvar" instead of the unsupported "3x3".

Written by Cursor Bugbot for commit 1595451. This will update automatically on new commits. Configure here.

- The Demosaic class only supports 'bilinear' and 'malvar' methods
- Changed to 'malvar' for higher quality demosaicing
- This fixes the error when initializing InvertibleISP
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes two compatibility issues in the DeepLens library: an invalid demosaic method parameter and missing MPS device support for a linear algebra operation.

  • Corrected invalid demosaic method from '3x3' to 'malvar' in the InvertibleISP pipeline
  • Added CPU fallback for torch.linalg.lstsq operation when running on MPS devices

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
deeplens/sensor/isp.py Fixed bug by changing demosaic method from unsupported '3x3' to valid 'malvar' method
deeplens/geolens.py Added try-except block to handle MPS device limitation for lstsq operation with CPU fallback

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deeplens/geolens.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@singer-yang singer-yang merged commit acaa31a into vccimaging:main Dec 31, 2025
2 checks passed
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.

3 participants