primitive · G8
Amplitude estimation via canonical QPE
One target qubit prepared in |1⟩ (a trivial "good-state preparation" for amplitude estimation), an m = 4 estimation register in |+⟩4, controlled-U2j via the cphase_h primitive, then an inverse QFT and a terminal measurement. Bit-reversal is resolved in the host decoder.
amplitude_estimation_verified · bit_order = msb_first · worst bin error = 0
Per-a results
| a (predicted) | peak bin | peak mass | |bin − a| | shots |
|---|---|---|---|---|
| 2 | 2 | 1.000 | 0 | 1024 |
| 4 | 4 | 1.000 | 0 | 1024 |
| 6 | 6 | 1.000 | 0 | 1024 |
| 7 | 7 | 1.000 | 0 | 1024 |
a = 2 · histogram over 16 bins (msb_first)
a = 4 · histogram over 16 bins (msb_first)
a = 6 · histogram over 16 bins (msb_first)
a = 7 · histogram over 16 bins (msb_first)
Kernel snippet (a = 4)
open in Playpond ↗
from quantum.nadarasa_g8_lib import (
guppy, qubit, h, x, cx, rz, measure, result, angle, cphase_h,
)
@guppy
def program() -> None:
e0 = qubit()
e1 = qubit()
e2 = qubit()
e3 = qubit()
tgt = qubit()
x(tgt)
h(e0); h(e1); h(e2); h(e3)
cphase_h(e0, tgt, 0.5)
cphase_h(e1, tgt, 1.0)
cphase_h(e2, tgt, 2.0)
cphase_h(e3, tgt, 4.0)
h(e3)
cphase_h(e3, e2, -0.5)
h(e2)
cphase_h(e3, e1, -0.25)
cphase_h(e2, e1, -0.5)
h(e1)
cphase_h(e3, e0, -0.125)
cphase_h(e2, e0, -0.25)
cphase_h(e1, e0, -0.5)
h(e0)
result("e0", measure(e0))
result("e1", measure(e1))
result("e2", measure(e2))
result("e3", measure(e3))
result("tgt", measure(tgt))