BQSKit / bqskit

Berkeley Quantum Synthesis Toolkit
Other
108 stars 31 forks source link

I'm getting a type error when compiling a circuit #188

Open alonkukl opened 10 months ago

alonkukl commented 10 months ago

I'm using the bqkit V1.1 and I'm getting a type error

The code that reproduces it is:

import qiskit as qk from bqskit import compile

from hubbard import EnergyObjective, hamiltonian_qiskit hm_lattice = { 'x_dimension' : 2, 'y_dimension' : 1, # 2D x_dim * y_dim grid 'tunneling' : 1.0, # hpping term t 'coulomb' : 2.0, # interaction term U 'spinless' : False, # double negative, so do have spins 'periodic' : False, # do not allow wrap-around hopping }

hm_filling = { 'n_electrons_up' : 1, 'n_electrons_down' : 0, }

hm_bk = hamiltonian_qiskit(fermion_transform='bravyi-kitaev', **hm_lattice)

bk_objective = EnergyObjective(hm_bk, trotter_steps=4, trotter_mode='trotter', **hm_filling)

bk_circuit_instance = bk_objective.generate_circuit([0.1]*bk_objective.npar())

c_bk = qk.transpile(bk_circuit_instance, basis_gates=["u3", "cx"])

for gate, count in c_bk.count_ops().items(): print("gate %s count: %d" % (gate, count))

print(c_bk.draw())

for cir in [c_bk]:

opt_circuit = compile(cir, optimization_level=2)

print("Compiled Circuit Statistics:")
print("  Gate Counts:", opt_circuit.gate_counts)
print("  Connectivity:", opt_circuit.coupling_graph)

Then the error I get is: TypeError: bad operand type for abs(): 'U3Gate'

edyounis commented 9 months ago

I cannot reproduce this issue, nor can I find a call to abs() that could possibly take a U3Gate. Are you still able to reproduce this issue? Can you provide more of the traceback?