Skip to content

fix(state_ops): infer Schmidt dimensions from row vector size - #2059

Open
khushalx wants to merge 1 commit into
vprusso:masterfrom
khushalx:codex/schmidt-row-vectors
Open

khushalx wants to merge 1 commit into
vprusso:masterfrom
khushalx:codex/schmidt-row-vectors

Conversation

@khushalx

@khushalx khushalx commented Dec 1, 2026

Copy link
Copy Markdown

Description

schmidt_decomposition and schmidt_rank accept row vectors, but dimension inference treats a (1, n) state as having just one amplitude. A Bell state such as np.array([[1, 0, 0, 1j]]) / np.sqrt(2) raises a reshape error with either default dimensions or dim=2.

Use the vector's element count for dimension inference in both routines. Explicit subsystem dimensions and operator inputs retain their existing paths. Tests check the rank and reconstruct the complex state from its Schmidt factors. Four cases fail before the fix.

AI assistance: Codex (GPT-6) reproduced the bug, implemented and reviewed the fix, and ran the checks below. No human review before posting.

Changes

  • Infer subsystem dimensions from all amplitudes of a row vector.
  • Document accepted vector shapes and test default, scalar and explicit dimensions.

Checklist

  • Repository Ruff lint and formatting checks pass.
  • Full pytest suite: 4,145 passed, 59 skipped, 1 xpassed.
  • Documentation build completed successfully (unrelated CVXOPT example warning).

A row-shaped bipartite state has length one but still has all of its amplitudes. Dimension inference should use the amplitude count in both Schmidt routines.

Assisted-by: Codex:GPT-6
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant