-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fidelity interface using primitives #8303
Conversation
Fidelity primitive POC
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 2981696422
💛 - Coveralls |
Co-authored-by: Julien Gacon <[email protected]>
Co-authored-by: Julien Gacon <[email protected]>
36e59bf
to
282c301
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks reasonable.
Co-authored-by: dlasecki <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Let's see if the docs build passes.... I'll also hold off automerge in case @woodsp-ibm or anybody else wants to have another look!
releasenotes/notes/add-fidelity-interface-primitives-dc543d079ecaa8dd.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Steve Wood <[email protected]>
Co-authored-by: Steve Wood <[email protected]>
Co-authored-by: Steve Wood <[email protected]>
…ecaa8dd.yaml Co-authored-by: Steve Wood <[email protected]>
Co-authored-by: Steve Wood <[email protected]>
Co-authored-by: Steve Wood <[email protected]>
Thank you for checking the docs, @woodsp-ibm! I applied all of your suggestions. |
fidelities=fidelities, | ||
raw_fidelities=raw_fidelities, | ||
metadata=result.metadata, | ||
run_options=run_opts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a comment. In gradients, in the result run_options there it says of run_options
run_options for the estimator. Currently, estimator's default run_options is not included.
which is the case here right. So these end up being the options we give to sampler.run() which may then augment them with it own default option.s If run_options were part of Sampler ( and Estimator) result then like metadata it could be result.run_options. But until such time that this happens, its just perhaps something to bear in mind.
Co-authored-by: Steve Wood <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for all the effort and patience @ElePT 😁
Seconded! |
* fidelity_poc * init stuff * simplified design * unittests * unittest working * optional parameters * typo * documentation * Update test/python/primitives/fidelity/test_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Update qiskit/primitives/fidelity/base_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * black * import order in test fixed * docstring fixed * Update qiskit/primitives/fidelity/base_fidelity.py Co-authored-by: dlasecki <[email protected]> * context removed * Reset branch * Add init * Fix inits * lint fixes * removed abstractmethod label for set_circuits * added support for setting only one circuit * new unittest * Move fidelities to algorithms * Update interface with new design doc * Fix docstrings and unit tests * Add evaluate * Adapt signature run * Make job async * Fix types * Remove async, cache circuits * Update evaluate method, replace use of np * Remove circuits from init * Add async, tests, update docstrings * Add default run options * change names, abstract methods, improve docstrings * Update docstrings, typing * Fix style * Update qiskit/algorithms/fidelities/base_fidelity.py Co-authored-by: Declan Millar <[email protected]> * Update qiskit/algorithms/fidelities/base_fidelity.py Co-authored-by: Declan Millar <[email protected]> * Make async * Add FidelityResult * Update qiskit/algorithms/fidelities/__init__.py Co-authored-by: Steve Wood <[email protected]> * Add to algorithms init * Rename classes * Apply review comments * Update preprocessing * Update docstrings * Move run to base class * Remove left/right params * Apply reviews steve/julien/hamamura * Fix typo * Style changes * Allow different num.params in circuit 1 and 2 * Fix unittest typo * Fix black * Fix docs * Fix style/docstrings * Add AlgorithmJob * Add truncate, fix result docstring * Completely remove left-right * Add comments * Make create circuit public * Remove empty param distinction * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Takashi Imamichi <[email protected]> * change list preprocessing * Update qiskit/algorithms/algorithm_job.py Co-authored-by: Ikko Hamamura <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Apply comments Steve * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Update test/python/algorithms/state_fidelities/test_compute_uncompute.py Co-authored-by: Julien Gacon <[email protected]> * Style changes * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Apply comments Julien * Style fix * Fix bug for lists of numpy values * Support single circuits * Support single circuits * Add fidelity interface using primitives * Apply reviews * Fix docs * Fix docs * Fix docs * Fix lint * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/compute_uncompute.py Co-authored-by: Steve Wood <[email protected]> * Update releasenotes/notes/add-fidelity-interface-primitives-dc543d079ecaa8dd.yaml Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/__init__.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Gian Gentinetta <[email protected]> Co-authored-by: Gian Gentinetta <[email protected]> Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: dlasecki <[email protected]> Co-authored-by: Declan Millar <[email protected]> Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Takashi Imamichi <[email protected]> Co-authored-by: Ikko Hamamura <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* fidelity_poc * init stuff * simplified design * unittests * unittest working * optional parameters * typo * documentation * Update test/python/primitives/fidelity/test_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Update qiskit/primitives/fidelity/base_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * black * import order in test fixed * docstring fixed * Update qiskit/primitives/fidelity/base_fidelity.py Co-authored-by: dlasecki <[email protected]> * context removed * Reset branch * Add init * Fix inits * lint fixes * removed abstractmethod label for set_circuits * added support for setting only one circuit * new unittest * Move fidelities to algorithms * Update interface with new design doc * Fix docstrings and unit tests * Add evaluate * Adapt signature run * Make job async * Fix types * Remove async, cache circuits * Update evaluate method, replace use of np * Remove circuits from init * Add async, tests, update docstrings * Add default run options * change names, abstract methods, improve docstrings * Update docstrings, typing * Fix style * Update qiskit/algorithms/fidelities/base_fidelity.py Co-authored-by: Declan Millar <[email protected]> * Update qiskit/algorithms/fidelities/base_fidelity.py Co-authored-by: Declan Millar <[email protected]> * Make async * Add FidelityResult * Update qiskit/algorithms/fidelities/__init__.py Co-authored-by: Steve Wood <[email protected]> * Add to algorithms init * Rename classes * Apply review comments * Update preprocessing * Update docstrings * Move run to base class * Remove left/right params * Apply reviews steve/julien/hamamura * Fix typo * Style changes * Allow different num.params in circuit 1 and 2 * Fix unittest typo * Fix black * Fix docs * Fix style/docstrings * Add AlgorithmJob * Add truncate, fix result docstring * Completely remove left-right * Add comments * Make create circuit public * Remove empty param distinction * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Takashi Imamichi <[email protected]> * change list preprocessing * Update qiskit/algorithms/algorithm_job.py Co-authored-by: Ikko Hamamura <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Apply comments Steve * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Update test/python/algorithms/state_fidelities/test_compute_uncompute.py Co-authored-by: Julien Gacon <[email protected]> * Style changes * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Julien Gacon <[email protected]> * Apply comments Julien * Style fix * Fix bug for lists of numpy values * Support single circuits * Support single circuits * Add fidelity interface using primitives * Apply reviews * Fix docs * Fix docs * Fix docs * Fix lint * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/compute_uncompute.py Co-authored-by: Steve Wood <[email protected]> * Update releasenotes/notes/add-fidelity-interface-primitives-dc543d079ecaa8dd.yaml Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/__init__.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> * Update qiskit/algorithms/state_fidelities/base_state_fidelity.py Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Gian Gentinetta <[email protected]> Co-authored-by: Gian Gentinetta <[email protected]> Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: dlasecki <[email protected]> Co-authored-by: Declan Millar <[email protected]> Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Takashi Imamichi <[email protected]> Co-authored-by: Ikko Hamamura <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
We propose the addition of a series of primitive-based
Fidelity
interfaces that will become a fundamental building block for primitive-based algorithms: VQD, PVQD, QNSPSA optimizers and quantum kernels.This PR contains a proposal for
BaseStateFidelity
and theComputerUncompute
method interface that is used in the refactored quantum kernel class (currently WIP, see design doc and PR). Other methods for calculating state overlaps/ fidelities could be added in the future (i.e. Swap tests, Hadamard tests...).Details and comments
This PR closes #6876 and #8493.
Update (August 31)
The current implementation follows the design of the new primitive interface, with a
run
method that returns anAlgorithmJob
that is non-blocking. TheAlgorithmJob
class has been introduced for typing purposes, but in the future it might be modified to include additional/different functionality toPrimitiveJob
.