qiskit-community / qiskit-bip-mapper

Qiskit transpiler plugin for BIP Mapping routing pass
Apache License 2.0
5 stars 3 forks source link

Error encountered while running readme example #6

Closed Haimrich closed 11 months ago

Haimrich commented 11 months ago

Hi everyone,

Thank you for sharing this work. After successfully installing the plugin using pip install qiskit-bip-mapper, I attempted to execute the example outlined in the README. However, my efforts were met with the following error message:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/qiskit/providers/models/backendproperties.py", line 298, in gate_property
    result = self._gates[gate]
KeyError: 'cx'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workspaces/quantum/bip.py", line 9, in <module>
    transpile(qc, backend, routing_method="bip")
  File "/usr/local/lib/python3.10/dist-packages/qiskit/compiler/transpiler.py", line 418, in transpile
    out_circuits = pm.run(circuits, callback=callback)
  File "/usr/local/lib/python3.10/dist-packages/qiskit/transpiler/passmanager.py", line 537, in run
    return super().run(circuits, output_name, callback)
  File "/usr/local/lib/python3.10/dist-packages/qiskit/transpiler/passmanager.py", line 233, in run
    return [self._run_single_circuit(circuits[0], output_name, callback)]
  File "/usr/local/lib/python3.10/dist-packages/qiskit/transpiler/passmanager.py", line 292, in _run_single_circuit
    result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
  File "/usr/local/lib/python3.10/dist-packages/qiskit/transpiler/runningpassmanager.py", line 125, in run
    dag = self._do_pass(pass_, dag, passset.options)
  File "/usr/local/lib/python3.10/dist-packages/qiskit/transpiler/runningpassmanager.py", line 173, in _do_pass
    dag = self._run_this_pass(pass_, dag)
  File "/usr/local/lib/python3.10/dist-packages/qiskit/transpiler/runningpassmanager.py", line 202, in _run_this_pass
    new_dag = pass_.run(dag)
  File "/usr/local/lib/python3.10/dist-packages/qiskit_bip_mapper/bip_mapping.py", line 171, in run
    model.create_cpx_problem(
  File "/usr/local/lib/python3.10/dist-packages/qiskit_bip_mapper/bip_model.py", line 360, in create_cpx_problem
    pbest_fid = -np.log(self._max_expected_fidelity(node, i, j))
  File "/usr/local/lib/python3.10/dist-packages/qiskit_bip_mapper/bip_model.py", line 390, in _max_expected_fidelity
    return max(
  File "/usr/local/lib/python3.10/dist-packages/qiskit_bip_mapper/bip_model.py", line 391, in <genexpr>
    gfid * self._cx_fidelity(i, j) ** k
  File "/usr/local/lib/python3.10/dist-packages/qiskit_bip_mapper/bip_model.py", line 404, in _cx_fidelity
    return 1.0 - self.bprop.gate_error("cx", [self.global_qubit[i], self.global_qubit[j]])
  File "/usr/local/lib/python3.10/dist-packages/qiskit/providers/models/backendproperties.py", line 355, in gate_error
    return self.gate_property(gate, qubits, "gate_error")[0]  # Throw away datetime at index 1
  File "/usr/local/lib/python3.10/dist-packages/qiskit/providers/models/backendproperties.py", line 308, in gate_property
    raise BackendPropertyError(f"Could not find the desired property for {gate}") from ex
qiskit.providers.exceptions.BackendPropertyError: 'Could not find the desired property for cx'

I'm uncertain if I'm overlooking something in my approach. I am using Python 3.10 and qiskit-terra 0.25.1. In the README, there is a mention of using the unitary synthesis plugin and considering a specific pull request in the installation process. Unfortunately, I'm unclear about which pull request I need to take into account.

Probably I've made an error in my setup or there's a step I've misunderstood.

Thank you kindly.

Haimrich commented 11 months ago

I solved by changing the backend, apparently FakePrague does not provide gate errors.

To prevent any future confusion, I'd suggest updating the example in the readme to use an alternative backend. This should be especially helpful if others run into a similar problem (if this isn't an isolated case that I encountered) 👍