Skip to content

Commit 664eb8e

Browse files
committed
Deploying to main from @ openqasm/openqasm@6c91bc6 🚀
1 parent ae1ab29 commit 664eb8e

File tree

10 files changed

+549
-415
lines changed

10 files changed

+549
-415
lines changed

_sources/language/delays.rst.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,29 @@ require more than 150ns for all valid combinations:
329329
}
330330
331331
332+
Qubits can be marked as synchronized by a box using the ``nop`` keyword (see :ref:`nop`).
333+
This can allow the explicit synchronization of qubits at a high level, without assigning any semantics to the action of that qubit within a box.
334+
For example:
335+
336+
.. code-block::
337+
338+
include "stdgates.inc";
339+
340+
stretch s;
341+
box [s] {
342+
// Qubits $0 and $1 are explicitly used by the `cx`.
343+
cx $0, $1;
344+
345+
// Qubit $2 must be synchronized to $0 and $1 at the start
346+
// and end of the box, but has no defined operations within
347+
// the box.
348+
nop $2;
349+
}
350+
351+
.. versionadded:: 3.2
352+
The ``nop`` directive.
353+
354+
332355
Barrier instruction
333356
-------------------
334357

_sources/language/insts.rst.txt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Built-in quantum instructions
22
=============================
33

4-
This section describes built-in non-unitary operations.
4+
This section describes built-in operations on qubits, including non-unitary ones.
55

66
Initialization
77
--------------
@@ -73,3 +73,47 @@ broadcasts to ``b[j] = measure a[j];`` for each index ``j`` into register ``a``.
7373
``c[0] = measure q[0];`` while the bottom depicts measurement of an entire register using the
7474
statement ``c = measure q;``. The center circuit of the top row depicts measurement as the
7575
final operation on ``q[0]``.
76+
77+
78+
.. _nop:
79+
80+
Explicit no-operation
81+
---------------------
82+
83+
.. versionadded:: 3.2
84+
The entire ``nop`` directive.
85+
86+
The statement ``nop <qubits>;`` is an explicit no-operation on all mentioned qubits, but marks them as being "used" within a scope.
87+
``<qubits>`` is a comma-separated list of qubit or qubit-register operands.
88+
89+
In the global scope this has no effect on the program operation, though a compiler must still validate the arguments.
90+
This has a particularly important effect on :ref:`boxed scopes <Boxed expressions>`; a ``nop`` counts as a "use" of the qubit within the ``box``, causing the qubit to be synchronized with the rest of the box at entry and exit.
91+
92+
A ``nop`` statement is valid in exactly the places that a gate-call statement is valid.
93+
The operands of a ``nop`` statement must all be in scope and be of type ``qubit`` or ``qubit[n]`` for any non-negative integer ``n``.
94+
95+
For example:
96+
97+
.. code-block::
98+
99+
include "stdgates.inc";
100+
101+
stretch s;
102+
box [s] {
103+
// Qubits $0 and $1 are explicitly used by the `cx`.
104+
cx $0, $1;
105+
106+
// Qubit $2 must be synchronized to $0 and $1 at the start
107+
// and end of the box, but has no defined operations within
108+
// the box.
109+
nop $2;
110+
111+
// More than one qubit can be specified in the list. It is
112+
// not an error to duplicate qubits, nor to ``nop`` a qubit
113+
// with explicit operations in this scope.
114+
nop $3, $0;
115+
116+
// The ``nop`` statement can have zero operands, and this
117+
// has no observable effect at all.
118+
nop;
119+
}

grammar/index.html

Lines changed: 408 additions & 405 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ <h1>OpenQASM Live Specification<a class="headerlink" href="#openqasm-version-spe
7474
<li class="toctree-l2"><a class="reference internal" href="language/insts.html">Built-in quantum instructions</a><ul>
7575
<li class="toctree-l3"><a class="reference internal" href="language/insts.html#initialization">Initialization</a></li>
7676
<li class="toctree-l3"><a class="reference internal" href="language/insts.html#measurement">Measurement</a></li>
77+
<li class="toctree-l3"><a class="reference internal" href="language/insts.html#explicit-no-operation">Explicit no-operation</a></li>
7778
</ul>
7879
</li>
7980
<li class="toctree-l2"><a class="reference internal" href="language/classical.html">Classical instructions</a><ul>
@@ -134,7 +135,7 @@ <h1>OpenQASM Live Specification<a class="headerlink" href="#openqasm-version-spe
134135
</li>
135136
<li class="toctree-l1"><a class="reference internal" href="grammar/index.html">OpenQASM 3.0 Grammar</a></li>
136137
<li class="toctree-l1"><a class="reference internal" href="release_notes.html">Release Notes</a><ul>
137-
<li class="toctree-l2"><a class="reference internal" href="release_notes.html#spec-v3-1-0-32">spec/v3.1.0-32</a><ul>
138+
<li class="toctree-l2"><a class="reference internal" href="release_notes.html#spec-v3-1-0-33">spec/v3.1.0-33</a><ul>
138139
<li class="toctree-l3"><a class="reference internal" href="release_notes.html#new-features">New Features</a></li>
139140
<li class="toctree-l3"><a class="reference internal" href="release_notes.html#upgrade-notes">Upgrade Notes</a></li>
140141
<li class="toctree-l3"><a class="reference internal" href="release_notes.html#bug-fixes">Bug Fixes</a></li>

language/delays.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,26 @@ <h2>Boxed expressions<a class="headerlink" href="#boxed-expressions" title="Link
351351
<span class="p">}</span>
352352
</pre></div>
353353
</div>
354+
<p>Qubits can be marked as synchronized by a box using the <code class="docutils literal notranslate"><span class="pre">nop</span></code> keyword (see <a class="reference internal" href="insts.html#nop"><span class="std std-ref">Explicit no-operation</span></a>).
355+
This can allow the explicit synchronization of qubits at a high level, without assigning any semantics to the action of that qubit within a box.
356+
For example:</p>
357+
<div class="highlight-qasm3 notranslate"><div class="highlight"><pre><span></span><span class="kn">include</span><span class="w"> </span><span class="s">&quot;stdgates.inc&quot;</span><span class="p">;</span>
358+
359+
<span class="kt">stretch</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
360+
<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>
361+
<span class="w"> </span><span class="c1">// Qubits $0 and $1 are explicitly used by the `cx`.</span>
362+
<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>
363+
364+
<span class="w"> </span><span class="c1">// Qubit $2 must be synchronized to $0 and $1 at the start</span>
365+
<span class="w"> </span><span class="c1">// and end of the box, but has no defined operations within</span>
366+
<span class="w"> </span><span class="c1">// the box.</span>
367+
<span class="w"> </span><span class="n">nop</span><span class="w"> </span><span class="l">$2</span><span class="p">;</span>
368+
<span class="p">}</span>
369+
</pre></div>
370+
</div>
371+
<div class="versionadded">
372+
<p><span class="versionmodified added">Added in version 3.2: </span>The <code class="docutils literal notranslate"><span class="pre">nop</span></code> directive.</p>
373+
</div>
354374
</section>
355375
<section id="barrier-instruction">
356376
<h2>Barrier instruction<a class="headerlink" href="#barrier-instruction" title="Link to this heading"></a></h2>

language/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<li class="toctree-l1"><a class="reference internal" href="insts.html">Built-in quantum instructions</a><ul>
122122
<li class="toctree-l2"><a class="reference internal" href="insts.html#initialization">Initialization</a></li>
123123
<li class="toctree-l2"><a class="reference internal" href="insts.html#measurement">Measurement</a></li>
124+
<li class="toctree-l2"><a class="reference internal" href="insts.html#explicit-no-operation">Explicit no-operation</a></li>
124125
</ul>
125126
</li>
126127
<li class="toctree-l1"><a class="reference internal" href="classical.html">Classical instructions</a><ul>

language/insts.html

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<section id="built-in-quantum-instructions">
3838
<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>
4040
<section id="initialization">
4141
<h2>Initialization<a class="headerlink" href="#initialization" title="Link to this heading"></a></h2>
4242
<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
105105
</figcaption>
106106
</figure>
107107
</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">&lt;qubits&gt;;</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">&lt;qubits&gt;</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">&quot;stdgates.inc&quot;</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>
108144
</section>
109145

110146

@@ -135,6 +171,7 @@ <h3>Navigation</h3>
135171
<li class="toctree-l2 current"><a class="current reference internal" href="#">Built-in quantum instructions</a><ul>
136172
<li class="toctree-l3"><a class="reference internal" href="#initialization">Initialization</a></li>
137173
<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>
138175
</ul>
139176
</li>
140177
<li class="toctree-l2"><a class="reference internal" href="classical.html">Classical instructions</a></li>

objects.inv

18 Bytes
Binary file not shown.

release_notes.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
<section id="release-notes">
3636
<h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this heading"></a></h1>
37-
<section id="spec-v3-1-0-32">
38-
<span id="release-notes-spec-v3-1-0-32"></span><h2>spec/v3.1.0-32<a class="headerlink" href="#spec-v3-1-0-32" title="Link to this heading"></a></h2>
37+
<section id="spec-v3-1-0-33">
38+
<span id="release-notes-spec-v3-1-0-33"></span><h2>spec/v3.1.0-33<a class="headerlink" href="#spec-v3-1-0-33" title="Link to this heading"></a></h2>
3939
<section id="new-features">
40-
<span id="release-notes-spec-v3-1-0-32-new-features"></span><h3>New Features<a class="headerlink" href="#new-features" title="Link to this heading"></a></h3>
40+
<span id="release-notes-spec-v3-1-0-33-new-features"></span><h3>New Features<a class="headerlink" href="#new-features" title="Link to this heading"></a></h3>
4141
<ul class="simple">
4242
<li><p>The types <code class="docutils literal notranslate"><span class="pre">bool</span></code> and (scalar) <code class="docutils literal notranslate"><span class="pre">bit</span></code> are now explicitly described as being completely
4343
interchangeable in expression (r-value) positions, and that <code class="docutils literal notranslate"><span class="pre">bit</span></code> and <code class="docutils literal notranslate"><span class="pre">bit[1]</span></code> are distinct
@@ -54,9 +54,14 @@ <h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this
5454
To support namespaced annotations, the annotations keyword may now include
5555
a dotted (‘.’) list of identifiers.</p></li>
5656
</ul>
57+
<ul class="simple">
58+
<li><p>Added an explicit no-operation statement <code class="docutils literal notranslate"><span class="pre">nop</span> <span class="pre">&lt;qubits&gt;;</span></code>, which can be used to mark qubits as
59+
“used” by a scope (such as a <code class="docutils literal notranslate"><span class="pre">box</span></code>) without implying any operations on them. See <a class="reference internal" href="language/insts.html#nop"><span class="std std-ref">Explicit no-operation</span></a>
60+
for full details.</p></li>
61+
</ul>
5762
</section>
5863
<section id="upgrade-notes">
59-
<span id="release-notes-spec-v3-1-0-32-upgrade-notes"></span><h3>Upgrade Notes<a class="headerlink" href="#upgrade-notes" title="Link to this heading"></a></h3>
64+
<span id="release-notes-spec-v3-1-0-33-upgrade-notes"></span><h3>Upgrade Notes<a class="headerlink" href="#upgrade-notes" title="Link to this heading"></a></h3>
6065
<ul class="simple">
6166
<li><p>It has been clarified that arrays and registers of size zero are
6267
allowed; however, integers and angles must have size greater than
@@ -70,7 +75,7 @@ <h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this
7075
</ul>
7176
</section>
7277
<section id="bug-fixes">
73-
<span id="release-notes-spec-v3-1-0-32-bug-fixes"></span><h3>Bug Fixes<a class="headerlink" href="#bug-fixes" title="Link to this heading"></a></h3>
78+
<span id="release-notes-spec-v3-1-0-33-bug-fixes"></span><h3>Bug Fixes<a class="headerlink" href="#bug-fixes" title="Link to this heading"></a></h3>
7479
<ul class="simple">
7580
<li><p>Clarify that array type variables are supported as inputs.</p></li>
7681
</ul>
@@ -106,7 +111,7 @@ <h3>Navigation</h3>
106111
<li class="toctree-l1"><a class="reference internal" href="language/index.html">Language</a></li>
107112
<li class="toctree-l1"><a class="reference internal" href="grammar/index.html">OpenQASM 3.0 Grammar</a></li>
108113
<li class="toctree-l1 current"><a class="current reference internal" href="#">Release Notes</a><ul>
109-
<li class="toctree-l2"><a class="reference internal" href="#spec-v3-1-0-32">spec/v3.1.0-32</a><ul>
114+
<li class="toctree-l2"><a class="reference internal" href="#spec-v3-1-0-33">spec/v3.1.0-33</a><ul>
110115
<li class="toctree-l3"><a class="reference internal" href="#new-features">New Features</a></li>
111116
<li class="toctree-l3"><a class="reference internal" href="#upgrade-notes">Upgrade Notes</a></li>
112117
<li class="toctree-l3"><a class="reference internal" href="#bug-fixes">Bug Fixes</a></li>

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)