1"use strict"; 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aaea2def-2728-538a-b183-6d1249750ed9")}catch(e){}}(); 3(self.webpackChunkpennylane_website=self.webpackChunkpennylane_website||[]).push([[4741],{91413:function(e,t,a){a.r(t),a.d(t,{Head:function(){return x},default:function(){return v}});var n=a(2784),i=a(45392);function o(e){const t=Object.assign({p:"p",a:"a",strong:"strong",div:"div"},(0,i.ah)(),e.components);return n.createElement(n.Fragment,null,n.createElement(t.p,null,n.createElement(t.a,{href:"https://pennylane.ai/compilation"},"Quantum compilation")," is the process of transforming quantum programs.\nThe main goal is to translate a higher-level program description to a set\nof low-level instructions that a quantum device can execute.\nThis shall be done in such a way that quantum resources like\ncircuit depth or the number of certain types of gates are optimized. To learn more, explore the ",n.createElement(t.a,{href:"https://pennylane.ai/topics/quantum-compilation"},"PennyLane Guide to Quantum Compilation"),"."),"\n",n.createElement(t.p,null,n.createElement(t.strong,null,"Example")),"\n",n.createElement(t.p,null,"Consider the following quantum circuit containing T, Hadamard, CNOT and Toffoli gates."),"\n",n.createElement(t.p,null,n.createElement(t.div,{dangerouslySetInnerHTML:{__html:'<span\n class="gatsby-resp-image-wrapper"\n style="position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px; "\n >
3\n <span\n class="gatsby-resp-image-background-image"\n style="padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAA9hAAAPYQGoP6dpAAABG0lEQVQoz62S2Y6DMAxF+/9fxRfwWihrpbZQQGWpoOweHWvC0OnjTCTLuXZ8c+3kIN9rXVf5yzL1BzYGTNMkl8tFbRxHxXgTA5vz7PfYkB7meZa+7zWZZZm4rquWJIlYliW3203x8XiUoiikbVsZhkFs21aj9vV6/RDuZUMeRZEaFzwej+2iPM+1uOs6WZZFScGGaGuZJERYXdfieZ4EQSD3+13CMJSmaeR6vUqapto2SsFxHIvv+9tYNoUQEjSEHIIIQoqez6degGpIyeHJEf8g3L8QpBRgRjkLlbTKCBzHUQ8m/tEyRcxj/ygUMTMeoKoqHQMKT6fTmydOnvpN4e9vw3yw/ZegbRSVZSnn81k9mPi+w7dX/q+P/QU8AwIRFdRP2wAAAABJRU5ErkJggg==\'); background-size: cover; display: block;"\n ></span>\n <img\n class="gatsby-resp-image-image"\n alt="Quantum tape constructed from tape = qml.tape.QuantumScript([qml.Hadamard(0), qml.Hadamard(1), qml.Hadamard(2), qml.CNOT((0, 1)), qml.CNOT((1, 2)), qml.T(0), qml.T(1), qml.T(2), qml.Toffoli([0, 1, 2])], [])"\n title="Quantum tape constructed from tape = qml.tape.QuantumScript([qml.Hadamard(0), qml.Hadamard(1), qml.Hadamard(2), qml.CNOT((0, 1)), qml.CNOT((1, 2)), qml.T(0), qml.T(1), qml.T(2), qml.Toffoli([0, 1, 2])], [])"\n src="/static/e152901ddc338b4e1bb4bcf9ee0e46f1/f058b/original_circuit.png"\n srcset="/static/e152901ddc338b4e1bb4bcf9ee0e46f1/c26ae/original_circuit.png 158w,\n/static/e152901ddc338b4e1bb4bcf9ee0e46f1/6bdcf/original_circuit.png 315w,\n/static/e152901ddc338b4e1bb4bcf9ee0e46f1/f058b/original_circuit.png 630w,\n/static/e152901ddc338b4e1bb4bcf9ee0e46f1/5a190/original_circuit.png 800w"\n sizes="(max-width: 630px) 100vw, 630px"\n style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;"\n loading="lazy"\n decoding="async"\n />\n </span>'}})),"\n",n.createElement(t.p,null,"We may compile this circuit to a different basis gate set to the Clifford + T gate set, i.e. containing only S, T, Hadamard and CNOT."),"\n",n.createElement(t.p,null,n.createElement(t.div,{dangerouslySetInnerHTML:{__html:'<span\n class="gatsby-resp-image-wrapper"\n style="position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px; "\n >
3\n <span\n class="gatsby-resp-image-background-image"\n style="padding-bottom: 18.9873417721519%; position: relative; bottom: 0; left: 0; background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAoUlEQVQY01WQWQ6DMBBDuf8dI/gBQVjDvrt6U4HaSNbsHk+iaZoUQtBxHDrP87XXdWldVwPxfd/atk37vr8gz2xZloKHFxEkSaK2bW0YomVZzKcJQES9aRpDVVXy3ivPc7NFUajv+y8hQZZl6rrurwGfwbquLRfHsdI0tV7nnFlqzwUo5opoHEdTwanIh4Rt+CzBgic3DIMRzfNsin6/CcIPy2szEuxvpRwAAAAASUVORK5CYII=\'); background-size: cover; display: block;"\n ></span>\n <img\n class="gatsby-resp-image-image"\n alt="Expanded circuit from (tape_expanded,) , _ = qml.compile(tape, basis_set=["T", "S", "Hadamard", "CNOT"])"\n title="Expanded circuit from (tape_expanded,) , _ = qml.compile(tape, basis_set=["T", "S", "Hadamard", "CNOT"])"\n src="/static/e70278a8e5c90e6fdb51dac22cfeb3d0/f058b/expanded_circuit.png"\n srcset="/static/e70278a8e5c90e6fdb51dac22cfeb3d0/c26ae/expanded_circuit.png 158w,\n/static/e70278a8e5c90e6fdb51dac22cfeb3d0/6bdcf/expanded_circuit.png 315w,\n/static/e70278a8e5c90e6fdb51dac22cfeb3d0/f058b/expanded_circuit.png 630w,\n/static/e70278a8e5c90e6fdb51dac22cfeb3d0/40601/expanded_circuit.png 945w,\n/static/e70278a8e5c90e6fdb51dac22cfeb3d0/78612/expanded_circuit.png 1260w,\n/static/e70278a8e5c90e6fdb51dac22cfeb3d0/8079d/expanded_circuit.png 2100w"\n sizes="(max-width: 630px) 100vw, 630px"\n style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;"\n loading="lazy"\n decoding="async"\n />\n </span>'}})),"\n",n.createElement(t.p,null,"There are some optimizations we can perform by hand, e.g. T gates commute through the control wires of CNOT gates, and $T^2 = S$.\nWe could thereby remove two T gates, which are often considered expensive in fault tolerant settings (see e.g. ",n.createElement(t.a,{href:"https://pennylane.ai/blog/2025/01/optimizing-with-op-t-mize-dataset"},"this blog post on T gate optimization"),").\nThere are more elaborate passes yielding, for example, the following circuit with significantly lower T-gate count."),"\n",n.createElement(t.p,null,n.createElement(t.div,{dangerouslySetInnerHTML:{__html:'<span\n class="gatsby-resp-image-wrapper"\n style="position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px; "\n >
3\n <span\n class="gatsby-resp-image-background-image"\n style="padding-bottom: 20.88607594936709%; position: relative; bottom: 0; left: 0; background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAAoElEQVQY02VP7QrEIAzb+z+jiD82nGNfbrpv7ZGAO44TSps2TWqVc5bruqTvexnHUZ7nkZQSM+K+7xcjhxDkPE/BHvC+77KuKzNehcFxHBS01krbtoyu69iHWVmA+DzP7KOHvG0b+TjmT7BpGtFai1JKjDE0cM6xX0yAwa3rmvUwDJxP0/QVhHOMkd/BBSXgCiKu8N4T4zLU4C/L8oMh+AE3+DMP++rLagAAAABJRU5ErkJggg==\'); background-size: cover; display: block;"\n ></span>\n <img\n class="gatsby-resp-image-image"\n alt="Optimized circuit with very different structure"\n title="Optimized circuit with very different structure"\n src="/static/ffdb889d97337796e1da9dfb51b24a8c/f058b/optimized_circuit.png"\n srcset="/static/ffdb889d97337796e1da9dfb51b24a8c/c26ae/optimized_circuit.png 158w,\n/static/ffdb889d97337796e1da9dfb51b24a8c/6bdcf/optimized_circuit.png 315w,\n/static/ffdb889d97337796e1da9dfb51b24a8c/f058b/optimized_circuit.png 630w,\n/static/ffdb889d97337796e1da9dfb51b24a8c/40601/optimized_circuit.png 945w,\n/static/ffdb889d97337796e1da9dfb51b24a8c/78612/optimized_circuit.png 1260w,\n/static/ffdb889d97337796e1da9dfb51b24a8c/a88f6/optimized_circuit.png 1900w"\n sizes="(max-width: 630px) 100vw, 630px"\n style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;"\n loading="lazy"\n decoding="async"\n />\n </span>'}})))}var l=function(e){void 0===e&&(e={});const{wrapper:t}=Object.assign({},(0,i.ah)(),e.components);return t?n.createElement(t,e,n.createElement(o,e)):o(e)},c=a(56694),r=a(82256),d=a(28546),s=a(2409),m=a(76741),p=a(9619),u=a(86165),g=a(95692),b=a(19948),f=a(45051),A=a(52322);const h={Notes:u.Z,Footnotes:s.Z,MarkdownText:p.Z,PermaLink:b.Z,a:m.Z,p:g.Z};function w(e){let{data:t,children:a}=e;const{mdx:n}=t,o=null==n?void 0:n.frontmatter,l=null==n?void 0:n.tableOfContents;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(c.Z,{pageTitle:(null==o?void 0:o.title)||""}),(0,A.jsx)(d.Z,{mainSection:(0,A.jsxs)("section",{className:"glossary-item-container w-[830px]",children:[(null==o?void 0:o.title)&&(0,A.jsxs)("h1",{children:[o.title," ",(0,A.jsx)(b.Z,{title:o.title})]}),(0,A.jsx)(i.Zo,{components:h,children:a})]}),sidebarSection:null!=l&&l.items&&l.items instanceof Array&&l.items.length>0?(0,A.jsx)(r.Z,{linksList:null==l?void 0:l.items,contentTitle:"Glossary"}):void 0})]})}function v(e){return n.createElement(w,e,n.createElement(l,e))}const x=e=>{var t,a,n,i,o,l,c,r,d,s;let{data:m}=e;return(0,A.jsx)(f.Z,{title:null!==(t=m.mdx)&&void 0!==t&&null!==(a=t.frontmatter)&&void 0!==a&&a.meta_title?m.mdx.frontmatter.meta_title:(null===(n=m.mdx)||void 0===n||null===(i=n.frontmatter)||void 0===i?void 0:i.title)||"",image:(null===(o=m.mdx)||void 0===o||null===(l=o.frontmatter)||void 0===l?void 0:l.meta_image)||"",description:(null===(c=m.mdx)||void 0===c||null===(r=c.frontmatter)||void 0===r?void 0:r.meta_description)||"",pathname:"/glossary/"+(null===(d=m.mdx)||void 0===d||null===(s=d.frontmatter)||void 0===s?void 0:s.slug)})}}}]); 4//# sourceMappingURL=component---src-templates-glossary-glossary-tsx-content-file-path-home-runner-work-pennylane-ai-react-pennylane-ai-react-apps-pennylane-website-content-glossary-quantum-compilation-index-mdx-eb5e16601e9feffca913.js.map 5//# debugId=aaea2def-2728-538a-b183-6d1249750ed9
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.