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

adding new single-qubit gates #333

Merged
merged 7 commits into from
Sep 14, 2024
Merged

Conversation

Fe-r-oz
Copy link
Contributor

@Fe-r-oz Fe-r-oz commented Aug 3, 2024

This PR aims to add the missing single qubit gate w.r.t stim. Added and Tested all the missiing single qubit gates that stim has: https://github.com/quantumlib/Stim/blob/main/doc/gates.md

In this book(https://threeplusone.com/pubs/on_gates.pdf), SQRTX is called V gate, so V gate is used as its name.

julia> sHadamardXY(1)
sHadamardXY on qubit 1
X₁ ⟼ + Y
Z₁ ⟼ - Z

julia> sHadamardYZ(1)
sHadamardYZ on qubit 1
X₁ ⟼ - X
Z₁ ⟼ + Y

julia> sV(1)
sV on qubit 1
X₁ ⟼ + X
Z₁ ⟼ - Y

julia> sInvV(1)
sInvV on qubit 1
X₁ ⟼ + X
Z₁ ⟼ + Y

julia> sSQRTY(1)
sSQRTY on qubit 1
X₁ ⟼ - Z
Z₁ ⟼ + X

julia> sInvSQRTY(1)
sInvSQRTY on qubit 1
X₁ ⟼ + Z
Z₁ ⟼ - X

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 3, 2024

The gates fail this test (hope this is not too bad), The gate pass all the other tests for single-qubit gates.

s = random_destabilizer(1)
Expression: sop * s == sqsop * s == cop * s == csqop * s == tcop * s == stcop * s

@Krastanov
Copy link
Member

I would expect there to be a but in the gates if they fail this test.

@Fe-r-oz Fe-r-oz marked this pull request as draft August 3, 2024 20:23
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 3, 2024

Indeed, some part of implementation is wrong. My bad!

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 4, 2024

Indeed, the implementation was so bad. In particular, The macro qubit kernel descriptions were wrong that's why the failing tests occured in this testset "Convert between small ops".

The build failed because of more occasional (comparison to MC under perturbative expansion purification example testset) error not related to this PR.

The windows latest CI fails because of this error:

Starting tests with 1 threads out of `Sys.CPU_THREADS = 4`...
ERROR: LoadError: InitError: Python: ImportError: DLL load failed while importing _path: The specified procedure could not be found.

@Fe-r-oz Fe-r-oz marked this pull request as ready for review August 4, 2024 13:29
src/symbolic_cliffords.jl Outdated Show resolved Hide resolved
test/test_symcliff.jl Outdated Show resolved Hide resolved
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 5, 2024

BTW, A small comment that is not related to this PR:

groupify, minimal_generating_set, pauligroup, normalizer, centralizer, contractor, delete_columns,

There is no delete_columns function in the group_tableaux file so when testing locally, there is error due to this. I checked this file, there is no delete_columns function.

@Krastanov
Copy link
Member

There is no delete_columns function in the group_tableaux

should be here

function delete_columns(𝒮::Stabilizer, subset)

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 5, 2024

Thanks, It seems I don't have this in the test_project_trace_reset!, prolly because I didn't sync the PR.

@Fe-r-oz Fe-r-oz requested a review from Krastanov August 5, 2024 20:11
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.75%. Comparing base (b02add9) to head (4bfd7c3).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #333      +/-   ##
==========================================
+ Coverage   82.41%   82.75%   +0.34%     
==========================================
  Files          62       62              
  Lines        4162     4308     +146     
==========================================
+ Hits         3430     3565     +135     
- Misses        732      743      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

This looks pretty good. Thank you for spending time on it! I think the only thing left is:

  • thinking through whether there is some more idiomatic naming convention for us compared to the DAG suffix. Probably we will just stick to that suffix.
  • Having a set of tests that specifically check that gates match the definitions that stim uses. E.g. something like CliffordOperator(gate) == C"Z X" or whatever the appropriate C string is, taken from the markdown file you shared.

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 11, 2024

For us, Inv is the naming convention that has been used. Primarily, it can be seen in the LinearAlgebra.inv method which we use a lot for inv(CliffordOperator(...)). Searching for inv, we see quite a lot of use of this in ~20 files, making it default convention to compared to DAG. Also, sInvPhase and sInvZCrY are existing examples of inv convention. Given that, should we revert back to using Inv?

Please share your thoughts on this. Thank you!

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Aug 14, 2024

Thanks again for the very hepful Task TODO list and feedback! Hopefully, the tasks have been addressed.

@Fe-r-oz Fe-r-oz marked this pull request as ready for review August 14, 2024 07:51
@Krastanov Krastanov merged commit 05491d9 into QuantumSavory:master Sep 14, 2024
15 of 16 checks passed
@Krastanov
Copy link
Member

Thanks, this is very useful!

@Fe-r-oz Fe-r-oz deleted the newgates branch September 14, 2024 07:15
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