Skip to content

Add QIntState, QUIntState; no attrs shenanigans #1860

Merged
mpharrigan merged 10 commits into
quantumlib:mainfrom
mpharrigan:2026-05/intstate
May 20, 2026
Merged

Add QIntState, QUIntState; no attrs shenanigans #1860
mpharrigan merged 10 commits into
quantumlib:mainfrom
mpharrigan:2026-05/intstate

Conversation

@mpharrigan
Copy link
Copy Markdown
Collaborator

@mpharrigan mpharrigan commented May 18, 2026

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.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread qualtran/bloqs/basic_gates/x_basis.py Outdated
Comment thread qualtran/bloqs/basic_gates/x_basis.py Outdated
Comment thread qualtran/bloqs/basic_gates/x_basis.py Outdated
Comment thread qualtran/bloqs/basic_gates/z_basis.py
Comment thread qualtran/bloqs/basic_gates/z_basis.py
@mpharrigan
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread qualtran/bloqs/basic_gates/qconst.py Outdated
Comment thread qualtran/bloqs/basic_gates/x_basis.py Outdated
Comment thread qualtran/bloqs/basic_gates/x_basis.py Outdated
mpharrigan and others added 4 commits May 18, 2026 16:58
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mpharrigan mpharrigan merged commit 177dd8e into quantumlib:main May 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IntState, IntEffect do not support signed ints

1 participant