|
8 | 8 | "# Performing an error mitigation workflow with program sets on Amazon Braket\n", |
9 | 9 | "\n", |
10 | 10 | "This notebook builds on topics present in the error mitigation workflow seen using mitiq, but instead focuses on a QHP-based (Rigetti) workflow. As such, it requires substantial customization beyond what is commonly available. \n", |
| 11 | +<<<<<<< HEAD |
11 | 12 | "\n", |
| 13 | +======= |
| 14 | + ">[!WARNING]\n", |
| 15 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
12 | 16 | ">Executing this notebook with devices will charge your AWS account! Please keep this in mind and verify with the previous notebook tracker. " |
13 | 17 | ] |
14 | 18 | }, |
|
117 | 121 | "id": "15258900", |
118 | 122 | "metadata": {}, |
119 | 123 | "source": [ |
| 124 | +<<<<<<< HEAD |
| 125 | +======= |
| 126 | + ">[!NOTE]\n", |
| 127 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
120 | 128 | "> To use the emulator, you can simply specify a smaller number of qubits, and modify the device target \n", |
121 | 129 | "\n", |
122 | 130 | "Now we define our problem Hamiltonian, here a simple Ising Hamiltonian. For simplicity, we use a simple string representation of the Pauli operators, and a greedy color-based grouping scheme using networkx. \n", |
|
928 | 936 | ] |
929 | 937 | }, |
930 | 938 | { |
| 939 | +<<<<<<< HEAD |
931 | 940 | "cell_type": "code", |
932 | 941 | "execution_count": null, |
933 | 942 | "id": "3d22aa40", |
|
936 | 945 | "source": [] |
937 | 946 | }, |
938 | 947 | { |
| 948 | +======= |
| 949 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
939 | 950 | "cell_type": "markdown", |
940 | 951 | "id": "2b4d5cca", |
941 | 952 | "metadata": {}, |
942 | 953 | "source": [ |
| 954 | +<<<<<<< HEAD |
943 | 955 | "### Step 0.5 - Generating Circuits\n", |
944 | 956 | "\n", |
945 | 957 | "Here, we generate our circuits. We first expand the circuits into noise amplified virsions, and then we apply a twirling sequence for each circuit. For the device, we need to convert the Pauli operators to native Rigetti instructions, and then remove the verbatim flags from the circuits. We will add these back in later, once we have bound observables to our circuits. \n", |
946 | 958 | "\n", |
947 | 959 | "> You also could construct observables at this point, ideally before or after ZNE, and before twirling circuits. " |
| 960 | +======= |
| 961 | + "### Step 0.5 - Generating Circuits" |
| 962 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
948 | 963 | ] |
949 | 964 | }, |
950 | 965 | { |
951 | 966 | "cell_type": "code", |
| 967 | +<<<<<<< HEAD |
952 | 968 | "execution_count": null, |
| 969 | +======= |
| 970 | + "execution_count": 18, |
| 971 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
953 | 972 | "id": "91405d02", |
954 | 973 | "metadata": {}, |
955 | 974 | "outputs": [ |
|
969 | 988 | ], |
970 | 989 | "source": [ |
971 | 990 | "folded_circuits = [multiply_gates(ansatz_v1, ['ISwap','Rz'],scale) for scale in scale_factors_expanded]\n", |
| 991 | +<<<<<<< HEAD |
972 | 992 | "circuits_pre = np.array([twirl_iswap(c, num_twirls) for c in folded_circuits], dtype=object)\n", |
| 993 | +======= |
| 994 | + "\n", |
| 995 | + "\n", |
| 996 | + "circuits_pre = np.array([twirl_iswap(c, num_twirls) for c in folded_circuits], dtype=object)\n", |
| 997 | + "\n", |
| 998 | + "\n", |
| 999 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
973 | 1000 | "circuits, twirls = apply_readout_twirl(circuits_pre)\n", |
974 | 1001 | "\n", |
975 | 1002 | "circuits = np.vectorize(convert_paulis)(circuits)\n", |
|
993 | 1020 | }, |
994 | 1021 | { |
995 | 1022 | "cell_type": "markdown", |
| 1023 | +<<<<<<< HEAD |
| 1024 | +======= |
| 1025 | + "id": "0f63942a", |
| 1026 | + "metadata": {}, |
| 1027 | + "source": [ |
| 1028 | + "We can also just visually verify that our circuits look reasonable:" |
| 1029 | + ] |
| 1030 | + }, |
| 1031 | + { |
| 1032 | + "cell_type": "code", |
| 1033 | + "execution_count": null, |
| 1034 | + "id": "b8662489", |
| 1035 | + "metadata": {}, |
| 1036 | + "outputs": [], |
| 1037 | + "source": [] |
| 1038 | + }, |
| 1039 | + { |
| 1040 | + "cell_type": "markdown", |
| 1041 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
996 | 1042 | "id": "7533d1e8", |
997 | 1043 | "metadata": {}, |
998 | 1044 | "source": [ |
|
1070 | 1116 | "source": [ |
1071 | 1117 | "#### Step 2.0 - Main Execution\n", |
1072 | 1118 | "\n", |
| 1119 | +<<<<<<< HEAD |
1073 | 1120 | "From our custom `run_with_program_sets` functions, using `None` for our set of observables in each basis indicates that we want to return the output distribution. " |
| 1121 | +======= |
| 1122 | + "Now, we begin our main execution. Supplying `None` as our set of observables indicates that we want to return the output distribution. " |
| 1123 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
1074 | 1124 | ] |
1075 | 1125 | }, |
1076 | 1126 | { |
|
1113 | 1163 | "source": [ |
1114 | 1164 | "### Step 3.0 - processing our results\n", |
1115 | 1165 | "\n", |
| 1166 | +<<<<<<< HEAD |
1116 | 1167 | "Now, we need to carry out our processing. The main two ways are to either extrapolate a final summed expectation value, or to extrapolate each Pauli observable, and then sum. We find the latter method typically works slightly better, but that may not be true for all systems. \n", |
| 1168 | +======= |
| 1169 | + "Now, we need to carry out our processing. The main two ways are to extrapolate a final expectation value, or to extrapolate each Pauli observable, and then sum. We find the latter method typically works slightly better, but that may not be true for all systems. \n", |
| 1170 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
1117 | 1171 | "\n", |
1118 | 1172 | "Additionally, we have three relevant set of qubit labels to keep track of. First, our problem and associated Hamiltonian entries, which are indexed from 1 to `num_qubits`. These are associated with a physical set of qubits, and finally there is the register, which importantly, is taken to be ordered by design. " |
1119 | 1173 | ] |
|
1700 | 1754 | "\n", |
1701 | 1755 | "For this precision, assuming that our method is more or less unbiased and that the true noisy mean is 0.52, we would expect to see improvements of between 14-16x improvement, maybe as low as 5-10x, solely based on precision, so our result is optimistically better. \n", |
1702 | 1756 | "\n", |
| 1757 | +<<<<<<< HEAD |
1703 | 1758 | "Regardless, with careful planning, these principles can be applied to other, more complex systems. For this workflow, we can see that individually, the different error mitigation methods do help, but not in as complete a manner as using them all together. " |
| 1759 | +======= |
| 1760 | + "Regardless, with careful planning, these principles can be applied to numerous systems. For this workflow, we can see that individually, the different error mitigation methods do help, but not in as complete a manner as using them all together. " |
| 1761 | +>>>>>>> 98f6da3 (feature: updates to error mitigation examples (#814)) |
1704 | 1762 | ] |
1705 | 1763 | }, |
1706 | 1764 | { |
|
0 commit comments