Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make purification_type string and change numerical values #554

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 0
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"



Expand All @@ -140,7 +140,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 1
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"



Expand All @@ -166,7 +166,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 2
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"


[Config Measurement7000_Layer2_Simple_MIM_MM_10km_3SepXXZPuri_low_memErr]
Expand All @@ -190,7 +190,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 3
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"


[Config Measurement7000_Layer2_Simple_MIM_MM_10km_4SepXXZPuri_low_memErr]
Expand All @@ -214,7 +214,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 4
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"


[Config Measurement7000_Layer2_Simple_MIM_MM_10km_5SepXXZPuri_low_memErr]
Expand All @@ -238,7 +238,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 5
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"


[Config Measurement7000_Layer2_Simple_MIM_MM_10km_6SepXXZPuri_low_memErr]
Expand All @@ -262,7 +262,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 6
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"



Expand All @@ -288,7 +288,7 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 7
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"



Expand All @@ -313,6 +313,6 @@ seed-set = ${0..24}

**.link_tomography = true
**.initial_purification = 8
**.purification_type = 3003
**.purification_type = "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"


Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ TEST_F(RuleSetGeneratorTest, PurificationRule) {

auto purification_rule = rsg->purifyRule(partner_addr, purification_type, 15);
auto serialized = purification_rule->serialize_json();
// rule_id is given by RuleSet and next_rule_id is given outside of Rule decration.
// rule_id is given by RuleSet and next_rule_id is given outside of Rule declaration.
json expected = R"({
"name":"purification with 1",
"send_tag": 15,
Expand Down
66 changes: 33 additions & 33 deletions quisp/modules/QRSA/HardwareMonitor/HardwareMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void HardwareMonitor::initialize(int stage) {
num_purification = par("initial_purification");
X_Purification = par("x_purification");
Z_Purification = par("z_purification");
purification_type = par("purification_type");
purification_type = std::string(par("purification_type").stringValue());
num_measure = par("num_measure");
my_address = provider.getNodeAddr();

Expand Down Expand Up @@ -562,7 +562,7 @@ work proceeds, a resource gets promoted from rule to rule (on
purification success), so if you ask for three rounds of purification,
it will emit three purification rules.

For example, with 2002, the first instance of "first stage X
For example, with "2N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z", the first instance of "first stage X
purification" (Rule0) includes allocating the resources from the base
pair pool, executing the purification circuit (including measurement),
exchanging the result messages, comparing and either promoting or
Expand Down Expand Up @@ -611,8 +611,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
std::vector<int> partners = {partner_address};

if (num_purification > 0) {
if (purification_type == 2002) { // Performs both X and Z purification for each n.
/// # Purification_type 2002: #
if (purification_type == "2N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z") { // Performs both X and Z purification for each n.
/// # Purification_type "2N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z": #
/// - name: Ss-Sp / perfect binary tree, even rounds
/// - rounds: 2n
/// - input Bell pairs per round: 2
Expand All @@ -625,7 +625,7 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
/// to switch basis, creating alternating
/// rounds of X and Z purification.
///
/// The only difference between 2002 and 3003
/// The only difference between "2N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z" and "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"
/// is the semantics of initial_purification.
/// Here, each iteration results in two rules,
/// guaranteeing an even number of rounds.
Expand All @@ -650,8 +650,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
constructCorrelationCheckRule("purification correlation check", PurType::SINGLE_SELECTION_Z_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 3003) {
/// # Purification_type 3003: #
} else if (purification_type == "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z") {
/// # Purification_type "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z": #
/// - name: Ss-Sp / perfect binary tree, odd or even rounds
/// - rounds: n
/// - input Bell pairs per round: 2
Expand All @@ -664,7 +664,7 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
/// to switch basis, creating alternating
/// rounds of X and Z purification.
///
/// The only difference between 2002 and 3003
/// The only difference between "2N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z" and "N_ALTERNATE_SINGLE_X_WITH_SINGLE_Z"
/// is the semantics of initial_purification.
/// Here, each iteration results in one rule,
/// X for even-numbered rounds (counting from zero),
Expand All @@ -688,8 +688,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
constructCorrelationCheckRule("purification correlation check", PurType::SINGLE_SELECTION_Z_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 1001) {
/// # Purification_type 1001: #
} else if (purification_type == "N_SINGLE_XZ") {
/// # Purification_type "N_SINGLE_XZ": #
/// - name: Ss-Dp XZ Purification
/// - rounds: n
/// - input Bell pairs per round: 3
Expand All @@ -702,7 +702,7 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
/// CNOT(A,C), MEAS(C), CNOT(E,A), MEAS(E)
/// then select after comparing outcomes.
/// Note that bases are not flipped between rounds.
/// Similar to 1221.
/// Similar to "N_ALTERNATE_SINGLE_XZ_WITH_SINGLE_ZX".
/// ![](../img/PhysRevA.100.052320-Fig12.png)
for (int i = 0; i < num_purification; i++) {
rule_name = "Double purification with: " + std::to_string(partner_address);
Expand All @@ -711,8 +711,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
tomography_RuleSet->addRule(
constructCorrelationCheckRule("purification correlation check", PurType::SINGLE_SELECTION_XZ_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
} else if (purification_type == 1221) {
/// # Purification_type 1221: #
} else if (purification_type == "N_ALTERNATE_SINGLE_XZ_WITH_SINGLE_ZX") {
/// # Purification_type "N_ALTERNATE_SINGLE_XZ_WITH_SINGLE_ZX": #
/// - name: Ss-Dp XZ, ZX alternating
/// - rounds: n
/// - input Bell pairs per round: 3
Expand All @@ -721,7 +721,7 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
/// of CNOTs reversed in alternating rounds
/// - scheduling: symmetric tree
/// ## description: ##
/// Almost the same as 1001, but first round
/// Almost the same as "N_SINGLE_XZ", but first round
/// is XZ, second round is ZX. Results in better alternating
/// error suppression, but still not great.
/// ![](../img/PhysRevA.100.052320-Fig12.png)
Expand All @@ -741,16 +741,16 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
constructCorrelationCheckRule("purification correlation check", PurType::SINGLE_SELECTION_ZX_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 1011) {
/// # Purification_type 1011: #
} else if (purification_type == "N_DOUBLE_X") {
/// # Purification_type "N_DOUBLE_X": #
/// - name: Ds-Sp: Fujii-san's Double selection purification
/// - rounds: n
/// - input Bell pairs per round: 3
/// - total Bell pairs: 3^n
/// - circuit: Fig. 13 in arXiv:1904.08605
/// - scheduling: symmetric tree
/// ## description: ##
/// Similar to 1001 and 1221 except that the control and target
/// Similar to "N_SINGLE_XZ" and "N_ALTERNATE_SINGLE_XZ_WITH_SINGLE_ZX" except that the control and target
/// of the first CNOT are flipped, corresponding to Fujii-san's
/// paper (PRA 80, 042308).
/// Every round is identical.
Expand All @@ -763,8 +763,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
tomography_RuleSet->addRule(
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_X_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
} else if (purification_type == 1021) { // Fujii-san's Double selection purification
/// # Purification_type 1021: #
} else if (purification_type == "N_ALTERNATE_DOUBLE_X_WITH_DOUBLE_Z") { // Fujii-san's Double selection purification
/// # Purification_type "N_ALTERNATE_DOUBLE_X_WITH_DOUBLE_Z": #
/// - name: Ds-Sp: Fujii-san's Double selection purification (alternating)
/// - rounds: n
/// - input Bell pairs per round: 3
Expand All @@ -773,7 +773,7 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
/// the order of the CNOTs alternates between rounds
/// - scheduling: symmetric tree
/// ## description: ##
/// Similar to 1011, almost corresponding to Fujii-san's paper (PRA 80,
/// Similar to "N_DOUBLE_X", almost corresponding to Fujii-san's paper (PRA 80,
/// 042308). Note there is no basis change between rounds, but that the
/// first round is XZ, second is ZX.
/// ![](../img/arxiv.1904.08605-Fig13.png)
Expand All @@ -793,8 +793,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_Z_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 1031) {
/// # Purification_type 1031: #
} else if (purification_type == "N_ALTERNATE_DOUBLE_XZ_WITH_DOUBLE_ZX") {
/// # Purification_type "N_ALTERNATE_DOUBLE_XZ_WITH_DOUBLE_ZX": #
/// - name: Ds-Dp: full double selection purification (alternating)
/// - rounds: n
/// - input Bell pairs per round: 5
Expand All @@ -803,7 +803,7 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
/// the order of the CNOTs alternates between rounds
/// - scheduling: symmetric tree
/// ## description: ##
/// A combination of 1001 and 1011 (Figs. 12 & 13). Resource requirements
/// A combination of "N_SINGLE_XZ" and "N_DOUBLE_X" (Figs. 12 & 13). Resource requirements
/// are high; two rounds of this requires 25 Bell pairs. With a low base
/// Bell pair generation rate and realistic memory decoherence, this will
/// be impractical.
Expand All @@ -815,17 +815,17 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
rule = constructPurifyRule(rule_name, PurType::DOUBLE_SELECTION_XZ_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag);
tomography_RuleSet->addRule(std::move(rule));
tomography_RuleSet->addRule(
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_X_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_XZ_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
} else {
rule_name = "Double selection Dual action Inverse with: " + std::to_string(partner_address);
rule = constructPurifyRule(rule_name, PurType::DOUBLE_SELECTION_ZX_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag);
tomography_RuleSet->addRule(std::move(rule));
tomography_RuleSet->addRule(
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_Z_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_ZX_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 1061) {
/// # Purification_type 1061: #
} else if (purification_type == "N_ALTERNATE_DOUBLE_X_SINGLE_Z_WITH_DOUBLE_Z_SINGLE_X") {
/// # Purification_type "N_ALTERNATE_DOUBLE_X_SINGLE_Z_WITH_DOUBLE_Z_SINGLE_X": #
/// - name: half double selection, half single selection
/// - rounds: n
/// - input Bell pairs per round: 4
Expand Down Expand Up @@ -854,8 +854,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 5555) { // Predefined purification method
/// # Purification_type 5555: #
} else if (purification_type == "2+N_DOUBLE_X_THEN_DOUBLE_Z_ALTERNATE_SINGLE_X_WITH_SINGLE_Z") { // Predefined purification method
/// # Purification_type "2+N_DOUBLE_X_THEN_DOUBLE_Z_ALTERNATE_SINGLE_X_WITH_SINGLE_Z": #
/// - name: Switching (B)
/// - rounds: n
/// - input Bell pairs per round: 3 in first two rounds, then 2
Expand Down Expand Up @@ -885,11 +885,11 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
tomography_RuleSet->addRule(
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_X_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
} else {
auto purify_action = std::make_unique<Purification>(PurType::DOUBLE_SELECTION_ZX_PURIFICATION, partner_address, shared_tag);
auto purify_action = std::make_unique<Purification>(PurType::DOUBLE_SELECTION_Z_PURIFICATION, partner_address, shared_tag);
rule->setAction(std::move(purify_action));
tomography_RuleSet->addRule(std::move(rule));
tomography_RuleSet->addRule(
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_ZX_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
constructCorrelationCheckRule("purification correlation check", PurType::DOUBLE_SELECTION_Z_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}

Expand All @@ -909,8 +909,8 @@ void HardwareMonitor::sendLinkTomographyRuleSet(int my_address, int partner_addr
constructCorrelationCheckRule("purification correlation check", PurType::SINGLE_SELECTION_Z_PURIFICATION, partner_address, qnic_type, qnic_index, shared_tag++));
}
}
} else if (purification_type == 5556) { // Predefined purification method
/// # Purification_type 5556: #
} else if (purification_type == "1+N_DOUBLE_X_ALTERNATE_SINGLE_Z_WITH_SINGLE_X") { // Predefined purification method
/// # Purification_type "1+N_DOUBLE_X_ALTERNATE_SINGLE_Z_WITH_SINGLE_X": #
/// - name: Switching (A)
/// - rounds: n
/// - input Bell pairs per round: 3 in first round, then 2
Expand Down
2 changes: 1 addition & 1 deletion quisp/modules/QRSA/HardwareMonitor/HardwareMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class HardwareMonitor : public IHardwareMonitor {
int num_purification = 0;
bool X_Purification = false;
bool Z_Purification = false;
int purification_type = -1;
int num_measure;
int num_end_nodes;

Expand All @@ -70,6 +69,7 @@ class HardwareMonitor : public IHardwareMonitor {
LinkCostMap *tomography_runningtime_holder;
std::string tomography_output_filename;
std::string file_dir_name;
std::string purification_type;

protected:
void initialize(int stage) override;
Expand Down
2 changes: 1 addition & 1 deletion quisp/modules/QRSA/HardwareMonitor/HardwareMonitor.ned
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ simple HardwareMonitor
string file_dir_name = default("results/");
// purification control
int initial_purification;
int purification_type;
string purification_type;
// these two are obsolete controls for purification
bool x_purification = default(false);
bool z_purification = default(false);
Expand Down
2 changes: 1 addition & 1 deletion quisp/modules/QRSA/HardwareMonitor/HardwareMonitor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class HardwareMonitorTestTarget : public quisp::modules::HardwareMonitor {
setParInt(this, "initial_purification", 0);
setParBool(this, "x_purification", true);
setParBool(this, "z_purification", true);
setParInt(this, "purification_type", 0);
setParStr(this, "purification_type", "");
setParInt(this, "num_measure", 0);

this->setName("hardware_monitor_test_target");
Expand Down
Loading
Loading