Iterative phase estimation
Design document · Original source
RFCs record designs and changes. A proposal appearing here does not mean its feature is ready to use. Explore current language support
Status recorded in the original: Proposed
Bound original source · SHA-25610faa686a7e0701a141d267ed4c67fcfe907e87b146074bb5f682ada00b1fc13
Status: proposed Revision: 1 (2026-08-11) Feature flag: experimental.iterativePhaseEstimation=true Depends on: NM-RFC-0002 exact-version imports, NM-RFC-0011 measurement-conditioned control, NM-RFC-0015 generalized circuit signatures Implementation gate: the section 12 review record is mandatory before implementation Does not change: generic QPE status, the five-qubit statevector ceiling, ctrl limits, pow expansion limits, or hardware claims
1. Purpose
Algorithm Pack 0.2 includes a fixed two-counting-qubit phase-estimation lesson. NM-RFC-0010 correctly excludes generic QPE: expanding pow(2^k) @ U repeats a circuit exponentially and does not model the direct controlled powers that make phase estimation useful.
Iterative phase estimation (IPE) is a different bounded product. It reuses one control qubit, measures it after every round, resets it, and applies a classical phase correction before the next round. This matches the narrow feed-forward model of NM-RFC-0011, but only if direct controlled powers, bit order, phase convention, resource budgets, and eigenstate preconditions are frozen.
Revision 1 defines that boundary. It creates no parser rule, runtime path, capability entry, standard-library export, provider adapter, or UI control.
2. Mathematical convention
For a normalized target eigenstate |psi> and named unitary U:
U |psi> = exp(2 * PI * i * phi) |psi>
0 <= phi < 1The requested precision P produces the binary fraction 0.b1 b2 ... bP. The report stores bits most-significant first and estimates:
phi_hat = sum(b_k / 2^k), k = 1..P
interval width = 1 / 2^PPhase distance is circular: min(|a-b|, 1-|a-b|). A fixture whose exact phase lies on a binary boundary must declare the accepted adjacent representation; floating-point equality is never inferred.
The algorithm does not prove that an arbitrary input is an eigenstate. An exact-version package must bind a named eigenstate-preparation circuit and the direct controlled-power family. General input states yield sampled mixture behavior and are outside the first ready range.
3. No Unitary<N> type
This RFC does not introduce a Unitary<N> value type. A phase source is one exact-version package manifest, nm-ipe-phase-source@0.1, that binds:
- package specifier and source digest;
- target width
N; - named eigenstate-preparation export;
Pnamed or const-specialized direct controlled-power exports;- gate-set and target compatibility;
- controlled-form availability for every operation in every power;
- concrete gate/depth/two-qubit counts for each specialization; and
- review and verifier identities.
Each power export must directly implement controlled U^(2^k) for its stated round. The compiler must not synthesize it by repeating U 2^k times. A manifest that contains only U plus a requested pow modifier is rejected.
All circuit exports are statically named or exact-version package exports. Runtime circuit values, closures, callbacks, or network-loaded bodies are not allowed.
4. Bounded IPE plan
nm-ipe-plan@0.1 is the execution input:
{
"format": "nm-ipe-plan",
"version": "0.1",
"phaseSource": "package.example@1.4.0::phase_source",
"targetWidth": 1,
"precisionBits": 3,
"seed": 29,
"backend": "browser-statevector"
}Rules:
NandPare compile-time constants bound by the manifest;- revision 1 planning bounds are
1 <= N <= 4and1 <= P <= 8; - an executable ready range may be narrower and must satisfy
N + 1 <=the separately published statevector ceiling; - the one control qubit is disjoint from the target register;
- the seed is mandatory because each round measures a non-deterministic bit;
- noise, mitigation, QPU targets, provider fallback, and unbounded retries are rejected; and
- requested/effective backend and all resource totals are recorded.
The planning bounds are parser/allocation limits, not a ready-range claim.
5. Round semantics
Round order is most-significant bit to least-significant bit. For round k:
- the reusable control qubit is verified to be
|0>; Hprepares|+>;- the manifest-bound direct controlled power for the round is applied;
- the phase correction derived only from previously measured bits is applied;
His applied;- the control is measured in Z and the bit is appended in canonical order;
- the control is reset before the next round.
Measurement and reset are legal here because this is an algorithm, not an oracle body. The classical correction must be expressible in the accepted NM-RFC-0011 predicate/value subset and must not inspect a future bit.
Randomness consumption follows NM-RFC-0011 exactly. A deterministic measurement consumes no draw; a non-deterministic measurement consumes one. Rerunning the same source, package, plan, backend, and seed must reproduce the bit sequence.
6. Resource model
Resource accounting is performed before execution and includes:
- eigenstate preparation;
- every direct controlled-power specialization;
PHadamard pairs, corrections, measurements, and resets;- target-native lowering and routing when selected; and
- the maximum live width
N + 1 + Aincluding declared ancillas.
The existing expanded-gate, depth, two-qubit, and output budgets apply. Direct power construction avoids exponential source repetition but does not exempt a large specialized circuit from budgets. No general multi-control synthesis is added; each controlled power must stay within the accepted gate set or fail closed.
7. Verification and run artifact
nm-ipe-run@0.1 records:
- exact plan and phase-source identity;
- target/precision constants;
- ordered round bits and per-round measurement probabilities;
- correction angle used at each round;
- requested and effective backend;
- per-round and aggregate resources;
- estimated phase and canonical interval;
- seeded runtime provenance; and
- integrity metadata.
For retained conformance fixtures only, an independent exact phase may be included in a separate verifier input. The report then stores circular error and whether it lies inside the declared precision interval. Production runs do not invent an exact phase when none is independently known.
The first verification tier is numerical and bounded: prepare the declared eigenstate, apply each direct power, and verify the expected eigenphase action within a frozen tolerance on the approved statevector range. Syntax inspection alone is early diagnosis, not proof.
8. Ready range
Revision 1 publishes no executable range. The first implementation must show at least:
N = 1, P = 3for an exactly representable phase;N = 1, P = 3for a non-exact phase with the correct interval semantics;N = 2, P = 3if the package advertises two-target-qubit support;- deterministic seeded replay and independent numeric verification; and
- fail-closed rejection of repeated-
pow, missing controlled powers, stale package digests, and resource overflow.
If only N = 1, P <= 3 is proven, that is the published range. A wider parsing bound must never be presented as execution readiness.
9. Diagnostics
| Code | Meaning |
|---|---|
NM-IPE-001 | feature not explicitly negotiated |
NM-IPE-002 | target width, precision, seed, or backend is invalid |
NM-IPE-003 | phase-source package or exact digest binding differs |
NM-IPE-004 | a direct controlled-power export is absent or unsupported |
NM-IPE-005 | repeated pow expansion was requested instead of a direct power |
NM-IPE-006 | width, gate, depth, or two-qubit budget is exceeded |
NM-IPE-007 | round order, reset state, or feed-forward dependency is invalid |
NM-IPE-008 | numerical eigenphase verification fails |
NM-IPE-009 | run artifact or recomputation digest differs |
10. Security and failure behavior
- Readers reject unknown fields, future versions, non-finite values, and oversized artifacts.
- Package resolution is exact-version only; no mutable
latestlookup occurs during a run. - A requested hardware target never falls back to a simulator.
- A failed controlled-power verification never falls back to repeated
pow. - Cancellation or incomplete rounds produce no complete phase estimate.
- Source, package bodies, session state, and provider credentials are not embedded in public reports unless an explicit source-bearing local artifact contract says so.
11. Acceptance
- Printer/IR/sidecar changes, if any, preserve round order and exact package identities without claiming generic QPE compatibility.
- Core, CLI, Worker, Test Explorer, and UI agree on canonical IPE artifacts.
- Seed fixtures prove the NM-RFC-0011 draw contract across reset rounds.
- Direct-power fixtures prove that gate count follows the specialized package carrier, not
2^ksource repetition. - Existing
algorithms.phase_estimation2@0.2remains a fixed teaching circuit. - Capability/runtime/Playground surfaces remain unchanged while proposed.
12. Required review record
| Review | Required decision | Status |
|---|---|---|
| Language owner | phase convention, bit order, precision constants, and result semantics | pending |
| Compiler owner | exact direct controlled-power manifest, specialization identity, and no-pow fallback | pending |
| Runtime owner | reset/feed-forward order, seed stream, cancellation, and bounded resource accounting | pending |
| Verification owner | numerical eigenphase fixtures, circular error, interval semantics, and tolerances | pending |
| Security owner | strict readers, exact-version phase-source trust, allocation limits, and hostile inputs | pending |
| Product owner | measured ready range, fixed lesson separation, and no generic-QPE claim | pending |
Approval must record reviewer identity, date, rationale, and a retained review artifact for every row. A merge, prototype, passing test, or local UI is not approval. Until every row is approved, no feature flag, parser/runtime surface, package export, capability, Test Explorer action, or lab control may be added.
13. Implementation sequence
- Approve phase convention, bit order, and direct-power manifest.
- Add strict plan/source/run readers and hostile-input fixtures.
- Add the one-control iterative kernel using NM-RFC-0011 semantics.
- Add independent numerical verification for retained phase sources.
- Connect CLI, Worker, Test Explorer, and an explicitly experimental lab.
- Publish only the measured ready range proven by the retained fixtures.