def generate_noisy_ghz(F, N):
    """
    Generate a noisy GHZ state of a given fidelity.

    Parameters
    -----------
    F : (scalar) fidelity of the final state
    N : (int) size of the final GHZ
    """
    # p = 1 - F
    # nu = 4**N*p/(4**N - 1)
    ghz = qt.ghz_state(N)
    ghz = ghz * ghz.dag()
    rho = (F**2) * ghz + (1- F**2)/(2**N) * qt.qeye([2]*N)
    return rho
Example #2
0
def test_ghz_type():
    "State CSR Type: ghz_state"
    st = ghz_state(3)
    assert_equal(isspmatrix_csr(st.data), True)
Example #3
0
theta = .63

# NOTE: Parameters as in Raja's thesis
# ps = 0.006
# pm = 0.006
# pg = 0.006
# a0 = 83.33
# a1 = 1/3.
# eta = (0.1)*(0.03)*(0.8)
# theta = .24

iterations = 30

# Initialize objects
rho_ref = qt.bell_state('00') * qt.bell_state('00').dag()
ghz_ref = qt.ghz_state(4) * qt.ghz_state(4).dag()

F = []
T = []
print("-------------------PROTOCOL TEST------------------")
for i in range(iterations):

    circuit = protocols.ghz4_epl(ps, pm, pg, eta, a0, a1, theta)
    rho, operations = circuit.run()
    fidelity = qt.fidelity(rho, ghz_ref)
    # print("F: ", fidelity)
    # print("T: ", operations["time"])
    # print(operations)
    # print(operations)
    F += [fidelity]
    T += [operations["time"]]
Example #4
0
def test_ghz_states():
    state = (qutip.qstate("uuu") + qutip.qstate("ddd")).unit()
    assert state == qutip.ghz_state(3)
"""

import qutip as qt
import numpy as np
import stabilizer

# Determine parameters
ps = 0.006
pm = 0.006
pg = 0.006

# Initialize  objects
stab = stabilizer.Stabilizer(ps, pm, pg)
stab_ideal = stabilizer.Stabilizer(0, 0, 0)

print("------------------TEST SWAP PAIR--------------------------")
pair = qt.bell_state('00') * qt.bell_state('00').dag()
pair = qt.tensor(pair, qt.basis(2, 0) * qt.basis(2, 0).dag())

pair_swapped = stab._swap_pair(pair, [0, 1])
print(pair)
print(pair_swapped)
print(qt.fidelity(pair, pair_swapped)**2)

print("------------------TEST SWAP GHZ--------------------------")
ghz = qt.ghz_state(4) * qt.ghz_state(4).dag()

ghz_swapped = stab._swap_ghz(ghz)
# print(ghz_swapped)
print(qt.fidelity(ghz, ghz_swapped)**2)
Example #6
0
        default=25,
        help="How often do you want to see the states rendered?")
    parser.add_argument(
        '-e',
        '--epochs',
        type=int,
        default=2000,  # 2000
        help="How many epochs the network is trained")
    args = parser.parse_args()

    dim = parameters_spinchain.N
    nsite = parameters_spinchain.M
    n_par = 512  #M=3: 256, M=4: 64, M=5: 16

    # GHZ state
    target_state = qu.ghz_state(nsite).full()

    # initialize figures to render
    if args.render == True: fig, axes = plt.subplots(1, 3, figsize=(10, 4))

    model = PredCorrNetwork(dim, nsite, n_par, target_state)
    print(model)
    print("number of model parameters:",
          sum([np.prod(p.size()) for p in model.parameters()]))

    if args.optimizer == "SGD":
        optimizer = optim.SGD(model.parameters(), lr=1e-6)
    elif args.optimizer == "ADAM":
        optimizer = optim.Adam(
            model.parameters(),
            lr=0.0007,
Example #7
0
def env_error_rate(t, a):
    # Function to calculate the error to the enviroment for step of stabilizers
    # measurements
    x = a * t
    p_env = (1 - np.exp(-x)) / 4.
    return p_env


# Number of iterations for a average
iterations = 2000
ignore_number = int(iterations / 100 * 5.)

# Initialize objects and define references
bell_ref = qt.bell_state('00') * qt.bell_state('00').dag()
bell_ref2 = qt.bell_state('01') * qt.bell_state('01').dag()
ghz4_ref = qt.ghz_state(4) * qt.ghz_state(4).dag()
ghz3_ref = qt.ghz_state(3) * qt.ghz_state(3).dag()

rho_ref = bell_ref

# Stabilizer and error modeling stuff
stab_size = 4
parity = "X"

stab = stabilizer.Stabilizer(ps=ps, pm=pm, pg=pg)
model = noise_modeling.NoiseModel(stab_size, parity)
model.separate_basis_parity()

# Choi state for noise noise modeling
choi = model._choi_state_ket(stab_size)
choi = choi * choi.dag()