Repository navigation
fix(channel_ops): accept wrapped CP Kraus forms in kraus_to_choi - #1989
Open
G26karthik wants to merge 1 commit into
Open
G26karthik wants to merge 1 commit into
G26karthik wants to merge 1 commit into
Conversation
The sys=2 fast path added in 1f5b094 (vprusso#1643) treated every nested list as [A, B] pairs instead of using normalize_kraus. The wrapped CP forms [[K1], [K2], ...] raised IndexError, and [[K1, K2, K3]] silently returned the Choi matrix of X -> K1 X K2^*, dropping K3. This broke is_completely_positive, choi_rank and the other predicates that call kraus_to_choi. Classify the input with normalize_kraus, as the general path does. Output for the flat, stacked, and paired forms is unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Author
|
@vprusso CI is green on this one. It lets |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
normalize_krausdocuments three completely positive list forms that are accepted across the package:[K1, ..., Kr],[[K1], ..., [Kr]]and[[K1, ..., Kr]](r > 2). Thesys=2fast path added tokraus_to_choiin #1643 does its own format check instead: anything that is not a flat list is read as[[A, B], ...]pairs. So[[K1], [K2], [K3]]raisesIndexError, and[[K1, K2, K3]]is read as the single pair(K1, K2), which silently returns the Choi matrix ofX -> K1 X K2^*and dropsK3. Thesys != 2path goes throughpartial_channel, which already usesnormalize_kraus, so only the defaultsysis affected.Because
is_completely_positive,choi_rankand other predicates callkraus_to_choi, they give wrong answers for these forms too. WithK = [[[1, 0], [0, 0]], [[0, 1], [0, 0]], [[0, 0], [1, 0]] / 2](flat list: CP, Choi rank 3):Changes
normalize_krausin thesys=2fast path, aspartial_channel,apply_channelandchannel_dimalready do. For the CP forms the left stack is reused as the right one, as before. Flat lists, stacked 3-D arrays and[[A, B], ...]pairs take the same path as before.is_trace_preservinganddual_channelstill do their own list dispatch, so I left them out of this PR to keep it to one concern (and away from theis_quantum_channelwork in #1987). Happy to send that separately if you want it.Checklist
rufffor errors related to code style and formatting. (ruff checkandruff format --checkclean)pytest. (pytest toqito/channel_ops/tests/test_kraus_to_choi.py toqito/channel_ops/tests/test_partial_channel.py toqito/channel_props/tests/test_choi_rank.py toqito/channel_props/tests/test_is_completely_positive.py toqito/channels: 115 passed)