|
4 | 4 |
|
5 | 5 | from netqasm.lang.ir import BranchLabel, GenericInstr, ICmd, ProtoSubroutine |
6 | 6 | from netqasm.logging.glob import get_netqasm_logger |
7 | | -from netqasm.sdk.build_types import NVHardwareConfig |
| 7 | +from netqasm.sdk.build_types import GenericHardwareConfig, NVHardwareConfig |
8 | 8 | from netqasm.sdk.connection import DebugConnection |
9 | 9 | from netqasm.sdk.constraint import ValueAtMostConstraint |
10 | 10 | from netqasm.sdk.epr_socket import EPRSocket |
@@ -1092,6 +1092,68 @@ def test_create_keep_no_corrections(): |
1092 | 1092 | ) |
1093 | 1093 |
|
1094 | 1094 |
|
| 1095 | +def test_create_keep_single_comm_qubit_no_memory_qubits(): |
| 1096 | + """ |
| 1097 | + Check that if there is a single communication qubit, but no memory qubits, |
| 1098 | + the subroutine for creating an EPR pair does not contain a MOV instruction. |
| 1099 | + """ |
| 1100 | + DebugConnection.node_ids = { |
| 1101 | + "Alice": 0, |
| 1102 | + "Bob": 1, |
| 1103 | + } |
| 1104 | + |
| 1105 | + epr_socket = EPRSocket("Bob") |
| 1106 | + |
| 1107 | + with DebugConnection("Alice", epr_sockets=[epr_socket]) as conn: |
| 1108 | + conn.builder._hardware_config = GenericHardwareConfig(1) |
| 1109 | + |
| 1110 | + epr_socket.create_keep(number=1) |
| 1111 | + |
| 1112 | + subroutine = conn.builder.subrt_pop_pending_subroutine() |
| 1113 | + |
| 1114 | + inspector = ProtoSubroutineInspector(subroutine) |
| 1115 | + assert inspector.match_pattern( |
| 1116 | + [ |
| 1117 | + GenericInstr.CREATE_EPR, |
| 1118 | + GenericInstr.RET_ARR, |
| 1119 | + ] |
| 1120 | + ) |
| 1121 | + |
| 1122 | + |
| 1123 | +def test_create_keep_single_comm_qubit_has_memory_qubits(): |
| 1124 | + """ |
| 1125 | + Check that if there is a single communication qubit and there are memory qubits, |
| 1126 | + the subroutine for creating an EPR pair does contain a MOV instruction. |
| 1127 | + """ |
| 1128 | + DebugConnection.node_ids = { |
| 1129 | + "Alice": 0, |
| 1130 | + "Bob": 1, |
| 1131 | + } |
| 1132 | + |
| 1133 | + epr_socket = EPRSocket("Bob") |
| 1134 | + |
| 1135 | + with DebugConnection("Alice", epr_sockets=[epr_socket]) as conn: |
| 1136 | + conn.builder._hardware_config = GenericHardwareConfig(1) |
| 1137 | + conn.builder._hardware_config._mem_qubit_count = 1 |
| 1138 | + |
| 1139 | + epr_socket.create_keep(number=1) |
| 1140 | + |
| 1141 | + subroutine = conn.builder.subrt_pop_pending_subroutine() |
| 1142 | + |
| 1143 | + inspector = ProtoSubroutineInspector(subroutine) |
| 1144 | + assert inspector.match_pattern( |
| 1145 | + [ |
| 1146 | + GenericInstr.CREATE_EPR, |
| 1147 | + PatternWildcard.ANY_ZERO_OR_MORE, |
| 1148 | + GenericInstr.WAIT_ALL, |
| 1149 | + PatternWildcard.ANY_ZERO_OR_MORE, |
| 1150 | + GenericInstr.MOV, |
| 1151 | + PatternWildcard.ANY_ZERO_OR_MORE, |
| 1152 | + GenericInstr.RET_ARR, |
| 1153 | + ] |
| 1154 | + ) |
| 1155 | + |
| 1156 | + |
1095 | 1157 | def test_recv_keep_no_corrections(): |
1096 | 1158 | DebugConnection.node_ids = { |
1097 | 1159 | "Alice": 0, |
|
0 commit comments