Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make apply! work when used with any order of subsystem indices #133

Merged
merged 6 commits into from
Sep 14, 2023
Merged

Make apply! work when used with any order of subsystem indices #133

merged 6 commits into from
Sep 14, 2023

Conversation

ba2tro
Copy link
Contributor

@ba2tro ba2tro commented Sep 9, 2023

apply! needs to be able to permute the operator based on the order of the indices of the qubits/subsystems, e.g., doing CNOT2->1. Resolves QuantumSavory/QuantumSavory.jl/issues/39 cc @Krastanov

@ba2tro
Copy link
Contributor Author

ba2tro commented Sep 9, 2023

Would it be better to just have an optional boolean keyword arg in apply! like perm instead of running the for loop for every multi-qubit system?

@Krastanov
Copy link
Collaborator

Thanks for starting this!

The apply! on Operator, and the apply! with SuperOperator both suffer from the same bug and should be fixed.

I would suggest not adding any keyword arguments to apply!. For now we can just pay the cost of this inefficient implementation. The proper fix for the slowness would be to use a sufficiently general stridded array multiplication.

@Krastanov
Copy link
Collaborator

Also, I would suggest having a test that has three operators and a permutation that is not its own inverse, e.g. apply!(a⊗b⊗c, (2,3,1),A⊗B⊗C) ≈ (C*a)⊗(A*b)⊗(B*c). The current CNOT tests do not cover such cases (because permutations of 2 elements are their own inverses).

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #133 (3c7e645) into master (fe00cb9) will increase coverage by 0.04%.
Report is 3 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
+ Coverage   93.62%   93.66%   +0.04%     
==========================================
  Files          25       25              
  Lines        3105     3125      +20     
==========================================
+ Hits         2907     2927      +20     
  Misses        198      198              
Files Changed Coverage Δ
src/apply.jl 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Krastanov
Copy link
Collaborator

I did some minor cleanup in the last commit. Thanks for taking care of this!

@Krastanov Krastanov merged commit 032dd82 into qojulia:master Sep 14, 2023
@ba2tro ba2tro deleted the apply branch September 18, 2023 12:28
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.

Bug when applying CNOT in reverse
2 participants