Skip to content

Preserve least-squares optimum in svdtf reflection correction - #437

Merged
wang-chen merged 1 commit into
pypose:mainfrom
Afloat16:fix/svdtf-reflection-optimum-20261020
Oct 20, 2026
Merged

wang-chen merged 1 commit into
pypose:mainfrom
Afloat16:fix/svdtf-reflection-optimum-20261020

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #436.

svdtf currently negates the entire unconstrained rotation when its determinant is negative. That produces a proper rotation, but does not preserve the least-squares optimum. For the six-point example in the issue, it returns SSE 112 instead of the attainable minimum 8. Exact planar rigid alignments can also be affected by the sign chosen for the null singular direction.

Apply the determinant correction only to the weakest singular direction. The correction is allocated from the singular values, preserving device and dtype; the SVD factors are not modified in place. The public SE(3) return type, translation formula, and separate svdstf implementation are unchanged.

Add regression coverage for reflections along each axis, exact planar and full-rank rigid transforms, translated/rotated coordinate frames, mixed and multidimensional broadcast batches, float32/float64, and float64 raw-output autograd checks for both determinant signs.

Validation on Linux, Python 3.12.14, PyTorch 2.7.1+cpu, torchvision 0.22.1+cpu, and NumPy 2.3.5:

  • New regression file: unchanged baseline 14 failed / 4 passed; this change 18 passed.
  • Full repository pytest: unchanged baseline 179 passed / 18 skipped; this change 197 passed / the same 18 skipped. All skips are existing CUDA requirements. Both runs retain the same 9 warnings and all original tests and official fixtures.
  • Additional deterministic numerical checks cover 200 proper/reflected/noisy full-rank cases, the singular-value objective bound, rigid-frame equivariance, batching, rank-deficient forward cases, noncontiguous inputs and input immutability.
  • Changed Python files compile and have no trailing whitespace.

The raw returned .tensor() passes finite-difference gradchecks for both determinant signs. Separate downstream .matrix() gradchecks have an inherited discrepancy on both the baseline and this change; this PR does not change LieTensor gradient conventions or claim to fix that behavior. GPU execution, end-to-end ICP/EPnP quality and performance were not validated. Existing CPU ICP/EPnP tests do pass as part of the complete suite.

Correct only the weakest singular direction when the SVD rotation is
improper, and cover reflected, planar and batched rigid alignments.

Fixes pypose#436.

Signed-off-by: Afloat <[email protected]>
@wang-chen
wang-chen requested a balanced review from Copilot October 20, 2026 12:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wang-chen
wang-chen requested a balanced review from Copilot October 20, 2026 12:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wang-chen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T13:01:56.207820Z 29b1a58 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 29b1a58f2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wang-chen
wang-chen merged commit f9b0882 into pypose:main Oct 20, 2026
4 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.

svdtf reflection correction can return a non-minimizing rigid alignment

3 participants