This video belongs to the openHPI course Introduction to Quantum Computing with Qiskit (with IBM Quantum). Do you want to see more?
An error occurred while loading the video player, or it takes a long time to initialize. You can try clearing your browser cache. Please try again later and contact the helpdesk if the problem persists.
Scroll to current position
- 00:00Hi everyone! Welcome back to this very last video of our course.
- 00:04So, in this video I'm gonna talk about
- 00:07measurement error mitigation and as the name suggests,
- 00:10the goal is to mitigate some measurement errors.
- 00:12So, to correct for errors that happened during the measurement,
- 00:16I will show you how to do so with Qiskit by actually
- 00:19going through the examples that we have been running in before,
- 00:23like the
- 00:24circuit the Grover's, a circuit, all the measurement outcomes that we got there.
- 00:27I will show you how we can improve them when correcting for these errors.
- 00:32So, first of all we import our standard Qiskit libraries
- 00:37and then we actually have to, especially have
- 00:41to create what we call the calibration job.
- 00:44So, for that there's a premade Qiskit function which is
- 00:47called complete measurement collaboration where we feed the number of qubits
- 00:51and we also when run that, we need to give our layout,
- 00:55the layout that we have used.
- 00:56Or ideally we don't have to give it but we
- 00:58get much better results if we feed the layout that we
- 01:01have used when we run a specific job, so that we
- 01:03can also correct for errors that are correlated and stuff.
- 01:08So,
- 01:10the way the function works is we prepare all
- 01:13basis states, so all 2^n different states
- 01:17and then we measure them all.
- 01:18And ideally of course it would just measure whatever we have prepared.
- 01:21However, due to our noise,
- 01:24we will not always measure exactly the state with
- 01:27probability one but we might have a probability of 99%
- 01:31to measure the state that we have prepared and
- 01:33some very small probabilities to measure some other states.
- 01:36However, all these smaller probabilities add up.
- 01:39So, that's why we want to correct for them.
- 01:40And so what we do is we create this matrix,
- 01:42the so called calibration matrix, in which we
- 01:46note all these, in which we denote all
- 01:50these probabilities to then be able to correct for them.
- 01:54So, let us prepare the calibration shop.
- 01:58We again as always give our provider
- 02:01and now we executed this function measurement calibrations
- 02:05using the complete measurement calibration function from Qiskit
- 02:08with our backend which is well,
- 02:10the one here used the
- 02:11Hanoi device, because that's the one I've used for running Grover and Deutsch-Jozsa
- 02:15before. We feed the layout and determine the number of shots.
- 02:22Now, of course I ran it before so we don't have to wait again
- 02:26and here we can see.
- 02:28So, we will get from these calibration results.
- 02:30We will apply the complete measurement fitter function on that, on these results.
- 02:35And given the state labels which is just which states have prepared.
- 02:38So, in the case of three qubits, it's 000 001 010 and so on.
- 02:45We apply the filter, for we create the filter function then to filter later on
- 02:49the noisy measurement results and I will show you how the matrix looks like now.
- 02:55So, this is the matrix we got for the Hanoi device and we can see for example
- 03:00if I've prepared the state 000 there's a 91
- 03:03or 92% chance to actually measure that state.
- 03:07Well, they're smaller probabilities to measure other states.
- 03:09So, on the diagonal elements here are those that
- 03:13should ideally be as close as possible to one.
- 03:16But for example on this diagonal that would mean that all bits flipped.
- 03:21And of course that probability is actually the smallest.
- 03:23So, here you have the smallest number even in zero.
- 03:27Now what we can do is we can look at how
- 03:33this matrix looks like in a more illustrative way here
- 03:37you can see the prepared state and the measured state.
- 03:39So, as before you can see the probabilities of the dark
- 03:43head is the closer it is to one, looks now as
- 03:45if it would be almost one and well it is almost
- 03:48one is like what 90 between 91 and 94% or something.
- 03:54But then we also see here there's some higher probability that for example the
- 03:59second qubit flips rather than that the first qubit or last qubit flips
- 04:04and so on. So this is just an illustrative way of seeing it.
- 04:07But one thing I actually want to notice now here, we see there's
- 04:10a warning which is deprecation warning, because
- 04:13the Qiskit Ignis package is deprecated.
- 04:16So, the function that I've used just for this illustration
- 04:19now might not be available anymore in a few weeks.
- 04:23So, this just reminds me that I wanted to give you
- 04:25this general warning that of course Qiskit, it's being continuously developed.
- 04:30So, all the functions that you see now hopefully
- 04:32they will still be available in a few weeks,
- 04:35months, years.
- 04:36But sometimes they change a bit they might need or they might have
- 04:39additional functionalities and then you might need to give them another argument.
- 04:43They might require one more argument or something.
- 04:45So, if you try to run these functions one by one and something doesn't work maybe just
- 04:49check whether, checking the documentation of Qiskit, whether by
- 04:52now it needs one additional argument for example.
- 04:57So, now we can have a look at the Grover's job that I ran
- 05:00before and see then how we how the measurement error mitigation affects that.
- 05:06So, we call our backend and the old job by good that I saved the job ID
- 05:12here, then we look at the counts which are now called the
- 05:15noise counts which are the counts we got before, that I showed you before
- 05:20and we can now, once we are given the noise counts we can
- 05:23just calculate the mitigated counts, mitigated results
- 05:27by applying the measure the measurement filter.
- 05:32This way, so we apply the measurement filter and then get these mitigated
- 05:35counts and now we can plot both the noise counts and the mitigated counts
- 05:40and let's see how that looks like.
- 05:43So, here we can see it's not a huge advantage.
- 05:47It's not going from like 29% to 50% which would be the theoretical result.
- 05:51But we can still see that the two elements that we're looking for
- 05:55in the grover algorithm 001 and 010 those to get a small,
- 06:01we get a higher chance now, while all the others, here's a
- 06:05small exception, but in general they all have a lower probability.
- 06:08So, the red ones are the mitigated results.
- 06:11So, for the Deutsch-Jozsa algorithm that we ran before, let us look how they
- 06:17mitigated results look in that case.
- 06:20So, first here we can see the results of the very last job that we ran on Deutsch-Jozsa.
- 06:24So, the one where we created our oracle ourselves with all the CNOT gates.
- 06:29So, we only only had this 58% chance probability to get the correct result.
- 06:36Now we get 62%.
- 06:38So, again it's still not going up to one.
- 06:40But of course the problem is that most of the errors here
- 06:43came from the CNOT rates, from the
- 06:46CNOT error rates and not from the measurement.
- 06:50That's why we, so we only correct and correct for the measurement of course.
- 06:53And then we can see still all the other errors decrease.
- 06:57But so, what happens if we look at one of the results where we had a constant oracle.
- 07:05In this case for the constant oracle,
- 07:07we did not have to apply any CNOT gates and the circuit depth was very short.
- 07:11So, in the end we basically have no other errors but almost all
- 07:15errors just that we had just came from the measurement error mitigation.
- 07:20So, in this case here we can see that from 96%,
- 07:23our measurement error mitigation brings us to 100%.
- 07:28And all these blue small errors that are here,
- 07:31they all disappear in the mitigated version or at least they
- 07:34become so small that we can't see them anymore on the Histogram.
- 07:38You can also check for the other oracles, because that oracle was now
- 07:44constant.
- 07:47Now we have another mitigated one, but the two,
- 07:49now we can look at the other two oracles that were given by Qiskit
- 07:52or at least we have a higher probability before. So, here we can see from 84 it goes to 91.
- 07:58And in the very last one,
- 08:04we can see that it goes from 92-99.
- 08:07So you can see this,
- 08:09this oracle was also implemented in a way that probably
- 08:13did not require a lot of gates but was quite efficient in
- 08:17or efficient, well as we want to call,
- 08:19it would definitely be just easier implemented to create this balanced function.
- 08:26Yes,
- 08:27so with this was actually the last video of our
- 08:30course, so I really hope you have enjoyed all these videos.
- 08:34I wish you good luck for your final exam and I hope to see you in
- 08:37future videos from IBM, where they talk about getting more insights on how to use Qiskit.
To enable the transcript, please select a language in the video player settings menu.