Skip to content

Commit

Permalink
add config file and partial postprocessing script
Browse files Browse the repository at this point in the history
  • Loading branch information
Naphann committed Jul 26, 2024
1 parent 7f02d75 commit 6b33780
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 36 deletions.
13 changes: 13 additions & 0 deletions quisp/post-process-simulation-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ do
grep "sim time" "exp2-raw-${alicedist}_${i}" | awk '{print $3}' | sed -n 'n;p' > "postprocess-exp2-$i"
done


# TODO: complete the postprocessing
for cnot in 0 025 05 075 1 125 15 175 2 225 25 275 3 325 35 375 4 425 45 475 5;
do
grep "fidelity" "exp3-raw-${cnot}_0_without_decoherence" | sed -n 's/.*Fidelity=\(0\.[0-9]*\).*/\1/p' | sed -n 'n;p' | cat
grep "sim time" "exp3-raw-${cnot}_0_without_decoherence" | cat
done

for cnot in 0 025 05 075 1 125 15 175 2 225 25 275 3 325 35 375 4 425 45 475 5;
do
grep "fidelity" "exp3-raw-${cnot}_0_with_1ms_decoherence" | sed -n 's/.*Fidelity=\(0\.[0-9]*\).*/\1/p' | sed -n 'n;p' | cat
grep "sim time" "exp3-raw-${cnot}_0_with_1ms_decoherence" | cat
done
48 changes: 16 additions & 32 deletions quisp/simulations/cross_validation_config_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/python3

import numpy as np
import os

import numpy as np


def generate_mim_exp_config(num_memories: int, alice_to_bsa: int, bob_to_bsa: int):
# [Config mim_imbalanced_10_10]
Expand All @@ -29,20 +30,19 @@ def generate_mim_exp_config(num_memories: int, alice_to_bsa: int, bob_to_bsa: in
# return [config_name, network_name, *error_params]


def generate_swapping_config(
cnot_error_prob: float, measurement_error_prob: float, with_depolarizing: bool
):
def generate_swapping_config(cnot_error_prob: float, measurement_error_prob: float, with_depolarizing: bool):
# [Config mim_imbalanced_10_10]
# network = networks.cross_validation_mim_link_imbalanced_10_10
# **.qrsa.hm.link_tomography = true
# **.qrsa.hm.initial_purification = 0
# **.qrsa.hm.purification_type = ""
# **.buffers = 1

# fix the cnot_error_prob and measurement_error_prob up to necessary decimal places
# round error probability to 3 decimal places
cnot_error_prob = round(cnot_error_prob, 3)
measurement_error_prob = round(measurement_error_prob, 3)
# delete the leading 0. and change it into string

# delete leading 0. and change it into string
cnot_error_prob_str = str(cnot_error_prob)[2:]
measurement_error_prob_str = str(measurement_error_prob)[2:]
if len(cnot_error_prob_str) == 0:
Expand All @@ -57,18 +57,9 @@ def generate_swapping_config(
else:
config_name = f"[Config swapping_validation_cnot_{cnot_error_prob_str}_meas_{measurement_error_prob_str}_without_decoherence]"
p_decoherence = 0
network_name = f"network = networks.cross_validation_swapping"
network_name = "network = networks.cross_validation_swapping"
error_params = [
f"**.cnot_gate_error_rate = {cnot_error_prob}",
f"**.cnot_gate_iz_error_ratio = {1/9}",
f"**.cnot_gate_zi_error_ratio = {1/9}",
f"**.cnot_gate_zz_error_ratio = {1/9}",
f"**.cnot_gate_ix_error_ratio = {1/9}",
f"**.cnot_gate_xi_error_ratio = {1/9}",
f"**.cnot_gate_xx_error_ratio = {1/9}",
f"**.cnot_gate_iy_error_ratio = {1/9}",
f"**.cnot_gate_yi_error_ratio = {1/9}",
f"**.cnot_gate_yy_error_ratio = {1/9}",
#
f"**.x_measurement_error_rate = {measurement_error_prob}",
f"**.y_measurement_error_rate = {measurement_error_prob}",
Expand All @@ -79,10 +70,10 @@ def generate_swapping_config(
f"**.memory_z_error_rate = {p_decoherence}",
]
other_params = [
f"**.qrsa.hm.link_tomography = true",
f"**.qrsa.hm.initial_purification = 0",
f"**.qrsa.hm.purification_type = \"\"",
f"*.EndNode1.is_initiator = true",
"**.qrsa.hm.link_tomography = false",
"**.qrsa.hm.initial_purification = 0",
'**.qrsa.hm.purification_type = ""',
"*.EndNode1.is_initiator = true",
]
return [config_name, network_name, *error_params, *other_params]

Expand All @@ -91,6 +82,7 @@ def write_config(filename: str, configs: list[list[str]]):
# config relative path inside simulation folder
dirname = os.path.dirname(__file__)
general_ini_file = os.path.join(dirname, "general_config.ini")
filename = os.path.join(dirname, filename)

with open(filename, "w") as the_file:
with open(general_ini_file) as f:
Expand All @@ -104,18 +96,10 @@ def write_config(filename: str, configs: list[list[str]]):
# exp 3: gate error
# exp 3: measurement error
# exp 3: with decoherence
swapping_configs_gate_error = [
generate_swapping_config(gp, 0, False) for gp in np.arange(0, 0.5, 0.025)
]
swapping_configs_gate_error_with_depo = [
generate_swapping_config(gp, 0, True) for gp in np.arange(0, 0.5, 0.025)
]
swapping_configs_meas_error = [
generate_swapping_config(0, gp, False) for gp in np.arange(0, 0.5, 0.025)
]
swapping_configs_meas_error_with_depo = [
generate_swapping_config(0, gp, True) for gp in np.arange(0, 0.5, 0.025)
]
swapping_configs_gate_error = [generate_swapping_config(gp, 0, False) for gp in np.arange(0, 0.51, 0.025)]
swapping_configs_gate_error_with_depo = [generate_swapping_config(gp, 0, True) for gp in np.arange(0, 0.51, 0.025)]
swapping_configs_meas_error = [generate_swapping_config(0, gp, False) for gp in np.arange(0, 0.51, 0.025)]
swapping_configs_meas_error_with_depo = [generate_swapping_config(0, gp, True) for gp in np.arange(0, 0.51, 0.025)]

# delete the duplicate config in the lists, "swapping_validation_cnot_0_meas_0_"
swapping_configs_gate_error = swapping_configs_gate_error[1:]
Expand Down
33 changes: 29 additions & 4 deletions quisp/simulations/general_config.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[General]
repeat = 1
seed-set = ${repetition}
sim-time-limit = 100s
sim-time-limit = 5000s
**.initial_notification_timing_buffer = 10s # when to start the BSA timing notification.
**.app.request_generation_interval = 2s
**.logger.enabled_log = false
**.logger.log_filename = "${resultdir}/${configname}-${runnumber}.jsonl"
**.logger.log_filename = "networks/${resultdir}/${configname}-${runnumber}.jsonl"
**.tomography_output_filename = "${resultdir}/${configname}.output"
**.statistic-recording = false
**.scalar-recording = false
Expand Down Expand Up @@ -33,7 +33,32 @@ sim-time-limit = 100s
**.z_gate_y_error_ratio = 0
**.z_gate_z_error_ratio = 0

# CNOT error parameters
**.cnot_gate_error_rate = 0
**.cnot_gate_iz_error_ratio = 0
**.cnot_gate_zi_error_ratio = 0
**.cnot_gate_zz_error_ratio = 0
**.cnot_gate_ix_error_ratio = 0
**.cnot_gate_xi_error_ratio = 0
**.cnot_gate_xx_error_ratio = 0
**.cnot_gate_iy_error_ratio = 0
**.cnot_gate_yi_error_ratio = 0
**.cnot_gate_yy_error_ratio = 0

# memory error parameters
**.memory_x_error_rate = 0
**.memory_y_error_rate = 0
**.memory_z_error_rate = 0
**.memory_energy_excitation_rate = 0
**.memory_energy_relaxation_rate = 0
**.memory_completely_mixed_rate = 0

# measurement error parameters
**.x_measurement_error_rate = 0
**.z_measurement_error_rate = 0
**.y_measurement_error_rate = 0

# simulation parameters
**.app.number_of_bellpair = 1000000
**.buffers = 1
**.qrsa.hm.num_measure = 10000000

**.qrsa.hm.num_measure = 1000000

0 comments on commit 6b33780

Please sign in to comment.