|
36 | 36 |
|
37 | 37 | <section id="built-in-quantum-instructions">
|
38 | 38 | <h1>Built-in quantum instructions<a class="headerlink" href="#built-in-quantum-instructions" title="Link to this heading">¶</a></h1>
|
39 |
| -<p>This section describes built-in non-unitary operations.</p> |
| 39 | +<p>This section describes built-in operations on qubits, including non-unitary ones.</p> |
40 | 40 | <section id="initialization">
|
41 | 41 | <h2>Initialization<a class="headerlink" href="#initialization" title="Link to this heading">¶</a></h2>
|
42 | 42 | <p>The statement <code class="docutils literal notranslate"><span class="pre">reset</span> <span class="pre">qubit|qubit[];</span></code> resets a qubit or quantum register to the state
|
@@ -105,6 +105,42 @@ <h2>Measurement<a class="headerlink" href="#measurement" title="Link to this hea
|
105 | 105 | </figcaption>
|
106 | 106 | </figure>
|
107 | 107 | </section>
|
| 108 | +<section id="explicit-no-operation"> |
| 109 | +<span id="nop"></span><h2>Explicit no-operation<a class="headerlink" href="#explicit-no-operation" title="Link to this heading">¶</a></h2> |
| 110 | +<div class="versionadded"> |
| 111 | +<p><span class="versionmodified added">Added in version 3.2: </span>The entire <code class="docutils literal notranslate"><span class="pre">nop</span></code> directive.</p> |
| 112 | +</div> |
| 113 | +<p>The statement <code class="docutils literal notranslate"><span class="pre">nop</span> <span class="pre"><qubits>;</span></code> is an explicit no-operation on all mentioned qubits, but marks them as being “used” within a scope. |
| 114 | +<code class="docutils literal notranslate"><span class="pre"><qubits></span></code> is a comma-separated list of qubit or qubit-register operands.</p> |
| 115 | +<p>In the global scope this has no effect on the program operation, though a compiler must still validate the arguments. |
| 116 | +This has a particularly important effect on <span class="xref std std-ref">boxed scopes</span>; a <code class="docutils literal notranslate"><span class="pre">nop</span></code> counts as a “use” of the qubit within the <code class="docutils literal notranslate"><span class="pre">box</span></code>, causing the qubit to be synchronized with the rest of the box at entry and exit.</p> |
| 117 | +<p>A <code class="docutils literal notranslate"><span class="pre">nop</span></code> statement is valid in exactly the places that a gate-call statement is valid. |
| 118 | +The operands of a <code class="docutils literal notranslate"><span class="pre">nop</span></code> statement must all be in scope and be of type <code class="docutils literal notranslate"><span class="pre">qubit</span></code> or <code class="docutils literal notranslate"><span class="pre">qubit[n]</span></code> for any non-negative integer <code class="docutils literal notranslate"><span class="pre">n</span></code>.</p> |
| 119 | +<p>For example:</p> |
| 120 | +<div class="highlight-qasm3 notranslate"><div class="highlight"><pre><span></span><span class="kn">include</span><span class="w"> </span><span class="s">"stdgates.inc"</span><span class="p">;</span> |
| 121 | + |
| 122 | +<span class="kt">stretch</span><span class="w"> </span><span class="n">s</span><span class="p">;</span> |
| 123 | +<span class="k">box</span><span class="w"> </span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="w"> </span><span class="p">{</span> |
| 124 | +<span class="w"> </span><span class="c1">// Qubits $0 and $1 are explicitly used by the `cx`.</span> |
| 125 | +<span class="w"> </span><span class="n">cx</span><span class="w"> </span><span class="l">$0</span><span class="p">,</span><span class="w"> </span><span class="l">$1</span><span class="p">;</span> |
| 126 | + |
| 127 | +<span class="w"> </span><span class="c1">// Qubit $2 must be synchronized to $0 and $1 at the start</span> |
| 128 | +<span class="w"> </span><span class="c1">// and end of the box, but has no defined operations within</span> |
| 129 | +<span class="w"> </span><span class="c1">// the box.</span> |
| 130 | +<span class="w"> </span><span class="n">nop</span><span class="w"> </span><span class="l">$2</span><span class="p">;</span> |
| 131 | + |
| 132 | +<span class="w"> </span><span class="c1">// More than one qubit can be specified in the list. It is</span> |
| 133 | +<span class="w"> </span><span class="c1">// not an error to duplicate qubits, nor to ``nop`` a qubit</span> |
| 134 | +<span class="w"> </span><span class="c1">// with explicit operations in this scope.</span> |
| 135 | +<span class="w"> </span><span class="n">nop</span><span class="w"> </span><span class="l">$3</span><span class="p">,</span><span class="w"> </span><span class="l">$0</span><span class="p">;</span> |
| 136 | + |
| 137 | +<span class="w"> </span><span class="c1">// The ``nop`` statement can have zero operands, and this</span> |
| 138 | +<span class="w"> </span><span class="c1">// has no observable effect at all.</span> |
| 139 | +<span class="w"> </span><span class="n">nop</span><span class="p">;</span> |
| 140 | +<span class="p">}</span> |
| 141 | +</pre></div> |
| 142 | +</div> |
| 143 | +</section> |
108 | 144 | </section>
|
109 | 145 |
|
110 | 146 |
|
@@ -135,6 +171,7 @@ <h3>Navigation</h3>
|
135 | 171 | <li class="toctree-l2 current"><a class="current reference internal" href="#">Built-in quantum instructions</a><ul>
|
136 | 172 | <li class="toctree-l3"><a class="reference internal" href="#initialization">Initialization</a></li>
|
137 | 173 | <li class="toctree-l3"><a class="reference internal" href="#measurement">Measurement</a></li>
|
| 174 | +<li class="toctree-l3"><a class="reference internal" href="#explicit-no-operation">Explicit no-operation</a></li> |
138 | 175 | </ul>
|
139 | 176 | </li>
|
140 | 177 | <li class="toctree-l2"><a class="reference internal" href="classical.html">Classical instructions</a></li>
|
|
0 commit comments