Pylove is a quantum circuit simulator specifically for noisy circuits acting on stabilizer codes. The types of circuits it is build to handle consist of rotations generated by logical operators. Noisy circuits are simulated via statevector simulation, where a mixed state density matrix is constructed from a mixture of pure states coming from a specified number of shots.
For an
Pylove makes use of the OpenFermion software package for manipulating Pauli operators and Fermionic operators.
This simulator was used in a study of quantum error mitigation using encodings of fermionic systems into stabilizer codes. As such, included in this simulator code are a number of tools for generating fermionic encodings and encodings fermionic Hamiltonians into qubit Hamiltonians acting on a stabilizer code. Fermionic operators are mapped to logical operators of the code.
Let us now discuss the usage of the simulator code with a simple example that is given in more detail in tutorial.ipynb
and example notebooks. Also refer to the documentation in docs.ipynb
.
Specify a stabilizer group by a list of generators given as OpenFermion QubitOperator
objects
stabs = [
QubitOperator('X1 Z0 Z2 Z4'),
QubitOperator('X3 Z2 Z4 Z8'),
QubitOperator('X5 Z0 Z4 Z6'),
QubitOperator('X7 Z4 Z6 Z8')
]
The initial state is specified to be the
log_ops = [
QubitOperator('Z0'),
QubitOperator('Z2', -1),
QubitOperator('Z4'),
QubitOperator('Z6', -1),
QubitOperator('Z8', -1)]
The circuit is assumed to consist of a sequence of rotations
Specified by a list of pairs, specifyin the angle and the logical operator
circuit_schedule = [
angle[0]*logical_op[0],
angle[1]*logical_op[1],
...
]
In the above, logical_op[i]
must all commute with all of the stabilizers
Pauli noise channels can be simulated, one specifies the Pauli Kraus operators as always as OpenFermion QubitOperator
objects. Noise acting following CNOT gates can be constructed as below, where qubit 0 is the control qubit and qubit 1 is te target.
my_gate_noise = [
[QubitOperator(()), QubitOperator('Y0'), QubitOperator('Y0 Y1')],
[.998, .001, .001]]
The most important function is pylove_simulation
which contains all the relevant functions for simulation. It uses the stabilizers and the logical operators to fix the initial state. The quantum circuit is then simulated
output_state = pylove_simulation(
stabilizers=stabs,
logical_operators=log_ops,
quantum_circuit=circuit,
gate_noise=my_gate_noise,
shots=100
)
One also has the option of specifying how many CPUs should be used for parallel processing with the keywork arg cpus=
.
After the simulation, the resulting pylove_state
object can be manipulated. One can calculate expectation values of observables or simulation fidelities with the tr
function
tr(output_state, output_state.ideal())
The simulator is originally intended to be used for studies of quantum error mitigation in the presence of a collection of
- code: Only the codespace is kept, this is the cheapest simulation in terms of memory
- full: All syndrome spaces are kept, this is exponentially costly in the rank of the stabilizer group
- custom: One can specify which syndrome spaces to keep by giving the syndrome patters of the desired subspaces
One can then simulate postselection with the postselect
function. The result is a new state with a larger overlap with the ideal state
postselected_state = postselect(state=new_graphstate, mode='code')
tr(output_state.ideal(), postselected_state)
See the notebook tutorial.ipynb
for an example of Pylove in action and refer to the documentation in docs.ipynb
.