Skip to content

fix(matrix_props): scale purity bound by trace squared in is_k_incoherent - #2057

Merged
vprusso merged 1 commit into
vprusso:masterfrom
chenyangsu:fix/is-k-incoherent-purity-scaling
Dec 1, 2026
Merged

vprusso merged 1 commit into
vprusso:masterfrom
chenyangsu:fix/is-k-incoherent-purity-scaling

Conversation

@chenyangsu

Copy link
Copy Markdown
Contributor

Description

For rho = np.full((4, 4), 0.25), is_k_incoherent(0.5 * rho, 3) returns True while is_k_incoherent(rho, 3) returns False, because the purity shortcut compares trace(mat @ mat.conj().T) against 1 / (d - 1) assuming unit trace. Comparing against trace(mat) ** 2 / (d - 1) for positive trace keeps the Johnston et al. (2022) Eq. (8) bound invariant under positive scaling. Happy to normalize mat upfront instead if you prefer.

Changes

  • Scale the purity threshold by trace(mat) ** 2 in is_k_incoherent.
  • Add positive-scaling regression tests in test_is_k_incoherent.py.

Checklist

  • Use ruff for errors related to code style and formatting.
  • Verify all previous and newly added unit tests pass in pytest.
  • Check the documentation build does not lead to any failures.

Testing: pytest toqito/matrix_props/tests/test_is_k_incoherent.py -> 32 passed (new test fails on master for scales 0.1 and 0.5). pytest toqito/matrix_props/tests/ -> 537 passed, 6 skipped. ruff check, ruff format --check, and ty check passed.

@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!

@vprusso vprusso left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @chenyangsu. The k-incoherent set is a cone while purity scales quadratically, so scaling the bound by trace squared is the correct fix, and the trace > 0 guard keeps the shortcut from accepting non-PSD input. Merging.

@vprusso
vprusso merged commit c2e5d5e into vprusso:master Dec 1, 2026
8 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.

2 participants