Open Fe-r-oz opened 2 months ago
That would be a nice check to implement. I imagine the symplecticinverse
does not match the same conventions as enumerate_cliffords
. E.g. there are places where an integer has to be represented as bits or where a submatrix needs to be created. In such places, if one does not follow the same conventions, the inverse will not work correctly. E.g. are integers little or big endian, are submatrices inserted in the left or right corner of a bigger matrix, are symplectic matrices represented as a big block-diagonal matrix with just 4 quardrants or a matrix made out of many small 2x2 matrices.
Thank you. Your insight is really helpful. I will be more careful and ponder about this.
I did noticed that enumerate_cliffords_slow(n, i, ;...)
is implemented in-place, with Tableau
manipulations and updates, and also you commented that 'their algorithm seems wrong as ⟨w'₁|wₗ⟩=bₗ which is not always zero.'
The symplecticinverse
indeed gives different answer if gn
is even slightly altered. E.g 0
instead of 1
( or vice versa) at very few index locations. Yesterday, initially, when rewriting the pesudocode from paper, I overlooked indexing at one place, and I got the answer 62340
instead of 62345
. Thus, the symplecticinverse
is sensitive to even small changes might happen to gn
.
Pedagogical details/ Additional Context
The following is not done/implemented in the paper per se but authors talk about circuit compilation:
...
In addition, Juqst.jl
also parse the symplectic matrix(gn)
in the form of the Aaronson/Gottesman Tableau.
The paper discusses by the list of parameters (α, β, γ, δ, r, s)
where α, β, γ, δ
are n × n
matrices of bits, and r, s
are n
-bit vectors. He splits the gn
into (α, β, γ, δ)
in one function, and in another, he converts it to the form of Aaronson/Gottesman Tableau. There is no testing for this, so I hesitated relying on this for the time being.
I have yet to check whether after this, does symplecticinverse
still work on the modifed gn
meaning is this reordering affect the result?
...
I think the overgoal is circuit compilation that you point out in issue 11
as authors say "given the list (α, β, γ, δ, r, s)
, there is a classical algorithm for compiling a circuit implementing U
which is composed of O(n²/ log n)
gates from the gate set {H, CNOT,P}
". This task can be divided into many small PR that address one thing at a time. I am pondering about step-by-step breakdown of what these tasks might look like and I am looking forward to discussing it with you soon.
Also, in #13, this paper also have one algorithm (Algorithm 1
) that relies on the calculation of symplectic matrix. Theorem 24
of this papers talks about the same stuff about symplectic transvections as the aforementioned paper in first comment does. Thus, there is overlap between these two issues/papers (11 and 13) as they appears to be relying on symplectic transvections.
I have yet to check whether after this, does symplecticinverse still work on the modifed gn meaning is this reordering affect the result?
Short answer: No, it would not work. symplecticinverse
only works on symplectic
matrices gn
, not on matrices that are created by decomposing gn
into (α,β,γ,δ)
and then forming new matrix in accordance with Aaronson/Gottesman Tableau with additional last column representing r
.
I may not have raised a good question, but I felt compelled to provide an answer. This question seems irrelavant to the present discussion.
Additional Context
If I am not mistaken, by 4 quadrants, you refer to the 4 submatrices of the Aaronsom/Gottesman tableau. Juqst.jl
tries to proceed with decompositing the original symplectic matrix gn
from the paper for which the paper provides pseudocode, and decomposes into to (α,β,γ,δ)
submatrices . Then, he arranges these quadrants into the Aaronson/Gottesman tableau form. Most likely, column vector towards the end representing r
is added when their tableau structure also has. The resulting matrix in now (2n x 2n+1)
which is not a symplectic.
These is done by two functions by Juqst.jl
, parseSymplectic
and stabiliseSymp
(which are not mentioned in the original paper) which makes sense as in paper, authors are only concerned with the symplectic matrix (gn
), and not the circuit compilation which is not the goal of the paper per se.
julia> symplecticinverse(stabiliseSymp(symplectic(62345, 7), 1)[1:14, 1:14])
12242461102891138205349303168274
Thus, only the complete pesudocode in the paper and 'some' part of Juqst.jl
implementation can be verified with correctness tests. The above does not work as I am trying to check whether a matrix in Aaronson/Gottesman form has symplectic inverse which will be incorrect.
P.S. This comment is not directly helpful to the discussion which is related to symplectic matrices. This is because I am checking the outcomes of some steps required for proceeding into circuit compilation.
To do the correctness check you need to implement symplecticinverse
in a way that uses the conventions from this codebase, not the conventions from the paper.
Describe the bug 🐞
enumerate_clifford_slow(n, i, ;...)
gives a canonical mapping from integer to symplectic groupSp(2n)
. This algorithm is based on generalized Gram-Schmidt orthogonalization procedure (see section B Symplection Gram-Schmidt and II. A for details of this algorithm from this paper).The same paper provides a useful correctness check in form of the
SYMPLECTICinverse(n, gn)
algorithm which provides an inverse map, meaning indexing a given group element.SYMPLECTICinverse(n, gn)
requiresn
andgn
wheregn
is returned bySymplecticImproved.
See the additional context for more details.I am working on the PR towards the
SymplecticImproved O(n³)
algorithm following Stefan's instructions from #11. For correctness sake, I implemented theSymplecticImproved
nearly as exactly as possible (1) from the paper itself since I was not satisfied with just theJuqst.jl
's implementation (2). There are a few minor differences between (2)'s implementation and the pseudocode in the paper, so for safety sake, it was better to not just rely onJuqst.jl
without testing it first.For these two approaches (1, 2) , this test should pass as it serve as a correctness check:
This test passes for both of these two approaches (1, 2):
It is noted that for these two approaches (1, 2) this works for
n > 2
.Expected behavior
For all the values of
n>2
that obey Symplectic cardinality, these should hold true forenumerate_clifford_slow(n, i, ;...)
:@test QuantumClifford.symplecticinverse(stab_to_gf2(tab(QuantumClifford.enumerate_cliffords_slow(n, i, onlycoset=false)))) == i
I also had a look at
test_enumerate.jl
but I didn't find tests forenumerate_cliffords_slow
. I think we should add a similar test as forenumerate_cliffords_slow
after it becomes bug-free. In the meantime, I will polish the PR and soon submit it for further discussion and link to this issue. I am sharing a conceptual MRE that I am getting locally as (2) can be referenced for existing implementation.Note: We are only interested in symplectic cardinality as the authors designed algorithms that return ith element from symplectic cardinality. That's why
onlycoset=false
, see the doctest inenumeration.jl
for more details. Also, under the hood,onlycoset=false
by default forenumerate_clifford_slow(n, i, ;...)
for this reason as well.Minimal Reproducible Example 👇
Error & Stacktrace or other complete output produced by the MRE ⚠️
Even for a few random cases, the above test does not hold:
Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
- Output of
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
- Output of
versioninfo()
Additional context
SymplecticImproved(i, n) O(n³)
note: WIP. PR soon to be submitted.
And this test passes:
Symplectic(n, i)
O(n⁴) algorithmIn order to relate with
enumerate_cliffords_slow
Pedagogical Detail: O(n⁴) and O(n³) algorithms provided in the paper provide different canonical mapping as acknowelged in the paper. Also,
n
can be deduced fromgn
. Thus,gn
is only parameter needed forSYMPLECTICinverse
.