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

noncliff: add tests for conjugate destabs #413

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

Fe-r-oz
Copy link
Contributor

@Fe-r-oz Fe-r-oz commented Nov 2, 2024

This PR removes the TODO comment and add tests for conjugation. This PR is inspired from this comment: #408 (comment)

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.

That would be very useful, thank you! I added a comment on a few improvements that can be made to make the tests more rigorous


@testset "conjugate destabs" begin
@testset "Single qubit Clifford gate" begin
for s in [S"X", S"Y", S"Z", S"-X", S"-Y", S"-Z"]
Copy link
Member

Choose a reason for hiding this comment

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

to make the tests more trustworthy we should have multi-qubit cases and cases of non-clifford operations -- it can be in a separate testset to keep this already nice testset easy to read. The extra testset can contain stuff like:

for n in [5, 10, 100]
    for g in [tHadamard, tPhase, pcT]
        eg = embed(g,...)
        sm = GeneralizedStabilizer(random_stabilizer(n))
        ...

Copy link
Contributor Author

@Fe-r-oz Fe-r-oz Nov 2, 2024

Choose a reason for hiding this comment

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

embed is not defined for CliffordOperator, only for PauliOperator, so instead used: enumerate_cliffords(i, clifford_cardinality(j)) for multi-qubit CliffordOperators. I hope you like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of embed for CliffordOperator, we can use CliffordOperator(sHadamard(2), 5)... darn...

@Fe-r-oz Fe-r-oz marked this pull request as draft November 2, 2024 13:47
@Krastanov Krastanov added the Skip-Changelog label for control of CI: skips the changelog check label Nov 2, 2024
@Fe-r-oz Fe-r-oz marked this pull request as ready for review November 2, 2024 14:27
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Nov 2, 2024

Thank you for your speedy comments and insights. That is much appreciated!

I hope this is satisfactory. n=100 crashed my PC so just used n=10 max.

Comment on lines 56 to 60
(1, [tHadamard, tPhase, tId1]),
(2, [tCNOT, tCPHASE, tSWAP]),
(3, [enumerate_cliffords(3, clifford_cardinality(3)), CliffordOperator(sHadamard(3), 3), CliffordOperator(sCNOT(1, 2), 3)]),
(4, [enumerate_cliffords(4, clifford_cardinality(4)), CliffordOperator(sHadamard(4), 4), CliffordOperator(sCNOT(2, 1), 4)]),
(5, [enumerate_cliffords(5, clifford_cardinality(5)), CliffordOperator(sHadamard(5), 5), CliffordOperator(sCNOT(2, 3), 5)])
Copy link
Member

Choose a reason for hiding this comment

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

this seems unnecessarily complicated. And the number of qubits is something that does not need to be specified separately

in particular, is there something special about enumerate_cliffords(n, clifford_cardinality(n)) that you are picking this choice

I will submit a few simplification suggestions later today

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there something special about enumerate_cliffords(n, clifford_cardinality(n)) that you are picking this choice

Nope. No particular reason for the choice of parameters for enumerate_cliffords.

Thank you!

Copy link
Member

Choose a reason for hiding this comment

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

to keep in the spirit of having a random check you can also just do enumerate_clifford(3, rand(1:clifford_cardinality(3))), but at this point it is just simpler to stick to random_stabilizer

@Krastanov
Copy link
Member

thanks for pushing through this, it is very helpful cleanup. Let's wait to see what the new tests say

@Krastanov Krastanov merged commit 9c1ea49 into QuantumSavory:nonclif Nov 5, 2024
9 of 12 checks passed
@Fe-r-oz Fe-r-oz deleted the fa/removeconjtodo branch November 5, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip-Changelog label for control of CI: skips the changelog check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants