Skip to content

Commit

Permalink
deploy: e685dc6
Browse files Browse the repository at this point in the history
  • Loading branch information
nelimee committed Oct 21, 2024
1 parent 21a2465 commit 049f51e
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ <h1>tqec.circuit.generation.generate_circuit<a class="headerlink" href="#tqec-ci
<dd class="field-even"><p>a <cite>ScheduledCircuit</cite> instance implementing the (part of) quantum error
correction experiment represented by the provided inputs.</p>
</dd>
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="tqec.exceptions.TQECException.html#tqec.exceptions.TQECException" title="tqec.exceptions.TQECException"><strong>TQECException</strong></a> – if <cite>len(plaquettes) != template.expected_plaquettes_number</cite>.</p>
</dd>
</dl>
</dd></dl>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,26 @@ <h1>tqec.circuit.measurement.get_measurements_from_circuit<a class="headerlink"
<dl class="py function">
<dt class="sig sig-object py" id="tqec.circuit.measurement.get_measurements_from_circuit">
<span class="sig-name descname"><span class="pre">get_measurements_from_circuit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">circuit</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Circuit</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="tqec.circuit.measurement.Measurement.html#tqec.circuit.measurement.Measurement" title="tqec.circuit.measurement.Measurement"><span class="pre">Measurement</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/tqec/circuit/measurement.html#get_measurements_from_circuit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tqec.circuit.measurement.get_measurements_from_circuit" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dd><p>Get all the measurements found in the provided circuit.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>circuit</strong> – circuit to extract measurements from.</p>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference internal" href="tqec.exceptions.TQECException.html#tqec.exceptions.TQECException" title="tqec.exceptions.TQECException"><strong>TQECException</strong></a> – if the provided circuit contains a <cite>REPEAT</cite> block.</p></li>
<li><p><a class="reference internal" href="tqec.exceptions.TQECException.html#tqec.exceptions.TQECException" title="tqec.exceptions.TQECException"><strong>TQECException</strong></a> – if the provided circuit contains a multi-qubit measurement
gate such as MXX or MPP.</p></li>
<li><p><a class="reference internal" href="tqec.exceptions.TQECException.html#tqec.exceptions.TQECException" title="tqec.exceptions.TQECException"><strong>TQECException</strong></a> – if the provided circuit contains a single-qubit
measurement gate with a non-qubit target.</p></li>
</ul>
</dd>
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>all the measurements present in the provided <cite>circuit</cite>, in their order
of appearance (so in increasing order of measurement record offsets).</p>
</dd>
</dl>
</dd></dl>

</section>

Expand Down
2 changes: 1 addition & 1 deletion pull/356/_autosummary/tqec.circuit.measurement.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<table class="autosummary longtable docutils align-default">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="tqec.circuit.measurement.get_measurements_from_circuit.html#tqec.circuit.measurement.get_measurements_from_circuit" title="tqec.circuit.measurement.get_measurements_from_circuit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_measurements_from_circuit</span></code></a>(circuit)</p></td>
<td><p></p></td>
<td><p>Get all the measurements found in the provided circuit.</p></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion pull/356/_autosummary/tqec.circuit.moment.Moment.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ <h1>tqec.circuit.moment.Moment<a class="headerlink" href="#tqec-circuit-moment-m
<td><p>Remove in-place all the instructions that have their name in the provided <cite>instructions_to_remove</cite>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">with_mapped_qubit_indices</span></code>(qubit_index_map)</p></td>
<td><p></p></td>
<td><p>Map the qubits <strong>indices</strong> the <cite>Moment</cite> instance is applied on.</p></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion pull/356/_autosummary/tqec.circuit.qubit_map.QubitMap.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ <h1>tqec.circuit.qubit_map.QubitMap<a class="headerlink" href="#tqec-circuit-qub
<td><p></p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">from_qubits</span></code>(qubits)</p></td>
<td><p></p></td>
<td><p>Creates a qubit map from the provided <cite>qubits</cite>, associating indices using the order in which qubits are provided.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">items</span></code>()</p></td>
<td><p></p></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ <h1>tqec.simulation.simulation.start_simulation_using_sinter<a class="headerlink
as ‘pymatching’ and ‘fusion_blossom’, can be used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>a list containing one simulation result (of type
<cite>list[sinter.TaskStats]</cite>) per provided observable in <cite>observables</cite>.</p>
<dt class="field-even">Yields<span class="colon">:</span></dt>
<dd class="field-even"><p>one simulation result (of type <cite>list[sinter.TaskStats]</cite>) per provided
observable in <cite>observables</cite>.</p>
</dd>
</dl>
</dd></dl>
Expand Down
14 changes: 4 additions & 10 deletions pull/356/_modules/tqec/circuit/generation.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ <h1>Source code for tqec.circuit.generation</h1><div class="highlight"><pre>
<span class="n">merge_scheduled_circuits</span><span class="p">,</span>
<span class="n">relabel_circuits_qubit_indices</span><span class="p">,</span>
<span class="p">)</span>
<span class="kn">from</span> <span class="nn">tqec.exceptions</span> <span class="kn">import</span> <span class="n">TQECException</span>
<span class="kn">from</span> <span class="nn">tqec.plaquette.plaquette</span> <span class="kn">import</span> <span class="n">Plaquette</span><span class="p">,</span> <span class="n">Plaquettes</span>
<span class="kn">from</span> <span class="nn">tqec.plaquette.plaquette</span> <span class="kn">import</span> <span class="n">Plaquettes</span>
<span class="kn">from</span> <span class="nn">tqec.position</span> <span class="kn">import</span> <span class="n">Displacement</span>
<span class="kn">from</span> <span class="nn">tqec.templates.base</span> <span class="kn">import</span> <span class="n">Template</span>

Expand Down Expand Up @@ -148,9 +147,6 @@ <h1>Source code for tqec.circuit.generation</h1><div class="highlight"><pre>
<span class="sd"> Returns:</span>
<span class="sd"> a `ScheduledCircuit` instance implementing the (part of) quantum error</span>
<span class="sd"> correction experiment represented by the provided inputs.</span>

<span class="sd"> Raises:</span>
<span class="sd"> TQECException: if `len(plaquettes) != template.expected_plaquettes_number`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># instantiate the template with the appropriate plaquette indices.</span>
<span class="c1"># Index 0 is &quot;no plaquette&quot; by convention and should not be included here.</span>
Expand Down Expand Up @@ -204,9 +200,8 @@ <h1>Source code for tqec.circuit.generation</h1><div class="highlight"><pre>
<span class="sd"> TQECException: if any index in `plaquette_array` is not correctly</span>
<span class="sd"> associated to a plaquette in `plaquettes`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Check that the user gave enough plaquettes.</span>
<span class="c1"># Collect all the used plaquette indices, removing 0 if present.</span>
<span class="n">indices</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">plaquette_array</span><span class="p">)</span>
<span class="c1"># Remove the first 0 entry in indices if present</span>
<span class="k">if</span> <span class="n">indices</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">indices</span> <span class="o">=</span> <span class="n">indices</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>

Expand All @@ -223,9 +218,7 @@ <h1>Source code for tqec.circuit.generation</h1><div class="highlight"><pre>
<span class="k">for</span> <span class="n">row_index</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">plaquette_array</span><span class="p">):</span>
<span class="k">for</span> <span class="n">column_index</span><span class="p">,</span> <span class="n">plaquette_index</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
<span class="k">if</span> <span class="n">plaquette_index</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="c1"># Warning: this is a reference to a shared circuit. It cannot be</span>
<span class="c1"># changed in-place!!</span>
<span class="n">scheduled_circuit</span> <span class="o">=</span> <span class="n">plaquette_circuits</span><span class="p">[</span><span class="n">plaquette_index</span><span class="p">]</span>
<span class="c1"># Computing the offset that should be applied to each qubits.</span>
<span class="n">plaquette</span> <span class="o">=</span> <span class="n">plaquettes</span><span class="p">[</span><span class="n">plaquette_index</span><span class="p">]</span>
<span class="n">qubit_offset</span> <span class="o">=</span> <span class="n">Displacement</span><span class="p">(</span>
<span class="n">plaquette</span><span class="o">.</span><span class="n">origin</span><span class="o">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">column_index</span> <span class="o">*</span> <span class="n">increments</span><span class="o">.</span><span class="n">x</span><span class="p">,</span>
Expand All @@ -238,6 +231,7 @@ <h1>Source code for tqec.circuit.generation</h1><div class="highlight"><pre>
<span class="c1"># calling `relabel_circuits_qubit_indices`, that</span>
<span class="c1"># explicitly returns a copy of its inputs, and do not</span>
<span class="c1"># mutate them either.</span>
<span class="n">scheduled_circuit</span> <span class="o">=</span> <span class="n">plaquette_circuits</span><span class="p">[</span><span class="n">plaquette_index</span><span class="p">]</span>
<span class="n">mapped_scheduled_circuit</span> <span class="o">=</span> <span class="n">scheduled_circuit</span><span class="o">.</span><span class="n">map_to_qubits</span><span class="p">(</span>
<span class="k">lambda</span> <span class="n">q</span><span class="p">:</span> <span class="n">q</span> <span class="o">+</span> <span class="n">qubit_offset</span><span class="p">,</span> <span class="n">inplace_qubit_map</span><span class="o">=</span><span class="kc">False</span>
<span class="p">)</span>
Expand Down
16 changes: 16 additions & 0 deletions pull/356/_modules/tqec/circuit/measurement.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,22 @@ <h1>Source code for tqec.circuit.measurement</h1><div class="highlight"><pre>
<div class="viewcode-block" id="get_measurements_from_circuit">
<a class="viewcode-back" href="../../../_autosummary/tqec.circuit.measurement.get_measurements_from_circuit.html#tqec.circuit.measurement.get_measurements_from_circuit">[docs]</a>
<span class="k">def</span> <span class="nf">get_measurements_from_circuit</span><span class="p">(</span><span class="n">circuit</span><span class="p">:</span> <span class="n">stim</span><span class="o">.</span><span class="n">Circuit</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="n">Measurement</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get all the measurements found in the provided circuit.</span>

<span class="sd"> Args:</span>
<span class="sd"> circuit: circuit to extract measurements from.</span>

<span class="sd"> Raises:</span>
<span class="sd"> TQECException: if the provided circuit contains a `REPEAT` block.</span>
<span class="sd"> TQECException: if the provided circuit contains a multi-qubit measurement</span>
<span class="sd"> gate such as MXX or MPP.</span>
<span class="sd"> TQECException: if the provided circuit contains a single-qubit</span>
<span class="sd"> measurement gate with a non-qubit target.</span>

<span class="sd"> Returns:</span>
<span class="sd"> all the measurements present in the provided `circuit`, in their order</span>
<span class="sd"> of appearance (so in increasing order of measurement record offsets).</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">qubit_map</span> <span class="o">=</span> <span class="n">QubitMap</span><span class="o">.</span><span class="n">from_circuit</span><span class="p">(</span><span class="n">circuit</span><span class="p">)</span>
<span class="n">num_measurements</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">GridQubit</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">measurements_reverse_order</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="n">Measurement</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
Expand Down
13 changes: 13 additions & 0 deletions pull/356/_modules/tqec/circuit/moment.html
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,19 @@ <h1>Source code for tqec.circuit.moment</h1><div class="highlight"><pre>
<span class="p">)</span>

<span class="k">def</span> <span class="nf">with_mapped_qubit_indices</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">qubit_index_map</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">Moment</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Map the qubits **indices** the `Moment` instance is applied on.</span>

<span class="sd"> Note:</span>
<span class="sd"> This method has to iterate over all the instructions in `self` and</span>
<span class="sd"> change the gate target they are applied on.</span>

<span class="sd"> Args:</span>
<span class="sd"> qubit_index_map: the map used to modify the qubit targets.</span>

<span class="sd"> Returns:</span>
<span class="sd"> a modified copy of `self` with the qubit gate targets mapped according</span>
<span class="sd"> to the provided `qubit_index_map`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">circuit</span> <span class="o">=</span> <span class="n">stim</span><span class="o">.</span><span class="n">Circuit</span><span class="p">()</span>
<span class="k">for</span> <span class="n">instr</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">instructions</span><span class="p">:</span>
<span class="n">mapped_targets</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="n">stim</span><span class="o">.</span><span class="n">GateTarget</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
Expand Down
4 changes: 3 additions & 1 deletion pull/356/_modules/tqec/circuit/qubit_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1>Source code for tqec.circuit.qubit_map</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">functools</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span><span class="p">,</span> <span class="n">field</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">Iterable</span><span class="p">,</span> <span class="n">Mapping</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">Iterable</span>

<span class="kn">import</span> <span class="nn">stim</span>

Expand Down Expand Up @@ -123,6 +123,8 @@ <h1>Source code for tqec.circuit.qubit_map</h1><div class="highlight"><pre>

<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">from_qubits</span><span class="p">(</span><span class="n">qubits</span><span class="p">:</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">GridQubit</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">QubitMap</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Creates a qubit map from the provided `qubits`, associating indices</span>
<span class="sd"> using the order in which qubits are provided.&quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">QubitMap</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="nb">enumerate</span><span class="p">(</span><span class="n">qubits</span><span class="p">)))</span>

<span class="nd">@staticmethod</span>
Expand Down
6 changes: 3 additions & 3 deletions pull/356/_modules/tqec/circuit/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,9 @@ <h1>Source code for tqec.circuit.schedule</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">_schedule</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">insertion_index</span><span class="p">,</span> <span class="n">schedule</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_moments</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">insertion_index</span><span class="p">,</span> <span class="n">moment</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># Else, the schedule already exists, in which case we just need to add the</span>
<span class="c1"># operations to an existing moment. Note that this might fail if two</span>
<span class="c1"># operations overlap.</span>
<span class="c1"># Else, the schedule already exists, in which case we just need to</span>
<span class="c1"># add the operations to an existing moment. Note that this might</span>
<span class="c1"># fail if two instructions overlap.</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_moments</span><span class="p">[</span><span class="n">moment_index</span><span class="p">]</span> <span class="o">+=</span> <span class="n">moment</span>

<span class="k">def</span> <span class="nf">append_observable</span><span class="p">(</span>
Expand Down
Loading

0 comments on commit 049f51e

Please sign in to comment.