Variational quantum circuit module. Provides support to variational circuits on mixed states. Based on QuTiP
Three sub-modules are provided:
measure
: provides some measures of qubit systemscom_measure
: return the probability distribution of the measurement in computational basis.sep_purity
: measure the purity of subsystems.fid_ref
: measure the fidelity between the subsystem of a state and a reference state.c_entropy
: measure the entropy of the output of the measurement in computational basis.dst
: use destructive swap test [10.1103/PhysRevA.87.052330] to obtain purity of [sub]systems.
vcirc
: provides variational circuit class- Create a variational circuit instance with N qubits:
vc = vcirc(N)
- Input state can be attached:
vc.add_input(state)
- Add a layer of ansatz by
vc.add_ansatz(x)
- Customized structure can be used
vc.add_ansatz(x,structure=custom_struc)
- Define structure as functions:
def custom_struc(parameters,N): qc = QubitCircuit(N) # qc.add_gate(...) ... add quatnum gates ... return qc
- Customized structure can be used
- Evaluation is simple:
vc.apply_to(state)
- Ansatzes can be added to subsystems:
vc.add_ansatz(x,pos=[0,1])
- The unitary given by the circuit can be obtained by
vc.compress()
- Structure of the ansatzes can be read from
vc.structures
, which contains a list of the tuples (name_of_ansatz
,subsystem
,hyper-parameters
). - Current parameters can be read from
vc.para
.
- Create a variational circuit instance with N qubits:
optimize
: utilizescipy.optimize
to optimize variational circuitscirc_maximize
andcirc_minimize
:res = circ_minimize(x0,input_state,vcircuit,test_function,*args)