Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AdaptVQE to new, stateless VQE #222

Merged
merged 3 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions qiskit_nature/algorithms/ground_state_solvers/adapt_vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ def _compute_gradients(
self._ansatz.operators = self._excitation_list + [exc]
# set the current ansatz
vqe.ansatz = self._ansatz
ansatz_params = vqe.ansatz._parameter_table.keys()
# construct the expectation operator of the VQE
vqe._expect_op = vqe.construct_expectation(ansatz_params, self._main_operator)
# evaluate energies
parameter_sets = theta + [-self._delta] + theta + [self._delta]
energy_results = vqe._energy_evaluation(np.asarray(parameter_sets))
energy_evaluation = vqe.get_energy_evaluation(self._main_operator)
energy_results = energy_evaluation(np.asarray(parameter_sets))
# compute gradient
gradient = (energy_results[0] - energy_results[1]) / (2 * self._delta)
res.append((np.abs(gradient), exc))
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/fix-adapt-vqe-c9df0c06ea352b91.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fix :class:`~qiskit_nature.algorithms.AdaptVQE` after the update of
:class:`~qiskit.algorithms.VQE` which deleted the internal ``_energy_evaluation``
method that Adapt-VQE was relying on.