Skip to content

.qcall() method for automatic deduction of parameters, helper BloqBuilder methods#1862

Merged
mpharrigan merged 26 commits into
quantumlib:mainfrom
mpharrigan:2026-05/qcall
May 20, 2026
Merged

.qcall() method for automatic deduction of parameters, helper BloqBuilder methods#1862
mpharrigan merged 26 commits into
quantumlib:mainfrom
mpharrigan:2026-05/qcall

Conversation

@mpharrigan
Copy link
Copy Markdown
Collaborator

@mpharrigan mpharrigan commented May 20, 2026

  • qcall class method on basic_gates/ and some arithmetic/ bloqs
  • BloqBuilder.CNOT and other shorthands
  • documentation on how to write your own qcall method

part of #1741

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 qcall pattern to Qualtran, providing a more concise and functional syntax for composing bloqs using QVar objects. The changes include comprehensive documentation for the pattern, operator overloading for QVar (supporting ~, +, and +=), and the implementation of qcall classmethods across a wide range of arithmetic and basic gate bloqs. Additionally, BloqBuilder was updated with helper methods to facilitate these calls. The review feedback identifies a recurring issue across several qcall implementations where the code fails to account for multi-qubit registers represented as numpy arrays, which would lead to AttributeError when attempting to access .bb or .dtype properties directly.

Comment thread qualtran/bloqs/arithmetic/addition.py
Comment thread qualtran/bloqs/basic_gates/identity.py
Comment thread qualtran/bloqs/basic_gates/on_each.py Outdated
Comment thread qualtran/bloqs/basic_gates/rotation.py Outdated
Comment thread qualtran/bloqs/basic_gates/swap.py
@mpharrigan
Copy link
Copy Markdown
Collaborator Author

the code fails to account for multi-qubit registers represented as numpy arrays

The annotations are correct. If the code fails, it's because you're not supposed to put a numpy array there

@mpharrigan mpharrigan merged commit 34be274 into quantumlib:main May 20, 2026
15 of 16 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.

1 participant