.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/fusion_extraction.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_fusion_extraction.py: Designing fusion network to generate resource graph state ========================================================== In this example, we decompose a graph state into a set of GHZ and linear cluster resource states, such that fusion operations can be used on these 'micro-resource' states to obtain the desired graph state. This is an important compilation stage to perform MBQC on discrete-variable optical QPUs. The decomposition algorithm is based on [1]. [1] Zilk et al., A compiler for universal photonic quantum computers, 2022 `arXiv:2210.09251 `_ .. GENERATED FROM PYTHON SOURCE LINES 17-25 .. code-block:: Python from __future__ import annotations import itertools import graphix from graphix import extraction from graphix.extraction import graph_to_fusion_network .. GENERATED FROM PYTHON SOURCE LINES 26-28 Here we say we want a graph state with 9 nodes and 12 edges. We can obtain resource graph for a measurement pattern by using :code:`pattern.extract_graph()`. .. GENERATED FROM PYTHON SOURCE LINES 28-35 .. code-block:: Python gs = graphix.GraphState() nodes = [0, 1, 2, 3, 4, 5, 6, 7, 8] edges = [(0, 1), (1, 2), (2, 3), (3, 0), (3, 4), (0, 5), (4, 5), (5, 6), (6, 7), (7, 0), (7, 8), (8, 1)] gs.add_nodes_from(nodes) gs.add_edges_from(edges) gs.draw() .. image-sg:: /gallery/images/sphx_glr_fusion_extraction_001.png :alt: fusion extraction :srcset: /gallery/images/sphx_glr_fusion_extraction_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 36-37 Decomposition with GHZ and linear cluster resource states with no limitation in their sizes. .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python graph_to_fusion_network(gs) .. rst-class:: sphx-glr-script-out .. code-block:: none [ResourceGraph(cltype=, graph=), ResourceGraph(cltype=, graph=), ResourceGraph(cltype=, graph=)] .. GENERATED FROM PYTHON SOURCE LINES 40-46 If you want to know what nodes are fused in each resource states, you can use :func:`~graphix.extraction.get_fusion_nodes` function. Currently, we consider only type-I fusion. See [2] for the definition of fusion. [2] Daniel E. Browne and Terry Rudolph. Resource-efficient linear optical quantum computation. Physical Review Letters, 95(1):010501, 2005. .. GENERATED FROM PYTHON SOURCE LINES 46-53 .. code-block:: Python fused_graphs = graph_to_fusion_network(gs) for idx1, idx2 in itertools.combinations(range(len(fused_graphs)), 2): print( f"fusion nodes between resource state {idx1} and " f"resource state {idx2}: {extraction.fusion_nodes(fused_graphs[idx1], fused_graphs[idx2])}" ) .. rst-class:: sphx-glr-script-out .. code-block:: none fusion nodes between resource state 0 and resource state 1: [1] fusion nodes between resource state 0 and resource state 2: [7, 5, 3] fusion nodes between resource state 1 and resource state 2: [2, 8] .. GENERATED FROM PYTHON SOURCE LINES 54-56 You can also specify the maximum size of GHZ clusters and linear clusters available, for more realistic fusion scheduling. .. GENERATED FROM PYTHON SOURCE LINES 56-57 .. code-block:: Python graph_to_fusion_network(gs, max_ghz=4, max_lin=4) .. rst-class:: sphx-glr-script-out .. code-block:: none [ResourceGraph(cltype=, graph=), ResourceGraph(cltype=, graph=), ResourceGraph(cltype=, graph=), ResourceGraph(cltype=, graph=)] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.048 seconds) .. _sphx_glr_download_gallery_fusion_extraction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fusion_extraction.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: fusion_extraction.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: fusion_extraction.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_