Skip to content

Commit

Permalink
Stateless VQE (Qiskit/qiskit#6418)
Browse files Browse the repository at this point in the history
* make VQE stateless

TODO deprecation

* fix get initial point from ansatz

* try fixing use of deprecate_function

* fix tests & black

* deprecate varalgo methods

* sort params per circuit default

* clarify deprecation message in varalgo.initialpoint

* initialize eval_count with 0 instead of None

it doesn't really matter, having it None was more a safeguard, but adaptVQE breaks if this is None and not 0

* simplify get_eigenstate

* fix lint

* remote note on parameter order

* review suggestions

* deprecate sort_parameters_by_name
* check ansatz has 0 params in setter
* rename varform -> ansatz

* fix tests

* lint

* keep previous behaviour of expectation

meaning that if a user didn't set it, we re-construct the expectation for each new run of VQE

* move expectation factory to right place

* address Qiskit/qiskit#5746

* fix typehint in expectation (add Optional)

* fix expectation setter

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Cryoris and mergify[bot] authored Jun 17, 2021
1 parent 756ad7f commit cdc5d3f
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 230 deletions.
4 changes: 1 addition & 3 deletions qiskit_algorithms/minimum_eigen_solvers/qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@ def __init__(
quantum_instance=quantum_instance,
)

def _check_operator(self, operator: OperatorBase) -> OperatorBase:
def _check_operator_ansatz(self, operator: OperatorBase) -> OperatorBase:
# Recreates a circuit based on operator parameter.
if operator.num_qubits != self.ansatz.num_qubits:
self.ansatz = QAOAAnsatz(
operator, self._reps, initial_state=self._initial_state, mixer_operator=self._mixer
)
operator = super()._check_operator(operator)
return operator

@property
def initial_state(self) -> Optional[QuantumCircuit]:
Expand Down
Loading

0 comments on commit cdc5d3f

Please sign in to comment.