Addition call_graph inconsistent with decomposition for registers with unequal bitsizes

Open Beginner friendly
#1,818 2 comments 0 reactions 0 assignees View on GitHub

@rupasri118 is already working on this.

Since Sep 29, 2026.

  • #1986 by @Pyhroff — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
69/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python

Research direction

Read the Add decomposition and call graph in qualtran/bloqs/arithmetic/addition.py, especially the lines linked in the issue. Reproduce the mismatch with the provided unequal-bit-size example and compare the two T-complexity counts. Done when the call graph and decomposition report consistent counts for that case.

Written by the indexing model from the issue text.

Description

kind/bug-report

The number of cnots in the call graph for the Add bloq doesn't account for when a_bitsize < b_bitsize. In the decomposition, there is a cnot yielded conditioned on a_bitsize=b_bitsize
https://github.com/quantumlib/Qualtran/blob/9b1bacf8a2233538e6bfdfeb3abe7a780a50c0bb/qualtran/bloqs/arithmetic/addition.py#L192-L193
but the call graph always includes this gate in the count
https://github.com/quantumlib/Qualtran/blob/9b1bacf8a2233538e6bfdfeb3abe7a780a50c0bb/qualtran/bloqs/arithmetic/addition.py#L204
This results in different gate counts depending on what level of decomposition you count. For example

from qualtran.bloqs.arithmetic import Add
a_dtype = QUInt(2)
b_dtype = QUInt(3)
gate = Add(a_dtype=a_dtype,b_dtype=b_dtype)
gate.t_complexity() == gate.decompose_bloq().t_complexity()

returns False.

Dominant language
Python
Stars
397
Forks
127
Avg merge
2d 22h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quantumlib/Qualtran

All issues in quantumlib/Qualtran

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.