import strawberryfields as sf
from strawberryfields.ops import *
import numpy as np
from numpy import pi, sqrt
# set the random seed
np.random.seed(42)
import strawberryfields as sf
import numpy as np
from braket.strawberryfields_plugin import BraketEngine
eng = BraketEngine("arn:aws:braket:us-east-1::device/qpu/xanadu/Borealis")
device = eng.device
時間ごとの管理は大変なのでヘルパー関数を使うようです。
Copy
from strawberryfields.tdm import borealis_gbs, get_mode_indices
gate_args_list = borealis_gbs(device, modes=216, squeezing="high")
delays = [1, 6, 36]
n, N = get_mode_indices(delays)
2022-10-14 01:53:44,917 - WARNING - 133/259 arguments of phase gate 1 have been shifted by pi in order to be compatible with the phase modulators.
2022-10-14 01:53:44,921 - WARNING - 145/259 arguments of phase gate 2 have been shifted by pi in order to be compatible with the phase modulators.
先ほど確認した光連続量量子ゲートで回路を記述します。
Copy
from strawberryfields.ops import Sgate, Rgate, BSgate, MeasureFock
prog = sf.TDMProgram(N)
with prog.context(*gate_args_list) as (p, q):
Sgate(p[0]) | q[n[0]]
for i in range(len(delays)):
Rgate(p[2 * i + 1]) | q[n[i]]
BSgate(p[2 * i + 2], np.pi / 2) | (q[n[i + 1]], q[n[i]])
MeasureFock() | q[0]