Skip to content

[WIP] Upgrade TemporaryAND to handle multiple control wires#9357

Draft
Qottmann wants to merge 3 commits intomainfrom
mutlielbow
Draft

[WIP] Upgrade TemporaryAND to handle multiple control wires#9357
Qottmann wants to merge 3 commits intomainfrom
mutlielbow

Conversation

@Qottmann
Copy link
Copy Markdown
Contributor

Context:

Just exploring an idea here. This has not been approved or discussed with product yet, as I am not even sure myself, if this is the best solution.

We often need to decompose control structure into multiple TemporaryAND (A TemporaryAND ladder if you will). It makes sense to extend TemporaryAND to have multiple control wires + work wires.

Description of the Change:

Extending TemporaryAND to multiple wires, adding an efficient decomposition when work wires are provided.

Benefits:

Efficient decomposition and this subroutine appears in almost all arithmetic operations (essentially, whenever there is multi-control). Unifying this into a single op that can be used in multiple places heavily reduces maintence burden and also ensures we use the best possible decomposition of multi-controlled ops everywhere in pennylane.

Further enables an efficient decomposition of C(Prod) (follow-up)

Possible Drawbacks:

The current implementation does not work yet (WIP)

Drawback from going to ControlledOp -> control_values are not jittable (this is, however, resolved elsewhere). The only reason TemporaryAND had jittable control_values was because they were manualy inserted despite the operator not being a ControlledOp.

The current version is not introducing breaking changes.

Related GitHub Issues:

@Qottmann Qottmann added the do not merge ⚠️ Do not merge the pull request until this label is removed label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge ⚠️ Do not merge the pull request until this label is removed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant