Skip to content

Commit

Permalink
Compiling observables
Browse files Browse the repository at this point in the history
Changes in lines: 657 and 663 of qiskit_device.py to apply the layout of the compiled circuits to the observables.
  • Loading branch information
felipelewyee authored Jan 14, 2025
1 parent 927bab3 commit 6a581cd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pennylane_qiskit/qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,13 @@ def _execute_estimator(self, circuit, session):

pauli_observables = [mp_to_pauli(mp, self.num_wires) for mp in circuit.measurements]
compiled_circuits = self.compile_circuits(qcirc)
compiled_observables = [op.apply_layout(compiled_circuits[0].layout) for op in pauli_observables]
estimator.options.update(**self._kwargs)
# split into one call per measurement
# could technically be more efficient if there are some observables where we ask
# for expectation value and variance on the same observable, but spending time on
# that right now feels excessive
circ_and_obs = [(compiled_circuits[0], pauli_observables)]
circ_and_obs = [(compiled_circuits[0], compiled_observables)]
result = estimator.run(
circ_and_obs,
precision=np.sqrt(1 / circuit.shots.total_shots) if circuit.shots else None,
Expand Down

0 comments on commit 6a581cd

Please sign in to comment.