{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# This cell is added by sphinx-gallery\n# It can be customized to whatever you like\n%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Quantum computing with superconducting qubits {#superconducting_qubits}\n=============================================\n\n::: {.meta}\n:property=\\\"og:description\\\": Learn about quantum computers based on\nsuperconducting qubits, developed by companies such as IBM and Google.\n:property=\\\"og:image\\\": \n:::\n\n::: {.related}\ntutorial\\_pasqal Quantum computation with neutral atoms\ntutorial\\_trapped\\_ions Trapped ion quantum computers\ntutorial\\_photonics Photonic quantum computers\n:::\n\n*Author: Alvaro Ballon --- Posted: 22 March 2022. Last updated: 26\nAugust 2022.*\n\n**Superconducting qubits** are among the most promising approaches to\nbuilding quantum computers. It is no surprise that this technology is\nbeing used by well-known tech companies in their quest to pioneer the\nquantum era. Google\\'s Sycamore claimed quantum advantage back in 2019\nand, in 2021, IBM built its Eagle quantum computer with 127 qubits! The\ncentral insight that allows for these quantum computers is that\nsuperconductivity is a quantum phenomenon, so we can use superconducting\ncircuits as quantum systems that we can control at will. We can actually\nbring the quantum world to a larger scale and manipulate it more freely!\n\nBy the end of this demo, you will learn how superconductors are used to\ncreate, prepare, control, and measure the state of a qubit. Moreover,\nyou will identify the strengths and weaknesses of this technology in\nterms of Di Vincenzo\\'s criteria, as introduced in the box below. You\nwill be armed with the basic concepts to understand the main scientific\npapers on the topic and keep up-to-date with the newest developments.\n\n::: {.container .alert .alert-block .alert-info}\n**Di Vincenzo\\'s criteria**: In the year 2000, David DiVincenzo proposed\na wishlist for the experimental characteristics of a quantum computer.\nDiVincenzo\\'s criteria have since become the main guideline for\nphysicists and engineers building quantum computers:\n\n1\\. **Well-characterized and scalable qubits**. Many of the quantum\nsystems that we find in nature are not qubits, so we must find a way to\nmake them behave as such. Moreover, we need to put many of these systems\ntogether.\n\n2\\. **Qubit initialization**. We must be able to prepare the same state\nrepeatedly within an acceptable margin of error.\n\n3\\. **Long coherence times**. Qubits will lose their quantum properties\nafter interacting with their environment for a while. We would like them\nto last long enough so that we can perform quantum operations.\n\n4\\. **Universal set of gates**. We need to perform arbitrary operations\non the qubits. To do this, we require both single-qubit gates and\ntwo-qubit gates.\n\n5\\. **Measurement of individual qubits**. To read the result of a\nquantum algorithm, we must accurately measure the final state of a\npre-chosen set of qubits.\n:::\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Superconductivity\n=================\n\n![..](../demonstrations/sc_qubits/sc_device.png){.align-center\nwidth=\"60.0%\"}\n\nSuperconducting chip with 4 qubits\n\nTo understand how superconducting qubits work, we first need to explain\nwhy some materials are superconductors. Let\\'s begin by addressing a\nsimpler question: why do conductors allow for the easy passage of\nelectrons and insulating materials don\\'t? Solid-state physics tells us\nthat when an electric current travels through a material, the electrons\ntherein come in two types. *Conduction electrons* flow freely through\nthe material, while *valence electrons* are attached to the atoms that\nform the material itself. A material is a good conductor of electricity\nif the valence electrons require no energy to be stripped from the atoms\nto become conduction electrons. Similarly, the material is a\nsemi-conductor if the energy needed is small, and it\\'s an insulator if\nthe energy is large.\n\nBut, if conduction electrons can be obtained for free in conducting\nmaterials, then why don\\'t all conductors have infinite conductivity?\nEven the tiniest of stimuli should create a very large current! To\naddress this valid concern, let us recall the *exclusion principle* in\natomic physics: the atom\\'s discrete energy levels have a population\nlimit, so only a limited number of electrons can have the same energy.\nHowever, the exclusion principle is not limited to electrons in atomic\norbitals. In fact, it applies to all electrons that are organized in\ndiscrete energy levels. Since conduction electrons also occupy discrete\n*conduction energy levels*, they must also abide by this law! The\nconductivity is then limited because, when the lower conduction energy\nlevels are occupied, the energy required to promote valence to\nconduction electrons is no longer zero. This energy will keep increasing\nas the population of conduction electrons grows.\n\n![..](../demonstrations/sc_qubits/conduction_band.png){.align-center\nwidth=\"60.0%\"}\n\nValence and conduction energy levels\n\nHowever, superconductors *do* have infinite conductivity. How is this\neven possible? It\\'s not a phenomenon that we see in our daily lives.\nFor some materials, at extremely low temperatures, the conduction\nelectrons attract the positive nuclei to form regions of high positive\ncharge density, alternating with regions of low charge density. This\ncharge distribution oscillates in an organized manner, creating waves in\nthe material known as *phonons*. The conduction electrons are pushed\ntogether by these phonons, forming *Cooper pairs*. Most importantly,\nthese coupled electrons need not obey the exclusion principle. We no\nlonger have an electron population limit in the lower conduction energy\nlevels, allowing for infinite conductivity!\n\n![..](../demonstrations/sc_qubits/cooper_pairs.png){.align-center\nwidth=\"60.0%\"}\n\nCooper pairs are formed by alternating regions of high and low density\nof positive charge (phonons) represented by the density of red dots.\n\n::: {.container .alert .alert-block .alert-info}\n**PennyLane plugins:** You can run your quantum algorithms on actual\nsuperconducting qubit quantum computers on the Cloud. The Qiskit, Amazon\nBraket, Cirq, and Rigetti PennyLane plugins give you access to some of\nthe most powerful superconducting quantum hardware.\n:::\n\nBuilding an artificial atom\n===========================\n\nWhen we code in PennyLane, we deal with the abstraction of a qubit. But\nhow is a qubit actually implemented physically? Some of the most widely\nused real-life qubits are built from individual atoms. But atoms are\ngiven to us by nature, and we cannot easily alter their properties. So\nalthough they are reliable qubits, they are not very versatile. We may\nadapt our technology to the atoms, but they seldom adapt to our\ntechnology. Could there be a way to build a device with the same\nproperties that make atoms suitable qubits? Let\\'s see if we can build\nan artificial atom!\n\nOur first task is to isolate the features that an ideal qubit should\nhave. First and foremost, we must not forget that a qubit is a physical\nsystem with **two distinguishable configurations** that correspond to\nthe computational basis states. In the case of an atom, these are\nusually the ground and excited states, $\\left\\lvert g \\right\\rangle$ and\n$\\left\\lvert e \\right\\rangle$, of a valence electron. In atoms, we can\ndistinguish these states reliably because the ground and excited states\nhave two distinct values of energy that can be resolved by our measuring\ndevices. If we measure the energy of the valence electron that is in\neither $\\left\\lvert g \\right\\rangle$ or $\\left\\lvert e \\right\\rangle$,\nwe will measure two --- and only two --- possible values $E_0$ and\n$E_1$, associated to $\\left\\lvert g \\right\\rangle$ and\n$\\left\\lvert e \\right\\rangle$ respectively.\n\nMost importantly, the physical system under consideration must **exhibit\nquantum properties**. The presence of **discrete energy levels** is\nindeed one such property, so if we do build a device that stores energy\nin discrete values, we can suspect that it obeys the laws of quantum\nmechanics. Usually, one thinks of a quantum system as being at least as\nsmall as a molecule, but building something so small is technologically\nimpossible. It turns out that we don\\'t need to go to such small scales.\nIf we build a somewhat **small electric circuit using superconducting\nwires** and bring it to temperatures of about 10 mK, it becomes a\nquantum system with discrete energy levels.\n\nFinally, we must account for the fact that electrons in atoms have more\nstates available than just $\\left\\lvert g \\right\\rangle$ and\n$\\left\\lvert e \\right\\rangle$. In fact, the energy levels in an atom are\ninfinitely many. How do we guarantee that an electron does not escape to\nanother state that is neither of our hand-picked states? The transition\nbetween the ground and the excited state only happens when the electron\nabsorbs a photon (a particle of light) with energy\n$\\Delta E = E_1 - E_0$. To get to another state with energy $E_2$, the\nelectron would need to absorb a photon with energy $E_2 - E_1$ or\n$E_2-E_0$. In an atom, these energy differences are always different:\nthere is a **non-uniform spacing between the energy levels**. Therefore,\nif we limit ourselves to interacting with the atom using photons with\nenergy $\\Delta E$, we will not go beyond the states that define our\nqubit.\n\n![..](../demonstrations/sc_qubits/photon_absorb.png){.align-center\nwidth=\"60.0%\"}\n\nPhotons with a particular energy excite electrons\n\nLet\\'s then build the simplest superconducting circuit. We do not want\nthe circuit to warm up, or it will lose its quantum properties. Of all\nthe elements that an ordinary circuit may have, only two do not produce\nheat when they\\'re superconducting: *capacitors* and *inductors*.\nCapacitors are two parallel metallic plates that store electric charge.\nThey are characterized by their *capacitance* $C$, which measures how\nmuch charge they can store when connected to a given power source.\nInductors are wires shaped as a coil and store magnetic fields when a\ncurrent passes through. These magnetic fields, in turn, slow down\nchanging currents that pass through the inductor. They are described by\nan *inductance* $L$, which measures the strength of the magnetic field\nstored in the inductor at a fixed current. The simplest superconducting\ncircuit is, therefore, a capacitor connected to an inductor, also known\nas an LC circuit, as shown below:\n\n![..](../demonstrations/sc_qubits/LC_circuit.png){.align-center\nwidth=\"60.0%\"}\n\nSuperconducting LC circuit\n\nSadly, this simple circuit has a problem: the spacing between energy\nlevels is constant, which means identical photons will cause energy\ntransitions between many neighbouring pairs of states. This makes it\nimpossible to isolate just two specific states for our qubit.\n\n![..](../demonstrations/sc_qubits/anharmonic.png){.align-center\nwidth=\"60.0%\"}\n\nNon-uniform energy levels in an atom vs. uniform energy levels in a\nsuperconducting LC circuit\n\nBut there turns out to be a fix for the even spacing. Enter the\n*Josephson junction*. It consists of a very thin piece of an insulating\nmaterial placed between two superconducting metals. Why do we need this?\nIf it\\'s insulating, no current should go through it and our circuit\nshould stop working! Here\\'s where another famous quantum effect comes\ninto play: the *tunnel effect*. Due to the quantum-probabilistic\nbehaviour of their location, Cooper pairs can sometimes go through the\nJosephson junction, so that the current is reduced but not completely\nstopped. If we replace the inductor with one of these junctions, the\nenergy levels of the superconducting circuit become unevenly spaced,\nexactly as we wanted. We have built an artificial atom!\n\nThe transmon\n============\n\nMission accomplished? Not yet. We want our qubit to be useful for\nbuilding quantum computers. In short, this means that we need to\ninteract with the environment in a controlled way. A way to do this is\nto add a *gate capacitor* with capacitance $C_g$ to the artificial atom,\nso that it can receive external signals (photons, in our case). The\namount of charge $Q_g$ in this capacitor can be chosen by the operator,\nand it determines how strongly the circuit interacts with the\nenvironment.\n\n![..](../demonstrations/sc_qubits/JC_circuit.png){.align-center\nwidth=\"60.0%\"}\n\nCircuit with a Josephson junction and a gate capacitor\n\nBut we run into a problem again. Adding a gate capacitor messes with our\nuneven energy levels, which we worked so hard to obtain. The separation\nin energy levels depends on $Q_g,$ as shown below.\n\n![..](../demonstrations/sc_qubits/energy_levels.png){.align-center\nwidth=\"60.0%\"}\n\nFirst three energy levels (green, orange, purple) as a function of the\ncharge in the gate capacitor.\n\nThe problem with this dependence is that a small change in the gate\ncharge $Q_g$ can change the difference in energy levels significantly. A\nsolution to this issue is to work around the value $Q_g/2e = 1/2$, where\nthe levels are not too sensitive to changes in the gate charge. But\nthere is a more straightforward solution: the difference in energy\nlevels also depends on the in-circuit capacitance $C$ and the physical\ncharacteristics of the junction. If we can make the capacitance larger,\nthe energy level differences become less sensitive to $Q_g$. So all we\nneed to do is choose an appropriate capacitor.\n\n![..](../demonstrations/sc_qubits/levels_capacitance.png){.align-center\nwidth=\"100.0%\"}\n\nEnergy levels vs gate capacitor charge for different values of\nin-circuit capacitance.\n\nBut there is a price to be paid: making the in-circuit capacitance $C$\nlarger does reduce the sensitivity to the gate charge, but it also makes\nthe differences in energy levels more uniform. Does that make the\nJosephson junction pointless? Thankfully, the latter effect turns out to\nbe smaller than the former, so we can adjust the capacitance value and\npreserve some non-uniformity. The regime that has been proven ideal is\nknown as the **transmon regime**, and artificial atoms in this regime\nare called **transmons**. They have proven to be highly effective as\nqubits, and they are used in many applications nowadays. We can thus\nwork with the first two energy levels of the transmon, which we will\nalso denote $\\left\\lvert g \\right\\rangle$ and\n$\\left\\lvert e \\right\\rangle$, the ground and excited states\nrespectively. The energy difference between these states is known as the\n*energy gap* $E_a$. We can stimulate transitions using photons of\nfrequency $\\omega_a$, where\n\n$$E_a = \\hbar\\omega_a.$$\n\nWe have now partially satisfied Di Vincenzo\\'s first criterion of a\nwell-defined qubit, and we will discuss scalability later. A great\nfeature of superconducting qubits is that the second criterion is\nsatisfied effortlessly. Since the excited states in an artificial atom\nare short-lived and prefer to be on the ground state, all we have to do\nis wait for a short period. If the circuit is well isolated, it is\nguaranteed that all the qubits will be in the ground state with a high\nprobability after this short interval.\n\nMeasuring the circuit\\'s state\n==============================\n\nNow that we have finally fabricated our qubit, we need to understand how\nto manipulate it. The way to do this is to put the qubit inside an\n*optical cavity*, a metal box where we can contain electromagnetic\nwaves. Our focus will be on the so-called *Fabry-Perot* cavities. They\nconsist of two mirrors facing each other and whose rears are coated with\nan anti-reflecting material. Something surprising happens when we shine\na beam of light on a Fabry-Perot cavity of length $L$: electromagnetic\nwaves will only be transmitted when they have a wavelength $\\lambda$\nsuch that\n\n$$L = n\\lambda/2,$$\n\nwhere $n$ is an arbitrary positive integer. If this condition is not\nmet, most of the photons in the wave will be reflected away. Therefore,\nwe will have an electromagnetic field inside if we carefully tune our\nlight source to one of these wavelengths. For superconducting qubits, it\nis most common to use wavelengths in the microwave range.\n\n![..](../demonstrations/sc_qubits/fabry_perot.png){.align-center\nwidth=\"60.0%\"}\n\nThe Fabry-Perot Cavity rejects most of the red wave but allows all of\nthe blue wave, since an integer number of blue wavelengths fit exactly\nin the cavity.\n\nFollowing Di Vincenzo\\'s fifth criterion, let\\'s see how we can measure\nthe state of the qubit placed inside the cavity. To obtain information,\nwe need to shine light at a frequency $\\omega_r$ that the cavity lets\nthrough (recall that the frequency and the wavelength are related via\n$\\omega = 2\\pi c/\\lambda$, where $c$ is the speed of light). We may also\nchoose the frequency value $\\omega_r$ to be far from the transmon\\'s\nfrequency gap $\\omega_a$, so the qubit does not absorb the photons.\nNamely, the *detuning* $\\Delta$ needs to be large:\n\n$$\\Delta \\equiv \\left\\lvert \\omega_r - \\omega_a \\right\\rvert \\gg 1.$$\n\nWhat happens to the photons of this frequency that meet paths with the\nqubit? They are scattered by the circuit, as opposed to photons of\nfrequency $\\omega_a$, which get absorbed. Scattering counts as an\ninteraction, albeit a weak one, so the scattered photons contain some\ninformation about the qubit\\'s state. Indeed, the collision causes an\nexchange in momentum and energy. For light, this means that its\namplitude and phase will change slightly. If we carefully measure the\nproperties of the scattered light, we can distill the information about\nthe state of the qubit and measure its state.\n\nTo understand how this works in more detail, we need to do some hands-on\ncalculations. We will rely on the concept of a Hamiltonian; do read the\nblue box below if you need a refresher on the topic!\n\n::: {.container .alert .alert-block .alert-info}\n**Primer on Hamiltonians:** When a physical system is exposed to outside\ninfluences, it will change configurations. One way to describe these\nexternal interactions is through a mathematical object called a\n**Hamiltonian**, which represents the total energy on the system. In\nquantum mechanics, the Hamiltonian $\\hat{H}$ is a Hermitian matrix whose\neigenvalues represent the possible energies the system may have. The\nHamiltonian also tells us how an initial state changes in time. In\nquantum mechanics, this change is described by a differential equation\nknown as Schrodinger\\'s equation:\n\n$$i\\hbar \\frac{\\partial}{\\partial t}\\left\\lvert \\psi(t)\\right\\rangle = \\hat{H}\\left\\lvert \\psi(t)\\right\\rangle.$$\n\nWhen the Hamiltonian does not depend on time, this equation can be\nsolved exactly:\n\n$$\\left\\lvert \\psi(t)\\right\\rangle= \\exp(-i\\hat{H}t/\\hbar)\\left\\lvert \\psi(0)\\right\\rangle$$\n\nwhere $\\exp$ represents the matrix exponential. Don\\'t worry, there\\'s\nno need to know how to solve this equation or calculate matrix\nexponentials. Pennylane can do this for us using `ApproxTimeEvolution`.\n:::\n\nWe are given a Hamiltonian $\\hat{H}$ that describes the transmon and the\nphotons inside the cavity. The transmon is initially in its ground state\n$\\left\\lvert g \\right\\rangle,$ and the cavity starts without any photons\nin it, i.e., in the *vacuum state* denoted by\n$\\left\\lvert 0 \\right\\rangle$. According to Schrodinger\\'s equation, the\nstate of the cavity (transmon and photons system) evolves into\n$\\left\\lvert \\psi(t)\\right\\rangle= \\exp(-i\\hat{H}t/\\hbar)\\left\\lvert g \\right\\rangle\\left\\lvert 0 \\right\\rangle$\nafter a time $t$. What is the Hamiltonian that describes light of\namplitude $\\epsilon$ and frequency $\\omega_r$ incident on the cavity,\nwhen the detuning $\\Delta$ is large? Deriving the Hamiltonian is not an\neasy job, so we should trust physicists on this one! The Hamiltonian\nturns out to be\n\n$$\\hat{H}=\\hbar(\\omega_r I+\\chi\\hat{\\sigma}_z)\\otimes\\hat{N} + \\hbar\\epsilon I\\otimes \\hat{P},$$\n\nwhere $\\hat{N}$ counts the number of photons in the cavity, $\\hat{P}$ is\nthe photon momentum operator, and $\\epsilon$ is the amplitude of the\nelectromagnetic wave incident on the cavity. The shift $\\chi$ is a\nquantity that depends on the circuit and gate capacitances and the\ndetuning $\\Delta$.\n\nThe effect of this evolution can be calculated explicitly. Shining\nmicrowaves on the cavity gives us a *coherent state* of light contained\nin it, which is the state of light that lasers give out. Coherent states\nare completely determined by two quantities called $\\bar{x}$ and\n$\\bar{p}$ (these quantities are mathematically similar to the notions of\naverage position and average momentum, but are in fact physically\nconnected to the phase of the light), so we will denote them via\n$\\left\\lvert \\bar{x}, \\bar{p}\\right\\rangle$. For the state of the qubit\nand cavity system, we write the ket in the form\n$\\left\\lvert g \\right\\rangle \\left\\lvert \\bar{x}, \\bar{p}\\right\\rangle$.\nThe Hamiltonian above has (approximately) the following effect:\n\n$$\\left\\lvert g \\right\\rangle \\left\\lvert 0 \\right\\rangle \\rightarrow \\left\\lvert g \\right\\rangle \\left\\lvert \\epsilon t, (\\omega_r+\\chi)t \\right\\rangle,$$\n\n$$\\left\\lvert e \\right\\rangle \\left\\lvert 0 \\right\\rangle \\rightarrow \\left\\lvert e \\right\\rangle \\left\\lvert \\epsilon t, (\\omega_r-\\chi)t \\right\\rangle.$$\n\nConsequently, if the state of the qubit was initially the superposition\n$\\alpha \\left\\lvert g \\right\\rangle +\\beta \\left\\lvert e \\right\\rangle$,\nthen the qubit-cavity system would evolve to the state\n\n$$\\left\\lvert\\psi(t)\\right\\rangle=\\alpha \\left\\lvert g \\right\\rangle \\left\\lvert \\epsilon t, (\\omega_r+\\chi)t \\right\\rangle +\\beta \\left\\lvert e \\right\\rangle \\left\\lvert \\epsilon t, (\\omega_r-\\chi)t \\right\\rangle.$$\n\nIn general, this state represents an entangled state between the qubit\nand the cavity. So if we measure the state of the light trapped by the\ncavity, we can determine the qubit\\'s state as well.\n\nLet us see how this works in practice using PennyLane. The\n`default.gaussian` device allows us to simulate coherent states of\nlight. These states start implicitly in the vacuum (no photons) state.\nThe PennyLane function `qml.Displacement(x,0)` applies a *displacement\noperator*, which creates a coherent state\n$\\left\\lvert \\bar{x}, 0\\right\\rangle$. The rotation operator\n`qml.Rotation(phi)` rotates the state\n$\\left\\lvert \\bar{x}, 0\\right\\rangle$ in $(x, p)$ space. When applied\nafter a large displacement, it changes the value of $\\bar{x}$ only\nslightly, but noticeably changes the value of $\\bar{p}$ by shifting it\noff from zero, as shown in the figure:\n\n![..](../demonstrations/sc_qubits/phase_space.png){.align-center\nwidth=\"60.0%\"}\n\nTranslation and rotation in the position-momentum picture\n\nIt turns out that this sequence of operations implements the evolution\nof the cavity state exactly. Note that here we are taking $\\omega_r=0$,\nwhich simply corresponds to taking $\\omega_r$ as a reference frequency,\nso a rotation by angle $\\phi$ actually means a rotation by\n$\\omega_r+\\phi$. In PennyLane, the operations read:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import pennylane as qml\nfrom pennylane import numpy as np\nimport matplotlib.pyplot as plt\n\n# Call the default.gaussian device with 50 shots\ndev = qml.device(\"default.gaussian\", wires=1, shots=50)\n\n# Fix parameters\nepsilon, chi = 1.0, 0.1\n\n# Implement displacement and rotation and measure both X and P observables\n\n\n@qml.qnode(dev)\ndef measure_P_shots(time, state):\n qml.Displacement(epsilon * time, 0, wires=0)\n qml.Rotation((-1) ** state * chi * time, wires=0)\n return qml.sample(qml.P(0))\n\n\n@qml.qnode(dev)\ndef measure_X_shots(time, state):\n qml.Displacement(epsilon * time, 0, wires=0)\n qml.Rotation((-1) ** state * chi * time, wires=0)\n return qml.sample(qml.X(0))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"::: {.note}\n::: {.title}\nNote\n:::\n\nIt may be surprising to see the `default.gaussian` device being used\nhere, since it is most often used when we work with photonic systems.\nBut it is also valid to use it here, since we are modelling a\nmeasurement process that uses photons.\n:::\n\nWe measure the photon\\'s momentum at the end, since it allows us to\ndistinguish qubit states as long as we can resolve them. Let us plot for\nthree different durations of the microwave-cavity interaction. We will\nsimulate the measurement of 50 photons, which can inform us whether the\nqubit is in the ground or excited state:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 5))\nfig.suptitle(\"Position/momentum measurement\", fontsize=18)\nax1.scatter(measure_X_shots(1, 0), measure_P_shots(1, 0))\nax1.scatter(measure_X_shots(1, 1), measure_P_shots(1, 1))\nax2.scatter(measure_X_shots(3, 0), measure_P_shots(3, 0))\nax2.scatter(measure_X_shots(3, 1), measure_P_shots(3, 1))\nax3.scatter(measure_X_shots(5, 0), measure_P_shots(5, 0))\nax3.scatter(measure_X_shots(5, 1), measure_P_shots(5, 1))\nax1.set_title(r\"$t=1/\\epsilon$\", fontsize=16)\nax2.set_title(r\"$t=3/\\epsilon$\", fontsize=16)\nax3.set_title(r\"$t=5/\\epsilon$\", fontsize=16)\nax1.set_ylabel(\"Momentum\", fontsize=16)\nax2.set_xlabel(\"Position\", fontsize=16)\nplt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the above, the blue and orange dots represent qubits which we can\ninfer to be in the state $\\left\\lvert g \\right\\rangle$ and\n$\\left\\lvert e \\right\\rangle$ respectively.\n\nWe see that the longer we shine microwaves on the cavity, the greater\nour ability to resolve the momentum change, making for an equally good\nmeasurement of the qubit\\'s state. However, this poses a problem: being\na relatively large object, the state of the qubit is rather short-lived\ndue to decoherence. Therefore, taking a long time to make the\nmeasurement introduces additional inaccuracies: the qubits may lose\nquantum properties due to decoherence before we even finish measuring!\nAn outstanding challenge for superconducting qubit technologies is to\nperform measurements as fast as possible, in times well below the\ndecoherence time.\n\nSuperconducting single-qubit gates\n==================================\n\nWe have seen that shining light with detuning $\\Delta \\gg 1$ is used to\nperform indirect measurements. A rather different choice,\n$\\omega_r =\\omega_a$ ($\\Delta=0$), allows us to manipulate the state of\nthe qubit. But does the Fabry-Perot cavity transmit these photons if\ntheir wavelength does not allow it? We must emphasize that the cavity\nreflects only the vast majority of photons, but not all of them. If we\ncompensate by increasing the radiation intensity, some photons will\nstill be transmitted into the cavity and be absorbed by the\nsuperconducting qubit.\n\nIf we shine a coherent state light with frequency $\\omega_a$ on the\ncavity and phase $\\phi$ at the position of the qubit, then the\nHamiltonian for the artificial atom is\n\n$$\\hat{H}=\\hbar\\Omega_R(\\hat{\\sigma}_{x}\\cos\\phi + \\hat{\\sigma}_{y}\\sin\\phi).$$\n\nHere, $\\Omega_R$ is a special frequency called the *Rabi frequency*,\nwhich depends on the average electric field in the cavity and the size\nof the superconducting qubit. With this Hamiltonian, we can implement a\nuniversal set of single-qubit gates since $\\phi=0$ implements an\n$X$-rotation and $\\phi=\\pi/2$ applies a $Y$-rotation.\n\nLet us check this using PennyLane. For qubits, we can define\nHamiltonians using `qml.Hamiltonian` and evolve an initial state using\n`ApproxTimeEvolution`:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from pennylane.templates import ApproxTimeEvolution\n\ndev2 = qml.device(\"default.qubit\", wires=1)\n\n# Implement Hamiltonian evolution given phase phi and time t, from a given initial state\n@qml.qnode(dev2)\ndef H_evolve(state, phi, time):\n\n if state == 1:\n qml.PauliX(wires=0)\n\n coeffs = [np.cos(phi), np.sin(phi)]\n ops = [qml.PauliX(0), qml.PauliY(0)]\n Ham = qml.Hamiltonian(coeffs, ops)\n ApproxTimeEvolution(Ham, time, 1)\n return qml.state()\n\n\n# Implement X rotation exactly\n@qml.qnode(dev2)\ndef Sc_X_rot(state, phi):\n\n if state == 1:\n qml.PauliX(wires=0)\n\n qml.RX(phi, wires=0)\n return qml.state()\n\n\n# Implement Y rotation exactly\n@qml.qnode(dev2)\ndef Sc_Y_rot(state, phi):\n\n if state == 1:\n qml.PauliX(wires=0)\n\n qml.RY(phi, wires=0)\n return qml.state()\n\n\n# Print to compare results\n\nprint(\"State |0>:\")\n\nprint(\n \"X-rotated by pi/3: {}; Evolved for phi=0, t=pi/6: {}\".format(\n Sc_X_rot(0, np.pi / 3).round(2), H_evolve(0, 0, np.pi / 6).round(2)\n )\n)\nprint(\n \"Y-rotated by pi/3: {}; Evolved for phi=pi/2, t=pi/6: {}\\n\".format(\n Sc_Y_rot(0, np.pi / 3).round(2), H_evolve(0, np.pi / 2, np.pi / 6).round(2)\n )\n)\n\nprint(\"State |1>:\")\nprint(\n \"X-rotated by pi/3: {}; Evolved for phi=0, t=pi/6: {}\".format(\n Sc_X_rot(1, np.pi / 3).round(2), H_evolve(1, 0, np.pi / 6).round(2)\n )\n)\nprint(\n \"Y-rotated by pi/3: {}; Evolved for phi=pi/2, t=pi/6: {}\\n\".format(\n Sc_Y_rot(1, np.pi / 3).round(2), H_evolve(1, np.pi / 2, np.pi / 6).round(2)\n )\n)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Thus, for a particular choice of angle, we have verified that this\nHamiltonian implements rotations around the X and Y axes. We can do this\nfor any choice of angle, where we see that the time interval needed for\na rotation by an angle $\\theta$ is $t=2\\theta/\\Omega_R.$ This time can\nbe controlled simply by turning the source of microwaves on and off.\n\nThe typical times in which a single-qubit gate is executed are in the\norder of the nanoseconds, making superconducting quantum computers the\nfastest ones out there. Why do they have this intrinsic advantage? The\nreason is that the Rabi frequency $\\Omega_R$, which grows with the size\nof the qubit and the magnitude of the electric field, is extremely high.\nWe have the technology to make very small cavities, which means we can\npack strong electric fields in a small region. Moreover, superconducting\nqubits are billions of times larger than other qubits, such as atoms.\nThe drawback is that superconducting qubit technology would be\nimpossible without these extremely high speeds: large qubits are\nextremely short-lived, so we are constrained to find the quickest ways\nto perform all quantum operations.\n\nTwo-qubit gates\n===============\n\nOne of the main challenges in all realizations of quantum computers is\nbuilding two-qubit gates, needed to satisfy Di Vincenzo\\'s fourth\ncriterion in full. An advantage of superconducting technology is the\nvariety of options to connect qubits with each other. There are many\noptions for this connection: do we just connect the two qubits with a\nsuperconducting wire, do we just put them in the same cavity? One of the\nbest ways is via *capacitative coupling*, where we connect two transmons\nthrough a wire and *coupling capacitor*.\n\n![..](../demonstrations/sc_qubits/capacitative.png){.align-center\nwidth=\"60.0%\"}\n\nTwo transmons connected through a coupling capacitor\n\nAs we will see, this capacitor helps us have a controlled interaction\nbetween qubits. When two **identical** transmons are connected through a\ncoupling capacitor, the Hamiltonian for the system of two qubits reads\n\n$$\\hat{H}=\\frac{\\hbar J}{2} (\\sigma^{x}_1\\sigma^{x}_2+\\sigma^{y}_1\\sigma^{y}_2),$$\n\nwhere $J$ depends on the coupling capacitance and the characteristics of\nboth circuits. Note that since the transmons are identical, they have\nthe same energy gap. The Hamiltonian $\\hat{H}$ allows us to implement\nthe two-qubit $iSWAP$ gate\n\n$$\\begin{aligned}\niSWAP = \\left( \\begin{array}{cccc} 1 & 0 & 0 & 0 \\\\ 0 & 0 & i & 0 \\\\ 0 & i & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\end{array} \\right)\n\\end{aligned}$$\n\nwhen applied for a time $t=3\\pi/2J$, as shown with the following\nPennyLane code:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"dev3 = qml.device(\"default.qubit\", wires=2)\n\n# Define Hamiltonian\ncoeffs = [0.5, 0.5]\nops = [qml.PauliX(0) @ qml.PauliX(1), qml.PauliY(0) @ qml.PauliY(1)]\n\nTwo_qubit_H = qml.Hamiltonian(coeffs, ops)\n\n# Implement Hamiltonian evolution for time t and some initial computational basis state\n@qml.qnode(dev3)\ndef Sc_ISWAP(basis_state, time):\n qml.templates.BasisStatePreparation(basis_state, wires=range(2))\n ApproxTimeEvolution(Two_qubit_H, time, 1)\n return qml.state()\n\n\n# Implement ISWAP exactly\n@qml.qnode(dev3)\ndef iswap(basis_state):\n qml.templates.BasisStatePreparation(basis_state, wires=range(2))\n qml.ISWAP(wires=[0, 1])\n return qml.state()\n\n\n# Print to compare results\n\nprint(\"State |0>|0>:\")\nprint(\n \"Evolved for t=3*pi/2: {}; Output of ISWAP gate: {}\\n \".format(\n Sc_ISWAP([0, 0], 3 * np.pi / 2).round(2), iswap([0, 0]).round(2)\n )\n)\n\nprint(\"State |0>|1>:\")\nprint(\n \"Evolved for t=3*pi/2: {}; Output of ISWAP gate: {}\\n \".format(\n Sc_ISWAP([0, 1], 3 * np.pi / 2).round(2), iswap([0, 1]).round(2)\n )\n)\n\nprint(\"State |1>|0>:\")\nprint(\n \"Evolved for t=3*pi/2: {}; Output of ISWAP gate: {}\\n \".format(\n Sc_ISWAP([1, 0], 3 * np.pi / 2).round(2), iswap([1, 0]).round(2)\n )\n)\n\nprint(\"State |1>|1>:\")\nprint(\n \"Evolved for t=3*pi/2: {}; Output of ISWAP gate: {}\\n \".format(\n Sc_ISWAP([1, 1], 3 * np.pi / 2).round(2), iswap([1, 1]).round(2)\n )\n)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To allow for universal computation, we must be able to build the `CNOT`\ngate by using only the `ISWAP` gate and any number of single-qubit\ngates. The following quantum circuit diagram depicts how we can achieve\nthis.\n\n![..](../demonstrations/sc_qubits/circuit.png){.align-center\nwidth=\"85.0%\"}\n\nCircuit to obtain the CNOT gate from the ISWAP gate\n\nWe can verify that the circuit above gives us the `CNOT` gate up to a\nglobal phase using PennyLane:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def cnot_with_iswap():\n qml.RZ(-np.pi / 2, wires=0)\n qml.RX(np.pi / 2, wires=1)\n qml.RZ(np.pi / 2, wires=1)\n qml.ISWAP(wires=[0, 1])\n qml.RX(np.pi / 2, wires=0)\n qml.ISWAP(wires=[0, 1])\n qml.RZ(np.pi / 2, wires=1)\n\n\n# Get matrix of circuit above\nmatrix = qml.matrix(cnot_with_iswap)()\n\n# Multiply by a global phase to obtain CNOT\n(np.exp(1j * np.pi / 4) * matrix).round(2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the code above, we assumed that we can switch the interaction on and\noff to control its duration. How do we do this without physically\ntampering with the qubits? The truth is that we can never switch the\ninteraction off completely, but we can weaken it greatly by changing the\ncharacteristics of one of the qubits. For example, if we change the\ninductance in one of the circuits to be much different from the other,\nthe interaction strength $J$ in the Hamiltonian will be almost zero.\n\nThis strategy, however, begs another question: how can we change the\ncharacteristics of the circuit elements on-demand? One possibility is to\nuse **flux-tunable qubits**, also known as superconducting quantum\ninterference devices (SQUIDs). They use two parallel Josephson junctions\nplaced around each circuit, a setup that allows us to change the\ninductance of one qubit using an external magnetic field. This\narchitecture, although fast, requires further interaction with the\nqubit, so there\\'s some probability of unintentionally changing its\nstate.\n\n![..](../demonstrations/sc_qubits/squid.png){.align-center\nwidth=\"60.0%\"}\n\nSQUID architecture surrounding a transmon\n\nAnother option is to use **all-microwave gates**. In this scenario, we\nplace two **different** transmons in a single cavity, and shine\nmicrowaves that can be absorbed by the second qubit. The first qubit\nwill scatter the photons, and the other will absorb them, causing a\nsimilar effect to that of the qubit-cavity system in the case of\nmeasurement. This means that we can entangle the two qubits. When the\nfirst qubit receives a microwave at the frequency that stimulates the\nsecond qubit, one can show that the (simplified) Hamiltonian is given by\n\n$$\\hat{H}=\\hbar \\tilde{\\Omega} (\\sigma^{z}_1\\sigma^{x}_2\\cos\\phi+\\sigma^{z}_1\\sigma^{y}_2\\sin\\phi),$$\n\nwhere $\\phi$ is the phase of the wave. As promised, we can obtain an\nentangled state by concatenating the evolution under this Hamiltonian\nfor a time $t=\\tfrac{\\pi}{4\\Omega}$ with $R_x$ and $R_y$ rotations and a\n`qml.Hadamard` gate:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"@qml.qnode(dev3)\ndef H_evolve(state, phi, time):\n # Prepare initial state\n qml.templates.BasisStatePreparation(state, wires=range(2))\n # Define Hamiltonian\n coeffs = [np.cos(phi), np.sin(phi)]\n ops = [qml.PauliZ(0) @ qml.PauliX(1), qml.PauliZ(0) @ qml.PauliY(1)]\n Ham = qml.Hamiltonian(coeffs, ops)\n # Combine Hamiltonian evolution with single-qubit gates\n qml.Hadamard(wires=0)\n qml.RX(-np.pi / 2, wires=1)\n ApproxTimeEvolution(Ham, time, 1)\n qml.RZ(-np.pi / 2, wires=0)\n return qml.state()\n\n\n# Verify that we return maximally entangled state up to a global phase\n(np.exp(-1j * np.pi / 4) * H_evolve([0, 0], 0, np.pi / 4)).round(3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Although this method does not affect the qubit\\'s state much, these\ngates are slower than those built using flux-tuning, since the Rabi\nfrequency for this interaction turns out to be smaller.\n\n::: {.container .alert .alert-block .alert-info}\n**Historical note:** In the literature, you may find some proper names\nfor particular types of coupled transmons. One of the most common is the\n**xmon**, which are transmons coupled with a \\\"+\\\" shaped capacitor. A\nfurther improvement over the xmon is the **gmon**, which adds an\nadditional inductor to the coupling to better switch interactions on and\noff. Many more architectures have been proposed since the introduction\nof the xmon and the gmon, so we have reached a point where it is better\nto avoid getting lost in names. Understanding the basic principles\nintroduced above will make us go a long way!\n:::\n\nThe state of the art\n====================\n\nSuperconducting qubits are a force to be reckoned with as practical\nimplementations of quantum computers. Nonetheless, there are still some\ntechnological challenges preventing them from scaling further. A glaring\nissue is that we need to keep the transmons at very low temperatures,\nwhich requires the use of large cryogenic devices known as *dilution\nrefrigerators*. However, many quantum computing technologies need to use\ncryogenic devices for different reasons. In the future, other quantum\ntechnologies may bypass the use of low temperatures, but superconducting\nqubits may not be so lucky, since they are constrained by the laws of\nphysics that allow for superconductivity.\n\nIn terms of Di Vincenzo\\'s criteria, the long coherence times required\nby the third criterion have been rather hard to achieve. Superconducting\ncircuits are large compared to other quantum systems, so their\ninteraction with the environment is difficult to control. As a\nconsequence, the excited state lasts for about 1 micro-second before\ndecaying back to the ground state. Current single-qubit gates are\nacceptable since they can be applied in a matter of nanoseconds, thanks\nto our ability to manufacture very small cavities. Problems arise,\nhowever, when we want to perform precise measurements of the qubit.\nWe\\'ve already seen that taking a longer time to perform a measurement\ngives us better precision. But there is an additional issue: the\nHamiltonian we wrote in the measurement section is only valid when the\nnumber of photons in the cavity does not exceed some critical number.\nThis upper bound on the photons sets additional constraints: we will\nneed longer times to resolve the state, since we have few photons\navailable to us.\n\nSpeeding up measurements without losing precision is a hot research\ntopic in superconductor quantum computing. The primary approach has been\nto make the most out of the limited number of photons we have by\nreducing all possible environmental noise. Currently, we can perform\nmeasurements in about 50 nanoseconds with 1% error. However, since\nfrequent measurements are needed for error correction, better precision\nand shorter times are required to scale our architectures further.\n\nAn additional challenge is the execution of the multi-qubit gates, which\nare currently ten times slower than single-qubit gates. One contender to\nthe fastest two-qubit gate is used by Google, where the qubits are\ncoupled with a capacitor and a SQUID. The net effect is a quick\nflux-tunable qubit, where the coupling $J$ is changed by using a\nmagnetic flux that goes through the coupling SQUID. While slower, IBM\nprefers to use all-microwave gates to increase coherence times. Both\napproaches have the problem of *frequency crowding*: if we interconnect\ntoo many qubits together inside a cavity, they may start to have similar\nenergy gaps. In that case, we may manipulate qubits that we did not\nintend to. The problem can be somewhat addressed by changing the\ngeometry in which the qubits are connected[^1]. However, much more work\nneeds to be done to address this scalability issue.\n\nConclusion\n==========\n\nSuperconducting quantum computing has gained momentum in the last decade\nas a leading competitor in the race for building a functional quantum\ncomputer. It is based on artificial versions of atomic systems done\nusing superconducting circuits, which allows for versatility and\ncontrol. They have been easy to scale so far, but increasing the qubit\ncoherence time and the speed of quantum operations and measurements is\nessential to scaling this technology further. This has motivated so many\napproaches for gates and measurement that we could not possibly cover\nthem all in one demo. Do check the literature below if you\\'d like to\nlearn more!\n\nReferences\n==========\n\nAbout the author\n================\n\n[^1]: [\\\"The IBM Quantum heavy hex\n lattice\\\"](https://research.ibm.com/blog/heavy-hex-lattice). IBM\n Research Blog. Retrieved 2022-03-15\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 0
}