qiboteam / boostvqe

Using DBI to boost VQE optimization
4 stars 1 forks source link

TFIM 2 CNOT not 3 CNOT compiling #70

Open marekgluza opened 4 months ago

marekgluza commented 4 months ago

Zrzut ekranu z 2024-07-17 17-22-48

Please implement this as an evolution oracle similar to #69

Here are some checks for the decomposition


c.add(gates.CNOT(0,1))
c.add(gates.Z(0))
c.add(gates.CNOT(0,1))

c2 = qibo.Circuit(2)
c2.add(gates.Z(0))

np.linalg.norm(c2.unitary()-c.unitary())
c = qibo.Circuit(2)

c.add(gates.CNOT(0,1))
c.add(gates.X(0))
c.add(gates.CNOT(0,1))

c2 = qibo.Circuit(2)
c2.add(gates.X(0))
c2.add(gates.X(1))
np.linalg.norm(c2.unitary()-c.unitary())
shangtai commented 3 weeks ago

Opened a new branch called tfim_2cnot and added the class tfim_EvolutionOracle(EvolutionOracle). It can be accessed here.

This is a work in progress.

shangtai commented 2 weeks ago

Example of code:

hamiltonian = SymbolicHamiltonian(nqubits=3)

# Instantiate the oracle with 10 Trotter steps
oracle = tfim_EvolutionOracle(h=hamiltonian, steps=10, evolution_oracle_type="trotter")

# Example: Run the circuit for qubit a=0, B_a=0.8, and t_duration=1.0
circuit = oracle.circuit(a=0, t_duration=1.0, B_a=0.8)

# Print the resulting circuit to visualize it
print(circuit.summary())

Produces

Circuit depth = 22 Total number of gates = 22 Number of qubits = 3 Most common gates: rx: 10 rz: 10 cx: 2