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

[WIP] Add quantum phase-estimation simulator #7171

Closed
wants to merge 7 commits into from

Conversation

jlapeyre
Copy link
Contributor

@jlapeyre jlapeyre commented Oct 23, 2021

The simulator is implemented as a class that does not depend on qiskit together with a wrapper class that implements the PhaseEstimator interface. The class PESimulator depends only on numpy and scipy. In particular, it does not depend on Qiskit or circuits in general. The class PhaseEstimationSimulator is a subclass of PhaseEstimator providing an alternative to the circuit-based PhaseEstimation.

It is intended to be used for research and for testing. It is faster than simulating QPE with circuits and a state-vector simulator. It is much simpler, the core is only 20 lines or so, depending only on well-tested and widely used features of scipy. The rather ad-hoc tests of the QPE implementation in qiskit are augmented by comparing with the output of this simulator, which computes the probabilities of all bitstrings. It can also be used for researchers trying to debug code employing the circuit-based QPE classes.

I also have a tutorial-like text explaining the idea and math behind this simulator and the (parallel) QPE in qiskit. I'll post that somewhere after I convert it to a notebook. This does not spend time on the things in books, rather on a few important details that the books leave out when making a working implementation.

@jlapeyre jlapeyre changed the title [WIP] Add initial implementation of quantum phase-estimator simulator [WIP] Add initial implementation of quantum phase-estimation simulator Oct 23, 2021
@jlapeyre jlapeyre changed the title [WIP] Add initial implementation of quantum phase-estimation simulator [WIP] Add quantum phase-estimation simulator Oct 25, 2021
@woodsp-ibm
Copy link
Member

In some places we do have classical versions of algorithms that you can use on the same input for small problems to check out say the correctness of your input build out logic in that its creating a correct operator, or to use as a reference result. I guess though that this is not a drop in replacement in that regard since it does not implement the PhaseEstimator interface.

Had you thought about the textbook as a possible location for the code and text? Though you mention wanting to be able to use this too for correctness checking unit tests for too as a better? test for areas of the current phase estimation logic.

@jlapeyre
Copy link
Contributor Author

jlapeyre commented Oct 26, 2021

In some places we do have classical versions of algorithms ...

EDIT: These topics have been addressed in new commits and the PR description above has been edited accordingly.

Yes, this is exactly what I am thinking about. To be more clear: I think putting a wrapper around this that subclasses the existing interface is a good idea. And yes, I definitely want to use this as a much more thorough check of the PhaseEstimation implementation.

I did not get a chance to do it yet, but I will make an interface as described above and include it in this PR.

* This gives the simulator the same interface as the existing qiskit
classes
* Use the simulator in some tests
Compare simulator to circuit-based QPE in test suite.
@ajavadia
Copy link
Member

ajavadia commented Nov 2, 2021

Can you put a code example to show how I can put a phase estimation subcircuit into a larger circuit and simulate it by evolving gates where needed and using this for the phase estimation part?

If it is a drop-in replacement, I would call it PhaseEstimationEmulator, as in https://arxiv.org/pdf/1604.06460.pdf

@jlapeyre
Copy link
Contributor Author

jlapeyre commented Nov 3, 2021

According the ideas and nomenclature in that paper, yes, I think "emulator" is the right word. It's useful to have a word to distinguish if from, say, a state vector simulator.

... simulate it by evolving gates where needed and using this for the phase estimation part?

This is interesting. If it's possible, it would require a modification; I think it's worth looking in to. Currently, the emulator includes measurement. There are two registers, call them the phase-readout register and the eigensystem registers. Only the phase-readout register is measured, while the eigensystem register is ignored or traced out.
Look at the last section in these notes on implementing QPE
I think you are asking to prepare the state in eq (22) in this document. I said "traced out", but the emulator doesn't really trace anything out; it never uses the eigenvectors |u> in the first place.

@woodsp-ibm woodsp-ibm added the mod: algorithms Related to the Algorithms module label Jul 11, 2023
@woodsp-ibm
Copy link
Member

woodsp-ibm commented Jul 11, 2023

@jlapeyre Given algorithms are being moved out of Qiskit (see #10406) and this has not been worked on in some while - should it just be closed?

@woodsp-ibm
Copy link
Member

I am closing this based on algorithms being moved out and this is rather old now and would need fixing up. If its really wanted to can opened on the new repo for the algorithms.

@woodsp-ibm woodsp-ibm closed this Jul 12, 2023
@jlapeyre
Copy link
Contributor Author

Yes, better to open in the new repo if I have time to pick this up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: algorithms Related to the Algorithms module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants