Skip to content

Commit

Permalink
Added missing had_transpiled=True to quantum_kernel (#247)
Browse files Browse the repository at this point in the history
* Added missing had_transpiled=True

* added missing reno file

* add missing words

* fix typo
  • Loading branch information
cnktysz authored Oct 20, 2021
1 parent 9c7e313 commit 7f7bde7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .pylintdict
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ traceback
transpilation
transpile
transpiled
transpiler
transpiles
uncompiled
transpiling
unitaries
Expand Down
4 changes: 2 additions & 2 deletions qiskit_machine_learning/kernels/quantum_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def evaluate(self, x_vec: np.ndarray, y_vec: np.ndarray = None) -> np.ndarray:
parameterized_circuit.assign_parameters({feature_map_params: x})
for x in to_be_computed_data[min_idx:max_idx]
]
results = self._quantum_instance.execute(circuits)
results = self._quantum_instance.execute(circuits, had_transpiled=True)
for j in range(max_idx - min_idx):
statevectors.append(results.get_statevector(j))

Expand Down Expand Up @@ -473,7 +473,7 @@ def evaluate(self, x_vec: np.ndarray, y_vec: np.ndarray = None) -> np.ndarray:
for x, y in to_be_computed_data_pair
]

results = self._quantum_instance.execute(circuits)
results = self._quantum_instance.execute(circuits, had_transpiled=True)

matrix_elements = [
self._compute_overlap(circuit, results, is_statevector_sim, measurement_basis)
Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/qsvm-transpiler-fix-13ab6b22a837d2b5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
features:
- |
``QuantumKernel`` transpiles all circuits before execution. However, this
information was not being passed, which calls the transpiler many times
during the execution of the ``QSVC/QSVR`` algorithm. Now, ``had_transpiled=True``
is passed correctly and the algorithm runs faster.

0 comments on commit 7f7bde7

Please sign in to comment.