4.2: Migrate cnx_ladder_logdepth to the modifier API

Open
#191 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@GBoydQ is already working on this.

Since Nov 11, 2026.

Assessment

This issue has not been assessed yet.

Description

Goal

Migrate log-depth cnx ladder to the public control/dagger API. Target cnx_ladder_logdepth, including their existing inverse/controlled variants, nested generated circuits and affected callers.

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

Dependencies

  • 1.7 — Ladder primitives: migration plan item 1.7 (no dedicated issue identified)
  • 3.2 — CNX helpers and CCA implementations: #181

Plan dependency details: 1.7, 3.2. 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 log-depth ladder structure, index bounds and workspace restoration. Check small-width boundaries and existing multi-control regressions.

Implementation guidance

Start by inspecting:

  • guppyalgos/primitives/subroutines/ladders/cnx_ladder.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.

Dominant language
Python
Stars
12
Forks
1
Avg merge
3d 1h
Merged PRs (30d)
19

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 Quantinuum/guppyalgos

All issues in Quantinuum/guppyalgos

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.