Arithmetic cleanup and protocol-based interfaces
Maintainers usually reply within 2 days
@ChiaraLeadbeater is already working on this.
Since Oct 8, 2026.
Assessment
This issue has not been assessed yet.
Description
Arithmetic is becoming cluttered as implementations and operation variants accumulate. This epic tracks a cleanup that introduces shared protocols, making arithmetic primitives easier to maintain, compose, and swap within higher-level algorithms.
A possible starting point is an Adder protocol exposing add and add_with_carry:
@guppy.protocol
class Adder:
@guppy.require(unitary=True)
def add[n: nat](
self,
a: array[qubit, n],
b: array[qubit, n],
) -> None: ...
@guppy.require(unitary=True)
def add_with_carry[n: nat](
self,
a: array[qubit, n],
b: array[qubit, n],
carry: qubit,
) -> None: ...
This is a suggestion; the exact interfaces and capability requirements should be explored before committing to a design.
Scope:
- Establish consistent arithmetic interfaces and operation semantics.
- Separate shared interfaces from implementation-specific details.
- Allow consuming algorithms to select compatible arithmetic implementations.
- Simplify module organization and reduce duplication.
Coordination with Guppy:
This work needs to be carried out very carefully in conjunction with the struct rewrite and support for custom dagger, control, and controlled-dagger modifiers coming in Guppy v1.2.x. Protocol design and implementation migration should be coordinated with that work, checking how each modifier interacts with protocol methods and structs before consolidating existing operation variants. The proposed interface should remain provisional until those interactions are understood.
Suggested sub-issues and nested sub-issues:
- Design arithmetic protocols
- Prototype an
Adderprotocol. - Determine how controlled, inverse, and unitary capabilities should be represented.
- Validate the design against the Guppy v1.2.x struct rewrite and custom dagger, control, and controlled-dagger modifiers.
- Prototype an
- Migrate addition and subtraction
- Adapt Cuccaro and Gidney adders.
- Integrate subtraction with the shared interfaces.
- Extend to other arithmetic primitives
- Assess protocols for incrementers and comparators.
- Refactor multiplication and exponentiation to consume shared interfaces.
This epic should be delivered incrementally through linked sub-issues, with nested sub-issues for implementation-specific work. The breakdown can evolve as the protocol design is explored.
- Dominant language
- Python
- Stars
- 12
- Forks
- 1
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Quantinuum/guppyalgos
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Quantinuum/guppyalgos#233 ·
Maintainers usually reply within 2 days
-
Add lint rules for importsPossibly taken @Walden-Killick claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Quantinuum/guppyalgos#224 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Quantinuum/guppyalgos#239 · 1 comment ·
Maintainers usually reply within 2 days
-
Add unitary modifiers to `Ladder` protocol and implementorsPossibly taken @GBoydQ claimed this 4 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
Quantinuum/guppyalgos#237 ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 Half a day Newbie friendliness 35/100
Quantinuum/guppyalgos#223 ·
Maintainers usually reply within 2 days
All issues in Quantinuum/guppyalgos
Similar issues
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug data-types native-format
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ClickHouse/clickhouse-connect#1320 ·
Maintainers usually reply within 1 day
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
future-agi/future-agi#6392 ·
Maintainers usually reply within 1 day