Make MultiCntrlFunction daggerable using struct modifiers
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reading MultiCntrlFunction and MultiCntrlFunctionParams, then trace the _swap_forward and _swap_inverse adapters in SwapUp and inspect existing kernels that use measurement or randomness. The issue’s Guppy 1.2.4 Composer prototype shows the desired struct modifiers and generic Unitary callbacks. Done when daggering can reuse the forward operation while preserving predicate behavior, kernel workspace cleanup, and existing callback use cases.
Written by the indexing model from the issue text.
Description
SwapUp currently needs separate _swap_forward and _swap_inverse adapters because MultiCntrlFunction stores opaque Function callbacks. We should be able to reuse the forward operation:
operation = MultiCntrlFunction(controlled_swapup, cnx_kernel)
with dagger:
operation.compose(controls, regs)
Update MultiCntrlFunction and MultiCntrlFunctionParams to retain both callbacks as generic types bounded by Unitary, with struct modifiers on compose.
This prototype works on Guppy 1.2.4:
from guppylang import guppy
from guppylang.std.builtins import Unitary, array, dagger, nat
from guppylang.std.quantum import discard, qubit
@guppy.struct
class Composer[
m: nat,
Regs,
Op: Unitary[[qubit, Regs], None],
Kernel: Unitary[[array[qubit, m], qubit], None],
]:
operation: Op
kernel: Kernel
@guppy.unitary
class compose:
@guppy
def __call__(
self, controls: array[qubit, m], targets: Regs
) -> None:
if m == 1:
self.operation(controls[0], targets)
else:
work = qubit()
self.kernel(controls, work)
self.operation(work, targets)
with dagger:
self.kernel(controls, work)
discard(work)
@guppy
def daggered(
self, controls: array[qubit, m], targets: Regs
) -> None:
if m == 1:
with dagger:
self.operation(controls[0], targets)
else:
work = qubit()
self.kernel(controls, work)
with dagger:
self.operation(work, targets)
with dagger:
self.kernel(controls, work)
discard(work)
The operation must preserve its predicate and act as identity when it is zero. The kernel must preserve the controls, compute their AND into a clean target, and restore internal workspace.
Migration needs care: both callbacks must be statically known, while explicit generic specialization currently produces opaque function pointers. Some existing kernels also use measurement or randomness; preserve those use cases or provide a compatible alternative.
- 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
-
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
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Quantinuum/guppyalgos#211 ·
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