Kickoff the arithmetics library#4061
Merged
Merged
Conversation
* fixed value comparator (now integer comparator) * linear rotation (now linear Pauli rotations) * piecewise linear rotation (now piecewise linear pauli rotations) Co-authored-by: Stefan Woerner <wor@zurich.ibm.com>
Co-authored-by: Almudena Carrera Vazquez <acv@zurich.ibm.com>
ajavadia
reviewed
Apr 1, 2020
Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com> Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Stefan Woerner <wor@zurich.ibm.com> Co-authored-by: Manoel Marques <manoel@us.ibm.com> Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com>
…into library-arithmetic
ajavadia
reviewed
Apr 6, 2020
Member
ajavadia
left a comment
There was a problem hiding this comment.
This is looking good. I checked some parts in detail and others skimmed for now, most comments are about documentation. I'll have another look before merge.
| return self._num_state_qubits | ||
|
|
||
| @num_state_qubits.setter | ||
| def num_state_qubits(self, num_state_qubits: Optional[int]) -> None: |
Member
There was a problem hiding this comment.
why is the setter input optional?
Collaborator
Author
There was a problem hiding this comment.
So that the circuit can be "reset" by
circuit.num_state_qubits = None
Maybe an application checks of the number of qubits has been set or not, though I don't have a concrete example where this would be needed. Should I set it to not support None?
Member
There was a problem hiding this comment.
that's fine. i just see that in this PR some setters accept None and some don't, is that intentional?
Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
…into library-arithmetic
ajavadia
approved these changes
Apr 7, 2020
faisaldebouni
pushed a commit
to faisaldebouni/qiskit-terra
that referenced
this pull request
Aug 5, 2020
* add functional rotations base class * refactor first arithmetic circuits * fixed value comparator (now integer comparator) * linear rotation (now linear Pauli rotations) * piecewise linear rotation (now piecewise linear pauli rotations) Co-authored-by: Stefan Woerner <wor@zurich.ibm.com> * integrate polynomial rotations Co-authored-by: Almudena Carrera Vazquez <acv@zurich.ibm.com> * update inits * add tests * skip test depending on Aqua * fix imports: no weighted_adder, add functional_rot * move circ diag in parsed-literal block * adjust formatting of linear circ diag * update rendering of docstrings * move AND/OR gates from Aqua Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com> Co-authored-by: Manoel Marques <manoel@us.ibm.com> * use data getter not _data in copy * add missing gate inits * fix imports * fix lint * move WSO from aqua Co-authored-by: Stefan Woerner <wor@zurich.ibm.com> Co-authored-by: Manoel Marques <manoel@us.ibm.com> Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com> * rename to weighted adder * refactor weighted adder and make a circuit * updates inits with weighted adder * add tests for weighted adder * fix outdated mcu1 import * add functional pauli rotations import * Update test/python/circuit/test_library.py Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update qiskit/circuit/library/arithmetic/weighted_adder.py Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * add comment on default behaviour of the weights * fix rst rendering * include arithmetic circs in sphinx * fix copyright * add _invalidate() method Co-authored-by: Stefan Woerner <wor@zurich.ibm.com> Co-authored-by: Almudena Carrera Vazquez <acv@zurich.ibm.com> Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com> Co-authored-by: Manoel Marques <manoel@us.ibm.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Start the arithmetic part of the circuit library. These circuits have been part of Aqua and have been refactored to derive from a circuit and have blueprint-characteristics, i.e. can be lazily constructed and are mutable.
Details and comments
This PR kicks off the development of the arithmetics library. Once this logic moved here we can remove it from Aqua. The integrated classes are:
RY(f(x))|x>. Note that these can be used to approximate a mappingF|x> |0> -> .. + sqrt(f(x)) |x>|1>.For a modular design and extensibility, the
FunctionalPauliRotationsbase class has been introduced as base class for all functional Pauli rotations. This is probably also sensible in regard of transpiler passes and circuit optimization, since there exist simplification rules specially for the structures arising from functional rotations.The tests check both end-to-end results and the mutability of the objects. Ideally we would add a test, that checks that the objects do not break the code in Aqua, but I think this is not supported with the current travis setup (therefore the test is skipped).
Note
This requires the logical or gate from Aqua, which was added -- however this function is not yet properly converted to a
Gate.