Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator #715

Merged
merged 8 commits into from
Nov 1, 2019

Conversation

chriseclectic
Copy link
Contributor

Summary

Using snapshots for weighted Pauli operator expection values should be done using the qasm simulator instead of the statevector simulator if the final statevector isn't required, as the later has the overhead of deserializing and returning the final state.

Details and comments

This is WIP with a couple of questions (probably for @chunfuchen)

  • This replaces the old qobj-hack for snapshot with the new instructions for them.
  • Question: was the only place this hack was used in VQE or were there other spots?
  • There should be an option to still do the measurement based VQE simulation on the qasm simulator for mimicing an experiment (especially with noise or noisy measurement).
  • Question: is it possible to add an option flag to force decomposition of Pauli op into measurement circuits (not using snapshot).

With regards to the last point this could be enabled by default if noise model has readout or measure errors. Technically it should be enabled if single-qubit Pauli gates have errors too, but maybe we want to allow relaxing that since it will lead to a large huge increase in simulator efficiency (the snapshot is always computed "ideal").

@woodsp-ibm woodsp-ibm requested a review from chunfuchen October 23, 2019 14:58
@yaelbh
Copy link
Contributor

yaelbh commented Oct 24, 2019

I identify at least eight options:

  • Qasm / statevector.
  • Snapshot / measurement circuit.
  • Ideal / noise (can also be noise which not related to the final Pauli evaluation, e.g. on some gate inside the circuit).

In particular I'm wondering about the required number of shots for each option.

  • In the option statevector-snapshot-ideal, there is only one shot (as far as I know Aer identifies this and performs a single shot even if the number of shots in the input is larger).
  • qasm-snapshot-ideal: one shot is enough (I guess that Aer identifies this too?). What it does is essentially equivalent to statevector-snapshot-ideal.
  • statevector-measurement: not a valid option in our context.
  • qasm-measurement: requires many shots.
  • statevector-snapshot-noise: not a valid option in our context.
  • qasm-snapshot-noise: requires many shots. What it does is essentially equivalent to qasm-measurement-noise.

Is this correct?

@chriseclectic
Copy link
Contributor Author

@yaelbh yep ideal qasm simulator with snapshot and no measurement will only simulate 1 shot regardless of what is passed in. With regards to noise: qasm-noise-snapshot and qasm-noise measurement would be different in the sense that snapshot is many shots of 1 circuit, while qasm-noise-measurement is many shots of many circuits (using decomposition of operator into measure circuits).

One key point though is I would discourage ever using the statevector simulator (unless for some reason Aer is unavailable and you are stuck using BasicAer). The only reason for using the statevector simulator in the past was before we had implemented the snapshot instructions as the expectation value was computed from the returned statevector.

@chunfuchen
Copy link
Contributor

@chriseclectic Thanks for the contribution.
Here are my comments:

  1. Since the Aer snapshot instruction can take the Pauli object directly, there is no need to keep aer_paulis property there.
  2. For the simulation, we could four combinations:
    1. w/o sampling noise (sampling) & w/o hardware noise => ideal simulation
    2. w/ sampling noise (sampling) & w/o hardware noise => need decompose Hamiltonian into Pauli basis.
    3. w/o sampling noise (sampling) & w/ hardware noise => ??
    4. w/ sampling noise (sampling) & w hardware noise => the more realistic simulation to the hardware.

For now, I think it is reasonable to only support 1, 2 and 4 for now, we can extend it later.
Thus, here comes how to let VQE know which mode it should run when using QasmSimulator from the Aer provider.
I think each case could corresponding the following setting in the QuantumInstance class.

  • 1: QasmSimulator with shots = 1
  • 2: QasmSimulator with shots > 1
  • 4: QasmSimulator wiht shots > 1 and setup noise model as well.

In this case, you need to update the logic to determine whether or not to use expectation snapshot in the vqe.py.

@chriseclectic chriseclectic changed the title [WIP] Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator Oct 29, 2019
@chriseclectic
Copy link
Contributor Author

@chunfuchen I made changes to enable snapshot mode for the qasm simulator only when shots=1 and there is no noise model in the quantum instance.

@woodsp-ibm woodsp-ibm merged commit 84c067f into qiskit-community:master Nov 1, 2019
mtreinish pushed a commit to mtreinish/qiskit-core that referenced this pull request Nov 20, 2020
…c/fix/vqe-snapshot

Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator
manoelmarques pushed a commit to manoelmarques/qiskit-terra that referenced this pull request Nov 23, 2020
…c/fix/vqe-snapshot

Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator
manoelmarques pushed a commit to manoelmarques/qiskit-terra that referenced this pull request Dec 2, 2020
…c/fix/vqe-snapshot

Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator
manoelmarques pushed a commit to manoelmarques/qiskit-terra that referenced this pull request Dec 7, 2020
…c/fix/vqe-snapshot

Enable Pauli operator snapshot mode for VQE on Aer QasmSimulator
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants