Skip to content

pauli_sum_collector.estimate_energy() should return float when energy.imag == 0 #4313

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

Merged
merged 2 commits into from
Jul 14, 2021

Conversation

tanujkhattar
Copy link
Collaborator

For chemistry hamiltonians generated via openfermion.qubit_operator_to_pauli_sum(qubit_hamiltonian), even though the pauli sum has only real terms (complex with imag == 0), using p.estimated_energy() returns a complex (with imag == 0) and hence cannot be directly used with scipy optimizers which expect a flaot (eg: Nelder-Mead, SLSQP etc.)

See quantumlib/OpenFermion#732 for an example.

@tanujkhattar tanujkhattar requested review from cduck, vtomole and a team as code owners July 12, 2021 14:55
@tanujkhattar tanujkhattar requested a review from viathor July 12, 2021 14:55
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Jul 12, 2021
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we already decided we wanted to have this method return a Union[float, Complex] so I think this is just a simple bug fix to get to the intended behavior. LGTM.

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 14, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 14, 2021
@CirqBot CirqBot merged commit a3109a7 into quantumlib:master Jul 14, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jul 14, 2021
erichulburd pushed a commit to erichulburd/Cirq that referenced this pull request Jul 15, 2021
….imag == 0 (quantumlib#4313)

For chemistry hamiltonians generated via `openfermion.qubit_operator_to_pauli_sum(qubit_hamiltonian)`, even though the pauli sum has only real terms (complex with imag == 0), using `p.estimated_energy()` returns a complex (with imag  == 0) and hence cannot be directly used with scipy optimizers which expect a flaot (eg: `Nelder-Mead`, `SLSQP` etc.)

See quantumlib/OpenFermion#732 for an example.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
….imag == 0 (quantumlib#4313)

For chemistry hamiltonians generated via `openfermion.qubit_operator_to_pauli_sum(qubit_hamiltonian)`, even though the pauli sum has only real terms (complex with imag == 0), using `p.estimated_energy()` returns a complex (with imag  == 0) and hence cannot be directly used with scipy optimizers which expect a flaot (eg: `Nelder-Mead`, `SLSQP` etc.)

See quantumlib/OpenFermion#732 for an example.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
….imag == 0 (quantumlib#4313)

For chemistry hamiltonians generated via `openfermion.qubit_operator_to_pauli_sum(qubit_hamiltonian)`, even though the pauli sum has only real terms (complex with imag == 0), using `p.estimated_energy()` returns a complex (with imag  == 0) and hence cannot be directly used with scipy optimizers which expect a flaot (eg: `Nelder-Mead`, `SLSQP` etc.)

See quantumlib/OpenFermion#732 for an example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants