Skip to content

Commit

Permalink
make experiment 3 work by editing generator python and ned file, also…
Browse files Browse the repository at this point in the history
… add sh file to run experiments (old are comment outed)
  • Loading branch information
res6idue committed Jul 26, 2024
1 parent c95c38d commit 993b468
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 31 deletions.
37 changes: 30 additions & 7 deletions quisp/batch-simulation.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
#!/bin/bash

for i in 1 2 4 8 16 32 64;
# for i in 1 2 4 8 16 32 64;
# do
# echo "Welcome $i times"
# ./quisp -n "./networks:./channels:./modules:./simulations" -i \
# ./images ./simulations/mim_generation_test.ini -u Cmdenv -c "memory_$i" --cmdenv-status-frequency=10s > "out-$i" &
# done

# for i in 0 1 2 3 4 5 6 7 8 9 10;
# do
# alicedist="$((20 - $i))"
# echo "Welcome $i times $alicedist"
# ./quisp -n "./networks:./channels:./modules:./simulations" -i \
# ./images ./simulations/cross_validation.ini -u Cmdenv -c "mim_imbalanced_${alicedist}_${i}" --cmdenv-status-frequency=10s > "exp2-raw-${alicedist}_${i}" &
# done

for cnot in 0 025 05 075 1 125 15 175 2 225 25 275 3 325 35 375 4 425 45 475;
do
echo "Welcome $i times"
echo "Welcome cnot: $cnot, meas $meas, without decoherence"
./quisp -n "./networks:./channels:./modules:./simulations" -i \
./images ./simulations/cross_validation_config_generated.ini -u Cmdenv -c "swapping_validation_cnot_${cnot}_meas_0_with_1ms_decoherence" --cmdenv-status-frequency=10s > "exp3-raw-${cnot}_0_with_1ms_decoherence" &

echo "Welcome cnot: $cnot, meas $meas, with 1ms decoherence"
./quisp -n "./networks:./channels:./modules:./simulations" -i \
./images ./simulations/mim_generation_test.ini -u Cmdenv -c "memory_$i" --cmdenv-status-frequency=10s > "out-$i" &
./images ./simulations/cross_validation_config_generated.ini -u Cmdenv -c "swapping_validation_cnot_${cnot}_meas_0_without_decoherence" --cmdenv-status-frequency=10s > "exp3-raw-${cnot}_0_without_decoherence" &
done

for i in 0 1 2 3 4 5 6 7 8 9 10;
for meas in 025 05 075 1 125 15 175 2 225 25 275 3 325 35 375 4 425 45 475;
do
alicedist="$((20 - $i))"
echo "Welcome $i times $alicedist"
echo "Welcome cnot: $cnot, meas $meas, without decoherence"
./quisp -n "./networks:./channels:./modules:./simulations" -i \
./images ./simulations/cross_validation.ini -u Cmdenv -c "mim_imbalanced_${alicedist}_${i}" --cmdenv-status-frequency=10s > "exp2-raw-${alicedist}_${i}" &
./images ./simulations/cross_validation_config_generated.ini -u Cmdenv -c "swapping_validation_cnot_0_meas_${meas}_with_1ms_decoherence" --cmdenv-status-frequency=10s > "exp3-raw-0_${meas}_with_1ms_decoherence" &

echo "Welcome cnot: $cnot, meas $meas, with 1ms decoherence"
./quisp -n "./networks:./channels:./modules:./simulations" -i \
./images ./simulations/cross_validation_config_generated.ini -u Cmdenv -c "swapping_validation_cnot_0_meas_${meas}_without_decoherence" --cmdenv-status-frequency=10s > "exp3-raw-0_${meas}_without_decoherence" &

done
52 changes: 31 additions & 21 deletions quisp/networks/cross_validation_network.ned
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,50 @@ import modules.SharedResource.SharedResource;
import channels.*;


network CrossValidationTwoHop
network cross_validation_swapping
{
submodules:
backend: Backend;
logger: Logger;
sharedResource: SharedResource;
EndNode[2]: QNode {
address = index;

EndNode1: QNode {
address = 1;
node_type = "EndNode";
@display("i=COMP;");
//emission_timing_std = 1e-5;//standard deviation. normal(0, 1e-9)
//emission_timing_uncertainty = 10;
@display("i=COMP;p=56,202");
}

repeater: QNode {
address = 1234;
EndNode2: QNode {
address = 5;
node_type = "EndNode";
@display("i=COMP;p=473,202");
}
Repeater: QNode {
address = 3;
node_type = "Repeater";
//buffers = 25;
@display("i=REP1G");
@display("i=REP1G;p=264,203");
}

BSA: BSANode {
BSA1: BSANode {
address = 2;
@display("i=BSA");
node_type = "BSA";
@dispaly("p=42,150");
@display("p=158,86");
}
BSA2: BSANode {
address = 4;
node_type = "BSA";
@dispaly("p=42,150");
@display("p=371,86");
}

connections:
EndNode[0].port++ <--> ClassicalChannel { distance = 10km; } <--> repeater.port++;
repeater.port++ <--> ClassicalChannel { distance = 10km; } <--> BSA.port++;
BSA.port++ <--> ClassicalChannel { distance = 10km; } <--> EndNode[1].port++;
EndNode1.port++ <--> ClassicalChannel { distance = 10km; } <--> BSA1.port++;
Repeater.port++ <--> ClassicalChannel { distance = 10km; } <--> BSA1.port++;
Repeater.port++ <--> ClassicalChannel { distance = 10km; } <--> BSA2.port++;
EndNode2.port++ <--> ClassicalChannel { distance = 10km; } <--> BSA2.port++;

EndNode[0].quantum_port_receiver++ <--> QuantumChannel { distance = 10km; } <--> repeater.quantum_port++;
repeater.quantum_port++ <--> QuantumChannel { distance = 10km; } <--> BSA.quantum_port++;
BSA.quantum_port++ <--> QuantumChannel { distance = 10km; } <--> EndNode[1].quantum_port++;
EndNode1.quantum_port++ <--> QuantumChannel { distance = 10km; } <--> BSA1.quantum_port++;
Repeater.quantum_port++ <--> QuantumChannel { distance = 10km; } <--> BSA1.quantum_port++;
Repeater.quantum_port++ <--> QuantumChannel { distance = 10km; } <--> BSA2.quantum_port++;
EndNode2.quantum_port++ <--> QuantumChannel { distance = 10km; } <--> BSA2.quantum_port++;
}

network cross_validation_mim_link_middle
Expand Down
27 changes: 24 additions & 3 deletions quisp/simulations/cross_validation_config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,24 @@ def generate_swapping_config(
# **.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
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
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:
cnot_error_prob_str = "0"
if len(measurement_error_prob_str) == 0:
measurement_error_prob_str = "0"

if with_depolarizing:
config_name = f"[Config swapping_validation_cnot_{cnot_error_prob}_meas_{measurement_error_prob}_with_1ms_decoherence]"
config_name = f"[Config swapping_validation_cnot_{cnot_error_prob_str}_meas_{measurement_error_prob_str}_with_1ms_decoherence]"
# p = 0.0004623208506703652 --> resulting in P_I = 0.36781054 after 1ms
p_decoherence = 0.0004623208506703652
else:
config_name = f"[Config swapping_validation_cnot_{cnot_error_prob}_meas_{measurement_error_prob}_without_decoherence]"
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"
error_params = [
Expand All @@ -66,7 +78,12 @@ def generate_swapping_config(
f"**.memory_y_error_rate = {p_decoherence}",
f"**.memory_z_error_rate = {p_decoherence}",
]
return [config_name, network_name, *error_params]
other_params = [
f"**.qrsa.hm.link_tomography = true",
f"**.qrsa.hm.initial_purification = 0",
f"**.qrsa.hm.purification_type = \"\"",
]
return [config_name, network_name, *error_params, *other_params]


def write_config(filename: str, configs: list[list[str]]):
Expand Down Expand Up @@ -99,6 +116,10 @@ def write_config(filename: str, configs: list[list[str]]):
generate_swapping_config(0, gp, True) for gp in np.arange(0, 0.5, 0.025)
]

# delete the duplicate config in the lists, "swapping_validation_cnot_0_meas_0_"
swapping_configs_gate_error = swapping_configs_gate_error[1:]
swapping_configs_gate_error_with_depo = swapping_configs_gate_error_with_depo[1:]

write_config(
"cross_validation_config_generated.ini",
[
Expand Down

0 comments on commit 993b468

Please sign in to comment.