Add QIntState, QUIntState; no attrs shenanigans #1860
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Code Review
This pull request introduces new bloqs for quantum constants (QIntState, QIntEffect, QUIntState, QUIntEffect) and refactors the X and Z basis states and effects to use abstract base classes. It also deprecates the legacy IntState and IntEffect in favor of the new QUInt implementations, and adds as_cirq_op to MeasureZ. Review feedback correctly identifies several inconsistencies in the refactoring of PlusEffect, MinusState, MinusEffect, OneState, and OneEffect, where the @frozen decorators were either missing or not updated to match the new class definitions, which could lead to issues with object comparison and initialization.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the qconst module, providing QIntState, QIntEffect, QUIntState, and QUIntEffect bloqs to represent quantum constants with specific data types, while deprecating the older IntState and IntEffect. Additionally, it refactors the _XVector and _ZVector base classes to use abc.ABCMeta for abstract properties. Feedback was provided to prevent runtime errors by checking for symbolic values during decomposition and to improve the inheritance structure of _XVector subclasses for better consistency and reduced redundancy.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
QIntState preceded the quantum data types, and is a bit of a misnomer as it generates an unsigned integer representation. With this PR, I've kept QIntState for backwards compatibility and added a PendingDeprecationWarning.
This PR adds QIntState and QUIntState with 1:1 mapping to their QDType. More such "quantum constants" can be added. Fixes #1165
I've also refactored the Zero/OneState/Effect bloq classes to avoid the strange attrs field overloading because it does not play nice with any metaprogramming one might want to do to e.g. extract fields from bloq classes.