fixed free() pointer error that was throwing segfaults on newer systems
[strong_simulation_stabilizer_rank.git] / README.txt
1 Strong simulation of multi-Pauli measurements using minimal stabilizer state decompositions
2 -------------------------------------------------------------------------------------------
3
4 PREREQUISITES:
5
6 You will need the Lapacke library to run strongsim[1-12]_rellerr.c (in particular, the lapacke.h header).
7 For instance, in Debian, you can obtain this by running:
8 $ sudo apt install liblapacke-dev
9
10 BUILD:
11
12 1. We start with the code that scales quadratically with stabilizer rank because it calculates expectation values to zero relative error. Build code for stabilizer rank tensor multiple you'd like to use. Here we choose k=6.
13 $ cp strongsim6.c strongsim.c
14 $ make strongsim
15
16 2. Now we build the code that scales linearly with stabilizer rank because it calculates expectation values to non-zero relative error. Build code for stabilizer rank tensor multiple you'd like to use. Here we choose k=6.
17 $ cp strongsim6_relerr.c strongsim_relerr.c
18 $ make strongsim_relerr
19
20 3. This produces libraries (*.so) of core functions like SHRINK, INNERPRODUCT, EXTEND, etc. since you might want to use them in other code. This means we need to put them somewhere the linker can find them. Follow 3a) for a temporary and easy method that will only be valid for the current shell session and follow 3b) for a persistent method that requires root access.
21 3a) Update LD_LIBRARY_PATH to see the library:
22 $ export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
23 or
24 3b) If you have root privileges put the *so library /usr/local/lib or whatever library directory in your path. Then, use ldconfig to write the path in the config file:
25 $ sudo cp ./*so /usr/local/lib
26 $ sudo echo "/usr/local/lib" >> /etc/ld.so.conf
27 $ sudo ldconfig
28
29 4. Build code for generating random commuting Pauli inputs (necessary for the strongsim[1-12]_relerr.c code since it requires a Hermitian observable to get away with using the square root number of stabilizer states).
30 $ make randominputcommutingHermitianPauli2
31
32 5. Build code for generating random (non-commuting) Pauli inputs (good enough for the strongsim[1-12].c code).
33 $ make randominputPauli
34
35 6. Build Hilbert vector space code to check our results.
36 $ make multipauli
37
38
39 TEST CODE:
40 1. Run test diagonositic for strongsim.c (zero relative error).
41 $ bash ./test.bash
42
43 2. Run test diagonositic for strongsim_relerr.c (non-zero relative error).
44 $ bash ./test2.bash
45
46
47
48 Details of source code files:
49
50 strongsim[1-12]_relerror.c takes one argument of the number of stabilizer states to sample and then takes stdin arguments for the number of qubits, t-gate magic states and then the Paulis
51
52 strongsim[1-12]_relerror.c scale linearly with the stabilizer rank and calculate up to finite relative error while strongsim[1-12].c scale quadratically with the stabilizer rank and calculate up to zero relative error.
53
54 strongsim*c need Pauli measurement inputs (with the associated phases) which can be randomly generated with randominputPauli.c and the output from strongsim*c can be verified with multipauli.c
55
56 strongsim[1-12]_relerror.c need commuting Pauli measurement inputs (with the associated phasese) which can be randomly generated with randominputcommutingHermitianPauli2.c and can be verified with multipauli.c
57
58 randominputcommutingHermitianPauli.c uses a brute-force random sampling of the commuting Paulis whereas *2.c uses random Clifford operations on initially separable Paulis to generate the commuting Paulis. *2.c is the only practically viable method for more than 30 Paulis on a desktop computer.
59
60 NOTE: current strongsim*c only support the same number of T gates as number of qubits!
61
62 Pd.txt is a tabulated list of P(d) values for strongsim[1-12]_relerror.c.