.. 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 Click :ref:`here ` 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-22 .. code-block:: default import itertools import graphix from graphix.extraction import get_fusion_network_from_graph .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/graphix/envs/127-support-python312/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:33: UserWarning: Couldn't import `kahypar` - skipping from default hyper optimizer and using basic `labels` method instead. warnings.warn( .. GENERATED FROM PYTHON SOURCE LINES 23-25 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:`nodes, edges = pattern.get_graph()`. .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. code-block:: default 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 33-34 Decomposition with GHZ and linear cluster resource states with no limitation in their sizes. .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: default get_fusion_network_from_graph(gs) .. rst-class:: sphx-glr-script-out .. code-block:: none [GHZ[0, 7, 5, 3, 1], GHZ[1, 2, 8], LINEAR[2, 3, 4, 5, 6, 7, 8]] .. GENERATED FROM PYTHON SOURCE LINES 37-43 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 43-50 .. code-block:: default fused_graphs = get_fusion_network_from_graph(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}: {graphix.extraction.get_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 51-53 You can also specify the maximum size of GHZ clusters and linear clusters available, for more realistic fusion scheduling. .. GENERATED FROM PYTHON SOURCE LINES 53-54 .. code-block:: default get_fusion_network_from_graph(gs, max_ghz=4, max_lin=4) .. rst-class:: sphx-glr-script-out .. code-block:: none [GHZ[0, 7, 5, 3], GHZ[1, 8, 2, 0], LINEAR[2, 3, 4, 5], LINEAR[5, 6, 7, 8]] .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 15.514 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-python :download:`Download Python source code: fusion_extraction.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: fusion_extraction.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_