2.7: Migrate swapup_linear_qubit, swapup_linear_register, swapup_linear to the modifier API

Aperta
#175 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@NathanCQC ci sta già lavorando.

Dal 11/11/2026.

  • #232 di @NathanCQC — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Goal

Migrate swap networks to the public control/dagger API. Target swapup_linear_qubit, swapup_linear_register, swapup_linear, including their existing inverse/controlled variants, nested generated circuits and affected callers.

Part of Functions: Control and dagger migration plan — item 2.7. Milestone: Modifier Refactor.

Dependencies

  • 1.6 — Swap and phase primitives: #166 (phase/cphase portion); swap work is in PR #138, which has no linked closing issue. Verify the swap capabilities needed here independently.

Plan dependency details: 1.6. Earlier-layer prerequisites must supply the capabilities this package uses. A linked issue or PR alone does not establish that its implementation is ready; check merged behavior and recorded blockers first.

Expected behavior

Callers use the forward public operation normally, with dagger for its adjoint, with control(external_controls) for additional controls, and both modifiers for controlled dagger wherever those capabilities are valid. Preserve natural signatures, register ownership, optimized decompositions and coherent relative phases.

Preserve swap-network direction, register positions and optimized decomposition. A dagger must reverse operation order, not simply repeat the same traversal.

Implementation guidance

Start by inspecting:

  • guppyalgos/primitives/subroutines/swap/swapup.py
  1. Read the repository instructions, related tests and examples. Search all target names across guppyalgos, tests, examples and docs; recheck paths and renamed APIs on the implementation branch.
  2. Inventory domains, variants, loops, measurements and callbacks. Prefer automatic modifier generation where supported. Preserve useful optimized kernels privately; supply validated custom paths where generation is unavailable.
  3. Reuse MultiCntrlFunction or MultiCntrlFunctionParams when appropriate, with an exact CNX kernel. Preserve and restore packed targets and borrowed controls. Avoid duplicated conjunction logic and dependency cycles.
  4. Migrate callers, imports/exports, callback annotations, factory return types, tests and documentation together. Replace explicit inverse/control variants with public modifiers where their contracts match; preserve meaningful operations and promised cleanup.

Acceptance criteria

  • All valid advertised public modes compile; unsupported compiler or semantic combinations have explicit recorded blockers.
  • Existing circuit behavior, relative phases, input domains and register ownership are preserved.
  • Affected callers and generated circuits use public modifiers, with no unintended private-kernel bypass or stale inverse/control alias.
  • Existing correctness coverage runs through the public API.
  • Small custom modifier paths use assert_unitary_modifiers with an independent expected unitary and its adjoint. Round trips alone are insufficient.
  • Custom control covers active, inactive and coherent branches with a single overall phase alignment; custom multi-control/packing paths have representative integration coverage and restore workspace.
  • Promised-input or measurement routines have specialized domain/coherence/cleanup tests where applicable.
  • Changes to gate count, depth or ancilla use are explained; unresolved contracts are documented.

Validation

Run uv run pytest <affected test paths> -q for the relevant modules and consumers, then prek. Execute affected notebooks sequentially and build documentation if changed. Record the exact commands and results in the PR.

Use existing shared testing helpers from public main. Do not duplicate compiler coverage for wholly generated modifiers or repeat the full adapter suite for every circuit. Public struct modifier migration and classical/container utilities remain outside this package, except for required circuit-caller updates.

Lingua principale
Python
Stelle
12
Fork
1
Merge medio
3g 1h
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Quantinuum/guppyalgos

Tutte le issue di Quantinuum/guppyalgos

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.