├── .gitignore ├── LICENSE ├── README.md ├── diskit ├── __init__.py ├── circuit_remapper.py └── components │ ├── __init__.py │ ├── layer.py │ └── topology.py ├── docs ├── .buildinfo ├── .doctrees │ ├── components │ │ ├── circuit_remapper.doctree │ │ ├── layer.doctree │ │ └── topology.doctree │ ├── environment.pickle │ ├── examples.doctree │ ├── examples │ │ ├── CNOT.doctree │ │ ├── QFT.doctree │ │ ├── Shors.doctree │ │ └── Topology.doctree │ ├── index.doctree │ ├── nbsphinx │ │ ├── examples │ │ │ ├── CNOT.ipynb │ │ │ ├── QFT.ipynb │ │ │ ├── Shors.ipynb │ │ │ └── Topology.ipynb │ │ ├── examples_CNOT_11_0.png │ │ ├── examples_CNOT_13_0.png │ │ ├── examples_CNOT_14_0.png │ │ ├── examples_CNOT_19_0.png │ │ ├── examples_CNOT_21_0.png │ │ ├── examples_CNOT_24_0.png │ │ ├── examples_CNOT_28_0.png │ │ ├── examples_CNOT_7_0.png │ │ ├── examples_QFT_12_0.png │ │ ├── examples_QFT_14_0.png │ │ ├── examples_QFT_15_0.png │ │ ├── examples_QFT_28_0.png │ │ └── examples_QFT_30_0.png │ ├── quick_start.doctree │ └── source.doctree ├── .nojekyll ├── Makefile ├── _images │ ├── SEG-QPU.png │ ├── examples_CNOT_11_0.png │ ├── examples_CNOT_13_0.png │ ├── examples_CNOT_14_0.png │ ├── examples_CNOT_19_0.png │ ├── examples_CNOT_21_0.png │ ├── examples_CNOT_24_0.png │ ├── examples_CNOT_28_0.png │ ├── examples_CNOT_7_0.png │ ├── examples_QFT_12_0.png │ ├── examples_QFT_14_0.png │ ├── examples_QFT_15_0.png │ ├── examples_QFT_28_0.png │ └── examples_QFT_30_0.png ├── _sources │ ├── components │ │ ├── circuit_remapper.rst.txt │ │ ├── layer.rst.txt │ │ └── topology.rst.txt │ ├── examples.rst.txt │ ├── examples │ │ ├── CNOT.ipynb.txt │ │ ├── QFT.ipynb.txt │ │ ├── Shors.ipynb.txt │ │ └── Topology.ipynb.txt │ ├── index.rst.txt │ ├── quick_start.rst.txt │ └── source.rst.txt ├── _static │ ├── _sphinx_javascript_frameworks_compat.js │ ├── basic.css │ ├── css │ │ ├── badge_only.css │ │ ├── fonts │ │ │ ├── Roboto-Slab-Bold.woff │ │ │ ├── Roboto-Slab-Bold.woff2 │ │ │ ├── Roboto-Slab-Regular.woff │ │ │ ├── Roboto-Slab-Regular.woff2 │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ ├── fontawesome-webfont.woff2 │ │ │ ├── lato-bold-italic.woff │ │ │ ├── lato-bold-italic.woff2 │ │ │ ├── lato-bold.woff │ │ │ ├── lato-bold.woff2 │ │ │ ├── lato-normal-italic.woff │ │ │ ├── lato-normal-italic.woff2 │ │ │ ├── lato-normal.woff │ │ │ └── lato-normal.woff2 │ │ └── theme.css │ ├── doctools.js │ ├── documentation_options.js │ ├── file.png │ ├── jquery-3.6.0.js │ ├── jquery.js │ ├── js │ │ ├── badge_only.js │ │ ├── html5shiv-printshiv.min.js │ │ ├── html5shiv.min.js │ │ └── theme.js │ ├── language_data.js │ ├── minus.png │ ├── plus.png │ ├── pygments.css │ ├── searchtools.js │ ├── sphinx_highlight.js │ ├── underscore-1.13.1.js │ └── underscore.js ├── components │ ├── circuit_remapper.html │ ├── layer.html │ └── topology.html ├── examples.html ├── examples │ ├── CNOT.html │ ├── CNOT.ipynb │ ├── QFT.html │ ├── QFT.ipynb │ ├── Shors.html │ ├── Shors.ipynb │ ├── Topology.html │ └── Topology.ipynb ├── genindex.html ├── index.html ├── make.bat ├── objects.inv ├── py-modindex.html ├── quick_start.html ├── search.html ├── searchindex.js ├── source.html └── source │ ├── components │ ├── circuit_remapper.rst │ ├── layer.rst │ └── topology.rst │ ├── conf.py │ ├── examples.rst │ ├── examples │ ├── CNOT.ipynb │ ├── QFT.ipynb │ ├── Shors.ipynb │ └── Topology.ipynb │ ├── images │ └── SEG-QPU.png │ ├── index.rst │ ├── quick_start.rst │ └── source.rst ├── examples ├── CNOT.ipynb ├── QFT.ipynb ├── Shors.ipynb ├── Topology.ipynb └── swap.py ├── requirements.txt ├── setup.py ├── sphinx_requirements.txt └── tests ├── test_circuit_remapper.py ├── test_circuits.py └── test_topology.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | wheels/ 26 | pip-wheel-metadata/ 27 | share/python-wheels/ 28 | *.egg-info/ 29 | .installed.cfg 30 | *.egg 31 | MANIFEST 32 | 33 | # PyInstaller 34 | # Usually these files are written by a python script from a template 35 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 36 | *.manifest 37 | *.spec 38 | 39 | # Installer logs 40 | pip-log.txt 41 | pip-delete-this-directory.txt 42 | 43 | # Unit test / coverage reports 44 | htmlcov/ 45 | .tox/ 46 | .nox/ 47 | .coverage 48 | .coverage.* 49 | .cache 50 | nosetests.xml 51 | coverage.xml 52 | *.cover 53 | *.py,cover 54 | .hypothesis/ 55 | .pytest_cache/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff: 62 | *.log 63 | local_settings.py 64 | db.sqlite3 65 | db.sqlite3-journal 66 | 67 | # Flask stuff: 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff: 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | 77 | # PyBuilder 78 | target/ 79 | 80 | # Jupyter Notebook 81 | .ipynb_checkpoints 82 | 83 | # IPython 84 | profile_default/ 85 | ipython_config.py 86 | 87 | # pyenv 88 | .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Distributed QC for Qiskit 2 | 3 | Distributed quantum computing is a concept that proposes to connect multiple quantum computers in a network to leverage a collection of more, but physically separated, qubits. In order to perform distributed quantum computing, it is necessary to add the addition of classical communication and entanglement distribution so that the control information from one qubit can be applied to another that is located on another quantum computer. For more details on distributed quantum computing, see this blog post: [Distributed Quantum Computing: A path to large scale quantum computing](https://medium.com/@stephen.diadamo/distributed-quantum-computing-1c5d38a34c50) 4 | 5 | In this project, we aim to validate distributed quantum algorithms using Qiskit. Because Qiskit does not yet come with networking features, we embed a "virtual network topology" into large circuits to mimic distributed quantum computing. The idea is to take a monolithic quantum circuit developed in the Qiskit language and distribute the circuit according to an artificially segmented version of a quantum processor. The inputs to the library are a quantum algorithm written monolithically (i.e., in a single circuit) and a topology parameter that represents the artificial segmentation of the single quantum processor. 6 | 7 | The algorithm takes these two inputs and remaps the Qiskit circuit to the specified segmentation, adding all necessary steps to perform an equivalent distributed quantum circuit. Our algorithm for achieving this is based on the work: [Distributed Quantum Computing and Network Control for Accelerated VQE](https://ieeexplore.ieee.org/document/9351762). The algorithm output is another Qiskit circuit with the equivalent measurement statistics but with all of the additional logic needed to perform a distributed version. 8 | -------------------------------------------------------------------------------- /diskit/__init__.py: -------------------------------------------------------------------------------- 1 | from .components import Layer, Topology 2 | from .circuit_remapper import CircuitRemapper 3 | -------------------------------------------------------------------------------- /diskit/components/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import Layer 2 | from .topology import Topology 3 | -------------------------------------------------------------------------------- /diskit/components/layer.py: -------------------------------------------------------------------------------- 1 | """Layer object which is a collection of operations to be applied on the qubits in the system.""" 2 | from typing import List, Optional 3 | from qiskit.circuit.quantumcircuitdata import CircuitInstruction 4 | from .topology import Topology 5 | 6 | 7 | class Layer: 8 | """ 9 | Layer object which is a collection of operations to be applied on the qubits in the system. 10 | """ 11 | 12 | def __init__(self, operations: Optional[List[CircuitInstruction]] = None, 13 | topology: Topology = None): 14 | """ 15 | Returns the important things for a layer in a quantum circuit. 16 | 17 | Args: 18 | operations (list): List of Operation objects, which contains 19 | information about the operation to be 20 | performed on the quantum circuit 21 | """ 22 | 23 | self._operations = operations if operations is not None else [] 24 | self._topology = topology 25 | 26 | def __str__(self): 27 | layer = "" 28 | 29 | for operation in self._operations: 30 | layer += f"-{operation}-|\n" 31 | 32 | return layer 33 | 34 | @property 35 | def operations(self): 36 | """ 37 | Get the *operations* in the layer. 38 | 39 | Returns: 40 | (list): List of Operation objects, which contains information about the operation to 41 | be performed on the quantum circuit. 42 | """ 43 | return self._operations 44 | 45 | def add_operation(self, operation: CircuitInstruction): 46 | """ 47 | Add an operation to the layer. 48 | 49 | Args: 50 | operation (Operation): Information about the operation to be added in the layer 51 | """ 52 | 53 | self._operations.append(operation) 54 | 55 | def add_operations(self, operations: List[CircuitInstruction]): 56 | """ 57 | Add multiple operations to the layer. 58 | 59 | Args: 60 | operations (list): List of Operation objects 61 | """ 62 | self._operations.extend(operations) 63 | 64 | def non_local_operations(self): 65 | """ 66 | Check if a control gate is present in the layer between two different 67 | computing hosts. 68 | 69 | Returns: 70 | (bool): True if control gate is present between two different computing hosts 71 | """ 72 | 73 | non_local_ops = [] 74 | 75 | for operation in self._operations: 76 | if len(operation.qubits) == 2: 77 | if not self._topology.are_adjacent(operation.qubits[0], operation.qubits[1]): 78 | non_local_ops.append(operation) 79 | 80 | return non_local_ops 81 | 82 | def remove_operation(self, index: int): 83 | """ 84 | Remove an operation from the layer. 85 | 86 | Args: 87 | index (int): Index of the operation to be removed 88 | """ 89 | 90 | self._operations.pop(index) 91 | -------------------------------------------------------------------------------- /diskit/components/topology.py: -------------------------------------------------------------------------------- 1 | """Topology class for mapping distributed quantum computers.""" 2 | from typing import List, Dict, Optional 3 | from qiskit.circuit.quantumregister import QuantumRegister, Qubit 4 | from qiskit.circuit.exceptions import CircuitError 5 | 6 | 7 | class Topology: 8 | """ 9 | Topology class for a distributed architecture. 10 | """ 11 | 12 | def __init__(self, qmap: Optional[Dict[str, List[str]]] = None): 13 | """Initialize the topology object""" 14 | if qmap is None: 15 | self._qmap = {} 16 | self.emap = None 17 | self.q_hosts = None 18 | self.qubits = None 19 | else: 20 | self._qmap = qmap 21 | self.emap = self.create_emap() 22 | self.q_hosts = list(qmap.keys()) 23 | self.qubits = [] 24 | for qubit in qmap.values(): 25 | self.qubits += qubit 26 | 27 | def reinitialize(self, qmap: Dict[str, List[str]]): 28 | """Reinitialize the topology object by providing a new qmap""" 29 | self.emap = self.create_emap() 30 | self.q_hosts = list(qmap.keys()) 31 | self.qubits = [] 32 | for qubit in qmap.values(): 33 | self.qubits += qubit 34 | 35 | def add_qpu(self, qpu: str, num_qubits: int, qreg: str = None, indices: List[int] = None): 36 | """Add a QPU to the qmap. *qpu* is the name of the QPU, and *num_qubits* is the number of 37 | qubits on the QPU.""" 38 | if qreg is None: 39 | qreg = QuantumRegister(num_qubits, qpu) 40 | self.qmap[qpu] = [Qubit(qreg, i) for i in range(num_qubits)] 41 | self.reinitialize(self.qmap) 42 | elif indices is not None: 43 | if len(indices) != num_qubits: 44 | raise CircuitError( 45 | "QuantumRegister was provided but with a different number of indices.") 46 | qreg = QuantumRegister(num_qubits, qreg) 47 | self.qmap[qpu] = [Qubit(qreg, i) for i in indices] 48 | self.reinitialize(self.qmap) 49 | else: 50 | raise CircuitError( 51 | "QuantumRegister was provided but with no indices.") 52 | 53 | def num_qubits(self): 54 | """Return the total number of qubits in the topology""" 55 | return len(self.qubits) 56 | 57 | def num_hosts(self): 58 | """Return the total number of hosts in the topology""" 59 | return len(self.q_hosts) 60 | 61 | def are_adjacent(self, qubit1: str, qubit2: str): 62 | """Return True if qubit1 and qubit2 are adjacent""" 63 | for host in self.q_hosts: 64 | if qubit1 in self.qmap[host] and qubit2 in self.qmap[host]: 65 | return True 66 | return False 67 | 68 | def get_host(self, qubit: str): 69 | """Return the host of qubit.""" 70 | for host in self.q_hosts: 71 | if qubit in self.qmap[host]: 72 | return host 73 | return None 74 | 75 | def get_epr_id(self, host): 76 | """Return the epr qubit IDs.""" 77 | return self.emap[host] 78 | 79 | def get_all_qubits(self): 80 | """Return all the qubits in the qmap.""" 81 | qubits = [] 82 | for qpu in self.qmap: 83 | qubits += self.qmap[qpu] 84 | for qpu in self.emap: 85 | qubits.append(self.emap[qpu]) 86 | return qubits 87 | 88 | @property 89 | def qmap(self): 90 | """The topology map.""" 91 | return self._qmap 92 | 93 | def remove_qpu(self, qpu: str): 94 | """Remove a QPU from the qmap.""" 95 | self.qmap.pop(qpu) 96 | self.reinitialize(self.qmap) 97 | 98 | def create_qmap(self, num_qpus: int, num_qubits: List[int], name: str = "qpu"): 99 | """Create a qmap with *num_qpus* QPUs, each with *num_qubits* qubits.""" 100 | for i in range(num_qpus): 101 | self.add_qpu(f"{name}{i}", num_qubits[i]) 102 | self.reinitialize(self.qmap) 103 | 104 | def get_qubits(self, qpu: str): 105 | """Return the qubits on a QPU.""" 106 | return self.qmap[qpu] 107 | 108 | def get_qpu(self, qubit: Qubit): 109 | """Return the QPU of a qubit.""" 110 | for qpu in self.qmap: 111 | if qubit in self.qmap[qpu]: 112 | return qpu 113 | return None 114 | 115 | def create_emap(self): 116 | """Create an emap from the qmap.""" 117 | emap = {} 118 | for qpu in self.qmap: 119 | ereg = QuantumRegister(1, f"com_{qpu}") 120 | emap[qpu] = Qubit(ereg, 0) 121 | return emap 122 | 123 | def get_regs(self): 124 | """Return the QuantumRegisters in the qmap.""" 125 | regs = [] 126 | for qpu in self.qmap: 127 | regs.append(self.qmap[qpu][0].register) 128 | for qpu in self.emap: 129 | regs.append(self.emap[qpu].register) 130 | return regs 131 | 132 | 133 | if __name__ == "__main__": 134 | t = Topology() 135 | -------------------------------------------------------------------------------- /docs/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: bace244aa13016ad14c5055dcacb1045 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/.doctrees/components/circuit_remapper.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/components/circuit_remapper.doctree -------------------------------------------------------------------------------- /docs/.doctrees/components/layer.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/components/layer.doctree -------------------------------------------------------------------------------- /docs/.doctrees/components/topology.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/components/topology.doctree -------------------------------------------------------------------------------- /docs/.doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/.doctrees/examples.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/examples.doctree -------------------------------------------------------------------------------- /docs/.doctrees/examples/CNOT.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/examples/CNOT.doctree -------------------------------------------------------------------------------- /docs/.doctrees/examples/QFT.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/examples/QFT.doctree -------------------------------------------------------------------------------- /docs/.doctrees/examples/Shors.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/examples/Shors.doctree -------------------------------------------------------------------------------- /docs/.doctrees/examples/Topology.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/examples/Topology.doctree -------------------------------------------------------------------------------- /docs/.doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/index.doctree -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples/Topology.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "65935fec", 7 | "metadata": { 8 | "ExecuteTime": { 9 | "end_time": "2023-02-03T08:41:58.274070Z", 10 | "start_time": "2023-02-03T08:41:58.256821Z" 11 | } 12 | }, 13 | "outputs": [], 14 | "source": [ 15 | "from diskit import *\n", 16 | "import warnings\n", 17 | "\n", 18 | "warnings.filterwarnings(\"ignore\")" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "9320634a", 24 | "metadata": { 25 | "collapsed": false 26 | }, 27 | "source": [ 28 | "# Example to create a topology" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "id": "150433fa", 35 | "metadata": { 36 | "collapsed": false 37 | }, 38 | "outputs": [], 39 | "source": [ 40 | "circuit_topo = Topology()\n", 41 | "circuit_topo.create_qmap(3, [2, 3, 3], \"sys\")\n", 42 | "circuit_topo.qmap, circuit_topo.emap" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "id": "169d787d", 48 | "metadata": {}, 49 | "source": [ 50 | "In-built functions to support actions in topology class" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 3, 56 | "id": "afe696b3", 57 | "metadata": { 58 | "ExecuteTime": { 59 | "end_time": "2023-02-03T08:42:00.214160Z", 60 | "start_time": "2023-02-03T08:42:00.197002Z" 61 | } 62 | }, 63 | "outputs": [ 64 | { 65 | "name": "stdout", 66 | "output_type": "stream", 67 | "text": [ 68 | "Total Number of Qubits in Topology : 8\n", 69 | "Total Number of QPUs in Topology: 3\n", 70 | "Qubit(QuantumRegister(3, 'sys1'), 2) and Qubit(QuantumRegister(3, 'sys2'), 1) are not adjacent\n", 71 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 0) --------- Host: sys0\n", 72 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 1) --------- Host: sys0\n", 73 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 0) --------- Host: sys1\n", 74 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 1) --------- Host: sys1\n", 75 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 2) --------- Host: sys1\n", 76 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 0) --------- Host: sys2\n", 77 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 1) --------- Host: sys2\n", 78 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 2) --------- Host: sys2\n" 79 | ] 80 | } 81 | ], 82 | "source": [ 83 | "print(\"Total Number of Qubits in Topology : \", circuit_topo.num_qubits())\n", 84 | "print(\"Total Number of QPUs in Topology: \", circuit_topo.num_hosts())\n", 85 | "\n", 86 | "Qubit1 = circuit_topo.qmap[\"sys1\"][2]\n", 87 | "Qubit2 = circuit_topo.qmap[\"sys2\"][1]\n", 88 | "print(\"{} and {} are adjacent\".format(Qubit1, Qubit2)\n", 89 | " if circuit_topo.are_adjacent(Qubit1, Qubit2) else\n", 90 | " \"{} and {} are not adjacent\".format(Qubit1, Qubit2))\n", 91 | "\n", 92 | "for qubit in circuit_topo.qubits:\n", 93 | " print(\"Qubit: {} --------- Host: {}\".format(qubit, circuit_topo.get_host(qubit)))" 94 | ] 95 | } 96 | ], 97 | "metadata": { 98 | "kernelspec": { 99 | "display_name": "Python 3 (ipykernel)", 100 | "language": "python", 101 | "name": "python3" 102 | }, 103 | "language_info": { 104 | "codemirror_mode": { 105 | "name": "ipython", 106 | "version": 3 107 | }, 108 | "file_extension": ".py", 109 | "mimetype": "text/x-python", 110 | "name": "python", 111 | "nbconvert_exporter": "python", 112 | "pygments_lexer": "ipython3", 113 | "version": "3.7.10" 114 | }, 115 | "toc": { 116 | "base_numbering": 1, 117 | "nav_menu": {}, 118 | "number_sections": true, 119 | "sideBar": true, 120 | "skip_h1_title": false, 121 | "title_cell": "Table of Contents", 122 | "title_sidebar": "Contents", 123 | "toc_cell": false, 124 | "toc_position": {}, 125 | "toc_section_display": true, 126 | "toc_window_display": false 127 | } 128 | }, 129 | "nbformat": 4, 130 | "nbformat_minor": 5 131 | } 132 | -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_11_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_11_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_13_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_13_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_14_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_14_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_19_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_19_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_21_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_21_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_24_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_24_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_28_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_28_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_CNOT_7_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_CNOT_7_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_QFT_12_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_QFT_12_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_QFT_14_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_QFT_14_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_QFT_15_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_QFT_15_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_QFT_28_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_QFT_28_0.png -------------------------------------------------------------------------------- /docs/.doctrees/nbsphinx/examples_QFT_30_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/nbsphinx/examples_QFT_30_0.png -------------------------------------------------------------------------------- /docs/.doctrees/quick_start.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/quick_start.doctree -------------------------------------------------------------------------------- /docs/.doctrees/source.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.doctrees/source.doctree -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/.nojekyll -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/_images/SEG-QPU.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/SEG-QPU.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_11_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_11_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_13_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_13_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_14_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_14_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_19_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_19_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_21_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_21_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_24_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_24_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_28_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_28_0.png -------------------------------------------------------------------------------- /docs/_images/examples_CNOT_7_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_CNOT_7_0.png -------------------------------------------------------------------------------- /docs/_images/examples_QFT_12_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_QFT_12_0.png -------------------------------------------------------------------------------- /docs/_images/examples_QFT_14_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_QFT_14_0.png -------------------------------------------------------------------------------- /docs/_images/examples_QFT_15_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_QFT_15_0.png -------------------------------------------------------------------------------- /docs/_images/examples_QFT_28_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_QFT_28_0.png -------------------------------------------------------------------------------- /docs/_images/examples_QFT_30_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_images/examples_QFT_30_0.png -------------------------------------------------------------------------------- /docs/_sources/components/circuit_remapper.rst.txt: -------------------------------------------------------------------------------- 1 | Circuit Remapper 2 | ================ 3 | 4 | .. automodule:: diskit.circuit_remapper 5 | :members: -------------------------------------------------------------------------------- /docs/_sources/components/layer.rst.txt: -------------------------------------------------------------------------------- 1 | Layer 2 | ===== 3 | 4 | .. automodule:: diskit.components.layer 5 | :members: -------------------------------------------------------------------------------- /docs/_sources/components/topology.rst.txt: -------------------------------------------------------------------------------- 1 | Topology 2 | ======== 3 | 4 | .. automodule:: diskit.components.topology 5 | :members: -------------------------------------------------------------------------------- /docs/_sources/examples.rst.txt: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | .. toctree:: 5 | 6 | examples/Topology 7 | examples/CNOT 8 | examples/QFT 9 | examples/Shors -------------------------------------------------------------------------------- /docs/_sources/examples/Topology.ipynb.txt: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "65935fec", 7 | "metadata": { 8 | "ExecuteTime": { 9 | "end_time": "2023-02-03T08:41:58.274070Z", 10 | "start_time": "2023-02-03T08:41:58.256821Z" 11 | } 12 | }, 13 | "outputs": [], 14 | "source": [ 15 | "from diskit import *\n", 16 | "import warnings\n", 17 | "\n", 18 | "warnings.filterwarnings(\"ignore\")" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "source": [ 24 | "# Example to create a topology" 25 | ], 26 | "metadata": { 27 | "collapsed": false 28 | } 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "outputs": [], 34 | "source": [ 35 | "circuit_topo = Topology()\n", 36 | "circuit_topo.create_qmap(3, [2, 3, 3], \"sys\")\n", 37 | "circuit_topo.qmap, circuit_topo.emap" 38 | ], 39 | "metadata": { 40 | "collapsed": false 41 | } 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "id": "169d787d", 46 | "metadata": {}, 47 | "source": [ 48 | "In-built functions to support actions in topology class" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 3, 54 | "id": "afe696b3", 55 | "metadata": { 56 | "ExecuteTime": { 57 | "end_time": "2023-02-03T08:42:00.214160Z", 58 | "start_time": "2023-02-03T08:42:00.197002Z" 59 | } 60 | }, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Total Number of Qubits in Topology : 8\n", 67 | "Total Number of QPUs in Topology: 3\n", 68 | "Qubit(QuantumRegister(3, 'sys1'), 2) and Qubit(QuantumRegister(3, 'sys2'), 1) are not adjacent\n", 69 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 0) --------- Host: sys0\n", 70 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 1) --------- Host: sys0\n", 71 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 0) --------- Host: sys1\n", 72 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 1) --------- Host: sys1\n", 73 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 2) --------- Host: sys1\n", 74 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 0) --------- Host: sys2\n", 75 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 1) --------- Host: sys2\n", 76 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 2) --------- Host: sys2\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "print(\"Total Number of Qubits in Topology : \", circuit_topo.num_qubits())\n", 82 | "print(\"Total Number of QPUs in Topology: \", circuit_topo.num_hosts())\n", 83 | "\n", 84 | "Qubit1 = circuit_topo.qmap[\"sys1\"][2]\n", 85 | "Qubit2 = circuit_topo.qmap[\"sys2\"][1]\n", 86 | "print(\"{} and {} are adjacent\".format(Qubit1, Qubit2)\n", 87 | " if circuit_topo.are_adjacent(Qubit1, Qubit2) else\n", 88 | " \"{} and {} are not adjacent\".format(Qubit1, Qubit2))\n", 89 | "\n", 90 | "for qubit in circuit_topo.qubits:\n", 91 | " print(\"Qubit: {} --------- Host: {}\".format(qubit, circuit_topo.get_host(qubit)))" 92 | ] 93 | } 94 | ], 95 | "metadata": { 96 | "kernelspec": { 97 | "display_name": "Python 3 (ipykernel)", 98 | "language": "python", 99 | "name": "python3" 100 | }, 101 | "language_info": { 102 | "codemirror_mode": { 103 | "name": "ipython", 104 | "version": 3 105 | }, 106 | "file_extension": ".py", 107 | "mimetype": "text/x-python", 108 | "name": "python", 109 | "nbconvert_exporter": "python", 110 | "pygments_lexer": "ipython3", 111 | "version": "3.7.10" 112 | }, 113 | "toc": { 114 | "base_numbering": 1, 115 | "nav_menu": {}, 116 | "number_sections": true, 117 | "sideBar": true, 118 | "skip_h1_title": false, 119 | "title_cell": "Table of Contents", 120 | "title_sidebar": "Contents", 121 | "toc_cell": false, 122 | "toc_position": {}, 123 | "toc_section_display": true, 124 | "toc_window_display": false 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 5 129 | } 130 | -------------------------------------------------------------------------------- /docs/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | Welcome to Diskit documentation! 2 | ================================ 3 | 4 | 5 | .. toctree:: 6 | :caption: Contents 7 | :includehidden: 8 | :maxdepth: 2 9 | 10 | quick_start 11 | examples 12 | source 13 | 14 | Introduction 15 | ============ 16 | 17 | Distributed quantum computing is a concept that proposes to connect multiple quantum computers in a network to leverage a collection of more, but physically separated, qubits. In order to perform distributed quantum computing, it is necessary to add the addition of classical communication and entanglement distribution so that the control information from one qubit can be applied to another that is located on another quantum computer. For more details on distributed quantum computing, see this blog post: `Distributed Quantum Computing: A path to large scale quantum computing `_ 18 | 19 | In this project, we aim to validate distributed quantum algorithms using Qiskit. Because Qiskit does not yet come with networking features, we embed a "virtual network topology" into large circuits to mimic distributed quantum computing. The idea is to take a monolithic quantum circuit developed in the Qiskit language and distribute the circuit according to an artificially segmented version of a quantum processor. The inputs to the library are a quantum algorithm written monolithically (i.e., in a single circuit) and a topology parameter that represents the artificial segmentation of the single quantum processor. 20 | 21 | The algorithm takes these two inputs and remaps the Qiskit circuit to the specified segmentation, adding all necessary steps to perform an equivalent distributed quantum circuit. Our algorithm for achieving this is based on the work: `Distributed Quantum Computing and Network Control for Accelerated VQE 22 | `_. The algorithm output is another Qiskit circuit with the equivalent measurement statistics but with all of the additional logic needed to perform a distributed version. 23 | 24 | .. figure:: ./images/SEG-QPU.png 25 | :align: center 26 | :width: 500 27 | :alt: Segmented QPU 28 | 29 | The algorithm proposed in the linked work is not yet optimized, and so we encourage users to contribute by adding other methods of distributing circuits to the library. 30 | -------------------------------------------------------------------------------- /docs/_sources/quick_start.rst.txt: -------------------------------------------------------------------------------- 1 | Quickstart 2 | ========== 3 | 4 | Diskit is available as a PyPi project and is can be installed with ``pip``. :: 5 | 6 | pip install diskit 7 | 8 | Diskit relies on Qiskit and therefore it should also be installed. 9 | Once installed, to generate a distributed circuit, one can simply generate a topology, 10 | create the circuit, perform the remapping, and run it as usual. :: 11 | 12 | from diskit import * 13 | 14 | network_topology = Topology() 15 | network_topology.create_qmap(2, [1, 1], "sys") 16 | qregs = circuit_topo.get_regs() 17 | 18 | qc = QuantumCircuit(*qregs) 19 | # Qubit 0 is on QPU 1, qubit 1 on QPU 2 20 | qc.h(0) 21 | qc.cx(0, 1) 22 | 23 | remapper = CircuitRemapper(circuit_topo) 24 | dist_circ = remapper.remap_circuit(qc) 25 | -------------------------------------------------------------------------------- /docs/_sources/source.rst.txt: -------------------------------------------------------------------------------- 1 | ################## 2 | Components 3 | ################## 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | :glob: 8 | 9 | components/* -------------------------------------------------------------------------------- /docs/_static/_sphinx_javascript_frameworks_compat.js: -------------------------------------------------------------------------------- 1 | /* 2 | * _sphinx_javascript_frameworks_compat.js 3 | * ~~~~~~~~~~ 4 | * 5 | * Compatability shim for jQuery and underscores.js. 6 | * 7 | * WILL BE REMOVED IN Sphinx 6.0 8 | * xref RemovedInSphinx60Warning 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | 18 | /** 19 | * small helper function to urldecode strings 20 | * 21 | * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL 22 | */ 23 | jQuery.urldecode = function(x) { 24 | if (!x) { 25 | return x 26 | } 27 | return decodeURIComponent(x.replace(/\+/g, ' ')); 28 | }; 29 | 30 | /** 31 | * small helper function to urlencode strings 32 | */ 33 | jQuery.urlencode = encodeURIComponent; 34 | 35 | /** 36 | * This function returns the parsed url parameters of the 37 | * current request. Multiple values per key are supported, 38 | * it will always return arrays of strings for the value parts. 39 | */ 40 | jQuery.getQueryParameters = function(s) { 41 | if (typeof s === 'undefined') 42 | s = document.location.search; 43 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 44 | var result = {}; 45 | for (var i = 0; i < parts.length; i++) { 46 | var tmp = parts[i].split('=', 2); 47 | var key = jQuery.urldecode(tmp[0]); 48 | var value = jQuery.urldecode(tmp[1]); 49 | if (key in result) 50 | result[key].push(value); 51 | else 52 | result[key] = [value]; 53 | } 54 | return result; 55 | }; 56 | 57 | /** 58 | * highlight a given string on a jquery object by wrapping it in 59 | * span elements with the given class name. 60 | */ 61 | jQuery.fn.highlightText = function(text, className) { 62 | function highlight(node, addItems) { 63 | if (node.nodeType === 3) { 64 | var val = node.nodeValue; 65 | var pos = val.toLowerCase().indexOf(text); 66 | if (pos >= 0 && 67 | !jQuery(node.parentNode).hasClass(className) && 68 | !jQuery(node.parentNode).hasClass("nohighlight")) { 69 | var span; 70 | var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); 71 | if (isInSVG) { 72 | span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); 73 | } else { 74 | span = document.createElement("span"); 75 | span.className = className; 76 | } 77 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 78 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 79 | document.createTextNode(val.substr(pos + text.length)), 80 | node.nextSibling)); 81 | node.nodeValue = val.substr(0, pos); 82 | if (isInSVG) { 83 | var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); 84 | var bbox = node.parentElement.getBBox(); 85 | rect.x.baseVal.value = bbox.x; 86 | rect.y.baseVal.value = bbox.y; 87 | rect.width.baseVal.value = bbox.width; 88 | rect.height.baseVal.value = bbox.height; 89 | rect.setAttribute('class', className); 90 | addItems.push({ 91 | "parent": node.parentNode, 92 | "target": rect}); 93 | } 94 | } 95 | } 96 | else if (!jQuery(node).is("button, select, textarea")) { 97 | jQuery.each(node.childNodes, function() { 98 | highlight(this, addItems); 99 | }); 100 | } 101 | } 102 | var addItems = []; 103 | var result = this.each(function() { 104 | highlight(this, addItems); 105 | }); 106 | for (var i = 0; i < addItems.length; ++i) { 107 | jQuery(addItems[i].parent).before(addItems[i].target); 108 | } 109 | return result; 110 | }; 111 | 112 | /* 113 | * backward compatibility for jQuery.browser 114 | * This will be supported until firefox bug is fixed. 115 | */ 116 | if (!jQuery.browser) { 117 | jQuery.uaMatch = function(ua) { 118 | ua = ua.toLowerCase(); 119 | 120 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 121 | /(webkit)[ \/]([\w.]+)/.exec(ua) || 122 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 123 | /(msie) ([\w.]+)/.exec(ua) || 124 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 125 | []; 126 | 127 | return { 128 | browser: match[ 1 ] || "", 129 | version: match[ 2 ] || "0" 130 | }; 131 | }; 132 | jQuery.browser = {}; 133 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; 134 | } 135 | -------------------------------------------------------------------------------- /docs/_static/css/badge_only.css: -------------------------------------------------------------------------------- 1 | .clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/Roboto-Slab-Bold.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/Roboto-Slab-Bold.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/Roboto-Slab-Regular.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/Roboto-Slab-Regular.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-bold-italic.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-bold-italic.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-bold.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-bold.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-normal-italic.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-normal-italic.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-normal.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/css/fonts/lato-normal.woff2 -------------------------------------------------------------------------------- /docs/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Base JavaScript utilities for all Sphinx HTML documentation. 6 | * 7 | * :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | "use strict"; 12 | 13 | const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([ 14 | "TEXTAREA", 15 | "INPUT", 16 | "SELECT", 17 | "BUTTON", 18 | ]); 19 | 20 | const _ready = (callback) => { 21 | if (document.readyState !== "loading") { 22 | callback(); 23 | } else { 24 | document.addEventListener("DOMContentLoaded", callback); 25 | } 26 | }; 27 | 28 | /** 29 | * Small JavaScript module for the documentation. 30 | */ 31 | const Documentation = { 32 | init: () => { 33 | Documentation.initDomainIndexTable(); 34 | Documentation.initOnKeyListeners(); 35 | }, 36 | 37 | /** 38 | * i18n support 39 | */ 40 | TRANSLATIONS: {}, 41 | PLURAL_EXPR: (n) => (n === 1 ? 0 : 1), 42 | LOCALE: "unknown", 43 | 44 | // gettext and ngettext don't access this so that the functions 45 | // can safely bound to a different name (_ = Documentation.gettext) 46 | gettext: (string) => { 47 | const translated = Documentation.TRANSLATIONS[string]; 48 | switch (typeof translated) { 49 | case "undefined": 50 | return string; // no translation 51 | case "string": 52 | return translated; // translation exists 53 | default: 54 | return translated[0]; // (singular, plural) translation tuple exists 55 | } 56 | }, 57 | 58 | ngettext: (singular, plural, n) => { 59 | const translated = Documentation.TRANSLATIONS[singular]; 60 | if (typeof translated !== "undefined") 61 | return translated[Documentation.PLURAL_EXPR(n)]; 62 | return n === 1 ? singular : plural; 63 | }, 64 | 65 | addTranslations: (catalog) => { 66 | Object.assign(Documentation.TRANSLATIONS, catalog.messages); 67 | Documentation.PLURAL_EXPR = new Function( 68 | "n", 69 | `return (${catalog.plural_expr})` 70 | ); 71 | Documentation.LOCALE = catalog.locale; 72 | }, 73 | 74 | /** 75 | * helper function to focus on search bar 76 | */ 77 | focusSearchBar: () => { 78 | document.querySelectorAll("input[name=q]")[0]?.focus(); 79 | }, 80 | 81 | /** 82 | * Initialise the domain index toggle buttons 83 | */ 84 | initDomainIndexTable: () => { 85 | const toggler = (el) => { 86 | const idNumber = el.id.substr(7); 87 | const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`); 88 | if (el.src.substr(-9) === "minus.png") { 89 | el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`; 90 | toggledRows.forEach((el) => (el.style.display = "none")); 91 | } else { 92 | el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`; 93 | toggledRows.forEach((el) => (el.style.display = "")); 94 | } 95 | }; 96 | 97 | const togglerElements = document.querySelectorAll("img.toggler"); 98 | togglerElements.forEach((el) => 99 | el.addEventListener("click", (event) => toggler(event.currentTarget)) 100 | ); 101 | togglerElements.forEach((el) => (el.style.display = "")); 102 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler); 103 | }, 104 | 105 | initOnKeyListeners: () => { 106 | // only install a listener if it is really needed 107 | if ( 108 | !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && 109 | !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS 110 | ) 111 | return; 112 | 113 | document.addEventListener("keydown", (event) => { 114 | // bail for input elements 115 | if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; 116 | // bail with special keys 117 | if (event.altKey || event.ctrlKey || event.metaKey) return; 118 | 119 | if (!event.shiftKey) { 120 | switch (event.key) { 121 | case "ArrowLeft": 122 | if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; 123 | 124 | const prevLink = document.querySelector('link[rel="prev"]'); 125 | if (prevLink && prevLink.href) { 126 | window.location.href = prevLink.href; 127 | event.preventDefault(); 128 | } 129 | break; 130 | case "ArrowRight": 131 | if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break; 132 | 133 | const nextLink = document.querySelector('link[rel="next"]'); 134 | if (nextLink && nextLink.href) { 135 | window.location.href = nextLink.href; 136 | event.preventDefault(); 137 | } 138 | break; 139 | } 140 | } 141 | 142 | // some keyboard layouts may need Shift to get / 143 | switch (event.key) { 144 | case "/": 145 | if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break; 146 | Documentation.focusSearchBar(); 147 | event.preventDefault(); 148 | } 149 | }); 150 | }, 151 | }; 152 | 153 | // quick alias for translations 154 | const _ = Documentation.gettext; 155 | 156 | _ready(Documentation.init); 157 | -------------------------------------------------------------------------------- /docs/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: '0.1', 4 | LANGUAGE: 'en', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | LINK_SUFFIX: '.html', 9 | HAS_SOURCE: true, 10 | SOURCELINK_SUFFIX: '.txt', 11 | NAVIGATION_WITH_KEYS: false, 12 | SHOW_SEARCH_SUMMARY: true, 13 | ENABLE_SEARCH_SHORTCUTS: true, 14 | }; -------------------------------------------------------------------------------- /docs/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/file.png -------------------------------------------------------------------------------- /docs/_static/js/badge_only.js: -------------------------------------------------------------------------------- 1 | !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); -------------------------------------------------------------------------------- /docs/_static/js/html5shiv-printshiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/_static/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | !function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("
"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}if(t.length>0){$(".wy-menu-vertical .current").removeClass("current").attr("aria-expanded","false"),t.addClass("current").attr("aria-expanded","true"),t.closest("li.toctree-l1").parent().addClass("current").attr("aria-expanded","true");for(let n=1;n<=10;n++)t.closest("li.toctree-l"+n).addClass("current").attr("aria-expanded","true");t[0].scrollIntoView()}}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current").attr("aria-expanded","false"),e.siblings().find("li.current").removeClass("current").attr("aria-expanded","false");var t=e.find("> ul li");t.length&&(t.removeClass("current").attr("aria-expanded","false"),e.toggleClass("current").attr("aria-expanded",(function(n,e){return"true"==e?"false":"true"})))}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t0 63 | var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 64 | var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 65 | var s_v = "^(" + C + ")?" + v; // vowel in stem 66 | 67 | this.stemWord = function (w) { 68 | var stem; 69 | var suffix; 70 | var firstch; 71 | var origword = w; 72 | 73 | if (w.length < 3) 74 | return w; 75 | 76 | var re; 77 | var re2; 78 | var re3; 79 | var re4; 80 | 81 | firstch = w.substr(0,1); 82 | if (firstch == "y") 83 | w = firstch.toUpperCase() + w.substr(1); 84 | 85 | // Step 1a 86 | re = /^(.+?)(ss|i)es$/; 87 | re2 = /^(.+?)([^s])s$/; 88 | 89 | if (re.test(w)) 90 | w = w.replace(re,"$1$2"); 91 | else if (re2.test(w)) 92 | w = w.replace(re2,"$1$2"); 93 | 94 | // Step 1b 95 | re = /^(.+?)eed$/; 96 | re2 = /^(.+?)(ed|ing)$/; 97 | if (re.test(w)) { 98 | var fp = re.exec(w); 99 | re = new RegExp(mgr0); 100 | if (re.test(fp[1])) { 101 | re = /.$/; 102 | w = w.replace(re,""); 103 | } 104 | } 105 | else if (re2.test(w)) { 106 | var fp = re2.exec(w); 107 | stem = fp[1]; 108 | re2 = new RegExp(s_v); 109 | if (re2.test(stem)) { 110 | w = stem; 111 | re2 = /(at|bl|iz)$/; 112 | re3 = new RegExp("([^aeiouylsz])\\1$"); 113 | re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 114 | if (re2.test(w)) 115 | w = w + "e"; 116 | else if (re3.test(w)) { 117 | re = /.$/; 118 | w = w.replace(re,""); 119 | } 120 | else if (re4.test(w)) 121 | w = w + "e"; 122 | } 123 | } 124 | 125 | // Step 1c 126 | re = /^(.+?)y$/; 127 | if (re.test(w)) { 128 | var fp = re.exec(w); 129 | stem = fp[1]; 130 | re = new RegExp(s_v); 131 | if (re.test(stem)) 132 | w = stem + "i"; 133 | } 134 | 135 | // Step 2 136 | re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; 137 | if (re.test(w)) { 138 | var fp = re.exec(w); 139 | stem = fp[1]; 140 | suffix = fp[2]; 141 | re = new RegExp(mgr0); 142 | if (re.test(stem)) 143 | w = stem + step2list[suffix]; 144 | } 145 | 146 | // Step 3 147 | re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; 148 | if (re.test(w)) { 149 | var fp = re.exec(w); 150 | stem = fp[1]; 151 | suffix = fp[2]; 152 | re = new RegExp(mgr0); 153 | if (re.test(stem)) 154 | w = stem + step3list[suffix]; 155 | } 156 | 157 | // Step 4 158 | re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; 159 | re2 = /^(.+?)(s|t)(ion)$/; 160 | if (re.test(w)) { 161 | var fp = re.exec(w); 162 | stem = fp[1]; 163 | re = new RegExp(mgr1); 164 | if (re.test(stem)) 165 | w = stem; 166 | } 167 | else if (re2.test(w)) { 168 | var fp = re2.exec(w); 169 | stem = fp[1] + fp[2]; 170 | re2 = new RegExp(mgr1); 171 | if (re2.test(stem)) 172 | w = stem; 173 | } 174 | 175 | // Step 5 176 | re = /^(.+?)e$/; 177 | if (re.test(w)) { 178 | var fp = re.exec(w); 179 | stem = fp[1]; 180 | re = new RegExp(mgr1); 181 | re2 = new RegExp(meq1); 182 | re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 183 | if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) 184 | w = stem; 185 | } 186 | re = /ll$/; 187 | re2 = new RegExp(mgr1); 188 | if (re.test(w) && re2.test(w)) { 189 | re = /.$/; 190 | w = w.replace(re,""); 191 | } 192 | 193 | // and turn initial Y back to y 194 | if (firstch == "y") 195 | w = firstch.toLowerCase() + w.substr(1); 196 | return w; 197 | } 198 | } 199 | 200 | -------------------------------------------------------------------------------- /docs/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/minus.png -------------------------------------------------------------------------------- /docs/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/_static/plus.png -------------------------------------------------------------------------------- /docs/_static/pygments.css: -------------------------------------------------------------------------------- 1 | pre { line-height: 125%; } 2 | td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } 3 | span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } 4 | td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 5 | span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 6 | .highlight .hll { background-color: #ffffcc } 7 | .highlight { background: #f8f8f8; } 8 | .highlight .c { color: #3D7B7B; font-style: italic } /* Comment */ 9 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 10 | .highlight .k { color: #008000; font-weight: bold } /* Keyword */ 11 | .highlight .o { color: #666666 } /* Operator */ 12 | .highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ 13 | .highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ 14 | .highlight .cp { color: #9C6500 } /* Comment.Preproc */ 15 | .highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ 16 | .highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ 17 | .highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ 18 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 19 | .highlight .ge { font-style: italic } /* Generic.Emph */ 20 | .highlight .gr { color: #E40000 } /* Generic.Error */ 21 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 22 | .highlight .gi { color: #008400 } /* Generic.Inserted */ 23 | .highlight .go { color: #717171 } /* Generic.Output */ 24 | .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ 25 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 26 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 27 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 28 | .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ 29 | .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ 30 | .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ 31 | .highlight .kp { color: #008000 } /* Keyword.Pseudo */ 32 | .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ 33 | .highlight .kt { color: #B00040 } /* Keyword.Type */ 34 | .highlight .m { color: #666666 } /* Literal.Number */ 35 | .highlight .s { color: #BA2121 } /* Literal.String */ 36 | .highlight .na { color: #687822 } /* Name.Attribute */ 37 | .highlight .nb { color: #008000 } /* Name.Builtin */ 38 | .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ 39 | .highlight .no { color: #880000 } /* Name.Constant */ 40 | .highlight .nd { color: #AA22FF } /* Name.Decorator */ 41 | .highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */ 42 | .highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ 43 | .highlight .nf { color: #0000FF } /* Name.Function */ 44 | .highlight .nl { color: #767600 } /* Name.Label */ 45 | .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ 46 | .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ 47 | .highlight .nv { color: #19177C } /* Name.Variable */ 48 | .highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ 49 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 50 | .highlight .mb { color: #666666 } /* Literal.Number.Bin */ 51 | .highlight .mf { color: #666666 } /* Literal.Number.Float */ 52 | .highlight .mh { color: #666666 } /* Literal.Number.Hex */ 53 | .highlight .mi { color: #666666 } /* Literal.Number.Integer */ 54 | .highlight .mo { color: #666666 } /* Literal.Number.Oct */ 55 | .highlight .sa { color: #BA2121 } /* Literal.String.Affix */ 56 | .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ 57 | .highlight .sc { color: #BA2121 } /* Literal.String.Char */ 58 | .highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ 59 | .highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ 60 | .highlight .s2 { color: #BA2121 } /* Literal.String.Double */ 61 | .highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ 62 | .highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ 63 | .highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ 64 | .highlight .sx { color: #008000 } /* Literal.String.Other */ 65 | .highlight .sr { color: #A45A77 } /* Literal.String.Regex */ 66 | .highlight .s1 { color: #BA2121 } /* Literal.String.Single */ 67 | .highlight .ss { color: #19177C } /* Literal.String.Symbol */ 68 | .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ 69 | .highlight .fm { color: #0000FF } /* Name.Function.Magic */ 70 | .highlight .vc { color: #19177C } /* Name.Variable.Class */ 71 | .highlight .vg { color: #19177C } /* Name.Variable.Global */ 72 | .highlight .vi { color: #19177C } /* Name.Variable.Instance */ 73 | .highlight .vm { color: #19177C } /* Name.Variable.Magic */ 74 | .highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/_static/sphinx_highlight.js: -------------------------------------------------------------------------------- 1 | /* Highlighting utilities for Sphinx HTML documentation. */ 2 | "use strict"; 3 | 4 | const SPHINX_HIGHLIGHT_ENABLED = true 5 | 6 | /** 7 | * highlight a given string on a node by wrapping it in 8 | * span elements with the given class name. 9 | */ 10 | const _highlight = (node, addItems, text, className) => { 11 | if (node.nodeType === Node.TEXT_NODE) { 12 | const val = node.nodeValue; 13 | const parent = node.parentNode; 14 | const pos = val.toLowerCase().indexOf(text); 15 | if ( 16 | pos >= 0 && 17 | !parent.classList.contains(className) && 18 | !parent.classList.contains("nohighlight") 19 | ) { 20 | let span; 21 | 22 | const closestNode = parent.closest("body, svg, foreignObject"); 23 | const isInSVG = closestNode && closestNode.matches("svg"); 24 | if (isInSVG) { 25 | span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); 26 | } else { 27 | span = document.createElement("span"); 28 | span.classList.add(className); 29 | } 30 | 31 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 32 | parent.insertBefore( 33 | span, 34 | parent.insertBefore( 35 | document.createTextNode(val.substr(pos + text.length)), 36 | node.nextSibling 37 | ) 38 | ); 39 | node.nodeValue = val.substr(0, pos); 40 | 41 | if (isInSVG) { 42 | const rect = document.createElementNS( 43 | "http://www.w3.org/2000/svg", 44 | "rect" 45 | ); 46 | const bbox = parent.getBBox(); 47 | rect.x.baseVal.value = bbox.x; 48 | rect.y.baseVal.value = bbox.y; 49 | rect.width.baseVal.value = bbox.width; 50 | rect.height.baseVal.value = bbox.height; 51 | rect.setAttribute("class", className); 52 | addItems.push({ parent: parent, target: rect }); 53 | } 54 | } 55 | } else if (node.matches && !node.matches("button, select, textarea")) { 56 | node.childNodes.forEach((el) => _highlight(el, addItems, text, className)); 57 | } 58 | }; 59 | const _highlightText = (thisNode, text, className) => { 60 | let addItems = []; 61 | _highlight(thisNode, addItems, text, className); 62 | addItems.forEach((obj) => 63 | obj.parent.insertAdjacentElement("beforebegin", obj.target) 64 | ); 65 | }; 66 | 67 | /** 68 | * Small JavaScript module for the documentation. 69 | */ 70 | const SphinxHighlight = { 71 | 72 | /** 73 | * highlight the search words provided in localstorage in the text 74 | */ 75 | highlightSearchWords: () => { 76 | if (!SPHINX_HIGHLIGHT_ENABLED) return; // bail if no highlight 77 | 78 | // get and clear terms from localstorage 79 | const url = new URL(window.location); 80 | const highlight = 81 | localStorage.getItem("sphinx_highlight_terms") 82 | || url.searchParams.get("highlight") 83 | || ""; 84 | localStorage.removeItem("sphinx_highlight_terms") 85 | url.searchParams.delete("highlight"); 86 | window.history.replaceState({}, "", url); 87 | 88 | // get individual terms from highlight string 89 | const terms = highlight.toLowerCase().split(/\s+/).filter(x => x); 90 | if (terms.length === 0) return; // nothing to do 91 | 92 | // There should never be more than one element matching "div.body" 93 | const divBody = document.querySelectorAll("div.body"); 94 | const body = divBody.length ? divBody[0] : document.querySelector("body"); 95 | window.setTimeout(() => { 96 | terms.forEach((term) => _highlightText(body, term, "highlighted")); 97 | }, 10); 98 | 99 | const searchBox = document.getElementById("searchbox"); 100 | if (searchBox === null) return; 101 | searchBox.appendChild( 102 | document 103 | .createRange() 104 | .createContextualFragment( 105 | '" 109 | ) 110 | ); 111 | }, 112 | 113 | /** 114 | * helper function to hide the search marks again 115 | */ 116 | hideSearchWords: () => { 117 | document 118 | .querySelectorAll("#searchbox .highlight-link") 119 | .forEach((el) => el.remove()); 120 | document 121 | .querySelectorAll("span.highlighted") 122 | .forEach((el) => el.classList.remove("highlighted")); 123 | localStorage.removeItem("sphinx_highlight_terms") 124 | }, 125 | 126 | initEscapeListener: () => { 127 | // only install a listener if it is really needed 128 | if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; 129 | 130 | document.addEventListener("keydown", (event) => { 131 | // bail for input elements 132 | if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; 133 | // bail with special keys 134 | if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; 135 | if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { 136 | SphinxHighlight.hideSearchWords(); 137 | event.preventDefault(); 138 | } 139 | }); 140 | }, 141 | }; 142 | 143 | _ready(SphinxHighlight.highlightSearchWords); 144 | _ready(SphinxHighlight.initEscapeListener); 145 | -------------------------------------------------------------------------------- /docs/examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Examples — diskit 0.1 documentation 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 112 | 113 |
117 | 118 |
119 |
120 |
121 | 128 |
129 |
130 |
131 |
132 | 133 | 134 | 157 |
158 |

Examples

159 | 177 |
178 | 179 | 180 |
181 |
182 |
183 | 184 |
185 | 186 |
187 |

© Copyright 2023, Anuranan Das, Stephen DiAdamo.

188 |
189 | 190 | Built with Sphinx using a 191 | theme 192 | provided by Read the Docs. 193 | 194 | 195 |
196 |
197 |
198 |
199 |
200 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /docs/examples/Topology.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "65935fec", 7 | "metadata": { 8 | "ExecuteTime": { 9 | "end_time": "2023-02-03T08:41:58.274070Z", 10 | "start_time": "2023-02-03T08:41:58.256821Z" 11 | } 12 | }, 13 | "outputs": [], 14 | "source": [ 15 | "from diskit import *\n", 16 | "import warnings\n", 17 | "\n", 18 | "warnings.filterwarnings(\"ignore\")" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "9320634a", 24 | "metadata": { 25 | "collapsed": false 26 | }, 27 | "source": [ 28 | "# Example to create a topology" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "id": "150433fa", 35 | "metadata": { 36 | "collapsed": false 37 | }, 38 | "outputs": [], 39 | "source": [ 40 | "circuit_topo = Topology()\n", 41 | "circuit_topo.create_qmap(3, [2, 3, 3], \"sys\")\n", 42 | "circuit_topo.qmap, circuit_topo.emap" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "id": "169d787d", 48 | "metadata": {}, 49 | "source": [ 50 | "In-built functions to support actions in topology class" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 3, 56 | "id": "afe696b3", 57 | "metadata": { 58 | "ExecuteTime": { 59 | "end_time": "2023-02-03T08:42:00.214160Z", 60 | "start_time": "2023-02-03T08:42:00.197002Z" 61 | } 62 | }, 63 | "outputs": [ 64 | { 65 | "name": "stdout", 66 | "output_type": "stream", 67 | "text": [ 68 | "Total Number of Qubits in Topology : 8\n", 69 | "Total Number of QPUs in Topology: 3\n", 70 | "Qubit(QuantumRegister(3, 'sys1'), 2) and Qubit(QuantumRegister(3, 'sys2'), 1) are not adjacent\n", 71 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 0) --------- Host: sys0\n", 72 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 1) --------- Host: sys0\n", 73 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 0) --------- Host: sys1\n", 74 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 1) --------- Host: sys1\n", 75 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 2) --------- Host: sys1\n", 76 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 0) --------- Host: sys2\n", 77 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 1) --------- Host: sys2\n", 78 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 2) --------- Host: sys2\n" 79 | ] 80 | } 81 | ], 82 | "source": [ 83 | "print(\"Total Number of Qubits in Topology : \", circuit_topo.num_qubits())\n", 84 | "print(\"Total Number of QPUs in Topology: \", circuit_topo.num_hosts())\n", 85 | "\n", 86 | "Qubit1 = circuit_topo.qmap[\"sys1\"][2]\n", 87 | "Qubit2 = circuit_topo.qmap[\"sys2\"][1]\n", 88 | "print(\"{} and {} are adjacent\".format(Qubit1, Qubit2)\n", 89 | " if circuit_topo.are_adjacent(Qubit1, Qubit2) else\n", 90 | " \"{} and {} are not adjacent\".format(Qubit1, Qubit2))\n", 91 | "\n", 92 | "for qubit in circuit_topo.qubits:\n", 93 | " print(\"Qubit: {} --------- Host: {}\".format(qubit, circuit_topo.get_host(qubit)))" 94 | ] 95 | } 96 | ], 97 | "metadata": { 98 | "kernelspec": { 99 | "display_name": "Python 3 (ipykernel)", 100 | "language": "python", 101 | "name": "python3" 102 | }, 103 | "language_info": { 104 | "codemirror_mode": { 105 | "name": "ipython", 106 | "version": 3 107 | }, 108 | "file_extension": ".py", 109 | "mimetype": "text/x-python", 110 | "name": "python", 111 | "nbconvert_exporter": "python", 112 | "pygments_lexer": "ipython3", 113 | "version": "3.7.10" 114 | }, 115 | "toc": { 116 | "base_numbering": 1, 117 | "nav_menu": {}, 118 | "number_sections": true, 119 | "sideBar": true, 120 | "skip_h1_title": false, 121 | "title_cell": "Table of Contents", 122 | "title_sidebar": "Contents", 123 | "toc_cell": false, 124 | "toc_position": {}, 125 | "toc_section_display": true, 126 | "toc_window_display": false 127 | } 128 | }, 129 | "nbformat": 4, 130 | "nbformat_minor": 5 131 | } 132 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/objects.inv -------------------------------------------------------------------------------- /docs/py-modindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Python Module Index — diskit 0.1 documentation 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 112 | 113 |
117 | 118 |
119 |
120 |
121 |
    122 |
  • 123 | 124 |
  • 125 |
  • 126 |
127 |
128 |
129 |
130 |
131 | 132 | 133 |

Python Module Index

134 | 135 |
136 | d 137 |
138 | 139 | 140 | 141 | 143 | 144 | 146 | 149 | 150 | 151 | 154 | 155 | 156 | 159 | 160 | 161 | 164 |
 
142 | d
147 | diskit 148 |
    152 | diskit.circuit_remapper 153 |
    157 | diskit.components.layer 158 |
    162 | diskit.components.topology 163 |
165 | 166 | 167 |
168 |
169 |
170 | 171 |
172 | 173 |
174 |

© Copyright 2023, Anuranan Das, Stephen DiAdamo.

175 |
176 | 177 | Built with Sphinx using a 178 | theme 179 | provided by Read the Docs. 180 | 181 | 182 |
183 |
184 |
185 |
186 |
187 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /docs/quick_start.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Quickstart — diskit 0.1 documentation 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 112 | 113 |
117 | 118 |
119 |
120 |
121 | 128 |
129 |
130 |
131 |
132 | 133 | 134 | 157 |
158 |

Quickstart

159 |

Diskit is available as a PyPi project and is can be installed with pip.

160 |
pip install diskit
161 | 
162 |
163 |

Diskit relies on Qiskit and therefore it should also be installed. 164 | Once installed, to generate a distributed circuit, one can simply generate a topology, 165 | create the circuit, perform the remapping, and run it as usual.

166 |
from diskit import *
167 | 
168 | network_topology = Topology()
169 | network_topology.create_qmap(2, [1, 1], "sys")
170 | qregs = circuit_topo.get_regs()
171 | 
172 | qc = QuantumCircuit(*qregs)
173 | # Qubit 0 is on QPU 1, qubit 1 on QPU 2
174 | qc.h(0)
175 | qc.cx(0, 1)
176 | 
177 | remapper = CircuitRemapper(circuit_topo)
178 | dist_circ = remapper.remap_circuit(qc)
179 | 
180 |
181 |
182 | 183 | 184 |
185 |
186 |
187 | 188 |
189 | 190 |
191 |

© Copyright 2023, Anuranan Das, Stephen DiAdamo.

192 |
193 | 194 | Built with Sphinx using a 195 | theme 196 | provided by Read the Docs. 197 | 198 | 199 |
200 |
201 |
202 |
203 |
204 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /docs/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Search — diskit 0.1 documentation 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 112 | 113 |
117 | 118 |
119 |
120 |
121 |
    122 |
  • 123 | 124 |
  • 125 |
  • 126 |
127 |
128 |
129 |
130 |
131 | 132 | 139 | 140 | 141 |
142 | 143 |
144 | 145 |
146 |
147 |
148 | 149 |
150 | 151 |
152 |

© Copyright 2023, Anuranan Das, Stephen DiAdamo.

153 |
154 | 155 | Built with Sphinx using a 156 | theme 157 | provided by Read the Docs. 158 | 159 | 160 |
161 |
162 |
163 |
164 |
165 | 170 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /docs/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({"docnames": ["components/circuit_remapper", "components/layer", "components/topology", "examples", "examples/CNOT", "examples/QFT", "examples/Shors", "examples/Topology", "index", "quick_start", "source"], "filenames": ["components/circuit_remapper.rst", "components/layer.rst", "components/topology.rst", "examples.rst", "examples/CNOT.ipynb", "examples/QFT.ipynb", "examples/Shors.ipynb", "examples/Topology.ipynb", "index.rst", "quick_start.rst", "source.rst"], "titles": ["Circuit Remapper", "Layer", "Topology", "Examples", "Distributed Circuit for a CNOT gates", "Distributed Quantum Fourier Transform", "Distribute Shor\u2019s Algorithm", "Example to create a topology", "Welcome to Diskit documentation!", "Quickstart", "Components"], "terms": {"The": [0, 2, 3, 6, 8], "logic": [0, 8], "class": [0, 1, 2, 7], "diskit": [0, 1, 2, 4, 5, 6, 7, 9], "circuit_remapp": [0, 4], "circuitremapp": [0, 4, 5, 6, 9, 10], "topologi": [0, 1, 3, 4, 5, 6, 8, 9, 10], "remap": [0, 8, 9], "ciruit": 0, "static": 0, "collate_measur": 0, "sim_result": 0, "dict": [0, 2], "num_qubit": [0, 2, 5, 7], "int": [0, 1, 2, 6], "collat": 0, "measur": [0, 6, 8], "from": [0, 1, 2, 4, 5, 6, 7, 8, 9], "simul": [0, 6], "result": [0, 4, 5, 6], "param": [], "number": [0, 2, 5, 6, 7], "qubit": [0, 1, 2, 3, 4, 6, 7, 8, 9], "return": [0, 1, 2, 5, 6], "A": [0, 6, 8], "dictionari": 0, "do_measure_readi": 0, "circ": [0, 6], "quantumcircuit": [0, 4, 5, 6, 9], "make": [0, 6], "i": [0, 1, 2, 4, 6, 8, 9], "readi": [0, 4], "network": [0, 8], "remap_circuit": [0, 4, 5, 6, 9], "decompos": [0, 4, 5, 6], "option": [0, 1, 2], "bool": [0, 1], "none": [0, 1, 2], "decompose_list": [0, 4], "list": [0, 1, 2, 6], "str": [0, 2], "distribut": [0, 2, 3, 8, 9], "over": [0, 6], "compat": 0, "2": [0, 3, 4, 6, 7, 9], "gate": [0, 1, 3, 5, 6, 8], "possibl": 0, "name": [0, 2, 6], "which": [0, 1, 4, 6], "should": [0, 6, 9], "object": [1, 2, 4], "collect": [1, 8], "oper": [1, 6], "appli": [1, 8], "system": 1, "compon": [1, 2, 8], "circuitinstruct": 1, "add_oper": 1, "add": [1, 2, 5, 8], "an": [1, 2, 4, 6, 8], "inform": [1, 6, 8], "about": [1, 6], "ad": [1, 8], "type": 1, "multipl": [1, 6, 8], "paramet": [0, 1, 8], "non_local_oper": 1, "check": [1, 4, 5, 6], "control": [1, 4, 5, 6, 8], "present": 1, "between": [1, 6], "two": [1, 6, 8], "differ": [1, 6], "comput": [1, 2, 6, 8], "host": [1, 2, 7], "true": [1, 2, 4, 6], "properti": [1, 2], "get": [1, 4, 5, 6], "contain": [1, 4], "perform": [1, 3, 4, 6, 8, 9], "quantum": [1, 2, 3, 6, 8], "circuit": [1, 3, 6, 8, 9, 10], "remove_oper": 1, "index": 1, "remov": [1, 2], "map": 2, "qmap": [2, 4, 5, 6, 7], "architectur": 2, "add_qpu": 2, "qpu": [2, 6, 7, 9], "qreg": [2, 4, 5, 6, 9], "indic": 2, "are_adjac": [2, 7], "qubit1": [2, 7], "qubit2": [2, 7], "ar": [2, 4, 6, 7, 8], "adjac": [2, 7], "create_emap": 2, "creat": [2, 3, 4, 6, 8, 9], "emap": [2, 4, 5, 6, 7], "create_qmap": [2, 4, 5, 6, 7, 9], "num_qpu": 2, "each": [2, 5, 6], "get_all_qubit": 2, "all": [2, 6, 8], "get_epr_id": 2, "epr": 2, "id": [2, 6], "get_host": [2, 7], "get_qpu": 2, "get_qubit": 2, "get_reg": [2, 4, 5, 6, 9], "quantumregist": [2, 4, 5, 6, 7], "num_host": [2, 7], "total": [2, 3, 7], "reiniti": 2, "provid": [2, 6], "new": 2, "remove_qpu": 2, "cnot": [3, 5, 8], "case": [3, 5, 6], "higher": 3, "order": [3, 8], "fourier": [3, 6, 8], "transform": [3, 6, 8], "For": [3, 8], "processor": [3, 4, 8], "4": [3, 4, 6], "16": [3, 4], "shor": [3, 8], "": [3, 4, 8], "algorithm": [3, 8], "import": [4, 5, 6, 7, 9], "qiskit": [4, 5, 6, 8, 9], "assembl": [4, 5, 6], "aer": [4, 5, 6], "visual": [4, 5], "plot_bloch_multivector": [4, 5], "warn": [4, 5, 7], "filterwarn": [4, 5, 7], "ignor": [4, 5, 7], "defin": [4, 5], "3": [4, 5, 6, 7], "circuit_topo": [4, 5, 6, 7, 9], "sys_cnot": 4, "39": [4, 5, 6, 7], "sys_cnot0": 4, "0": [4, 5, 6, 7, 9], "1": [4, 5, 6, 7, 9], "sys_cnot1": 4, "com_sys_cnot0": 4, "com_sys_cnot1": 4, "regist": [4, 5, 6], "monolith": [4, 5, 6, 8], "qc": [4, 6, 9], "h": [4, 5, 6, 9], "cx": [4, 6, 9], "draw": [4, 5], "mpl": [4, 5], "remapp": [4, 5, 6, 8, 9, 10], "base": [4, 8], "5": [4, 5, 6], "convert": 4, "6": [4, 5, 6], "dist_circ": [4, 6, 9], "output": [4, 5, 8], "If": 4, "consecut": 4, "same": 4, "target": 4, "we": [4, 5, 6, 8], "can": [4, 6, 8, 9], "do": [4, 5, 6], "onli": 4, "onc": [4, 9], "let": [4, 5], "look": 4, "follow": 4, "exampl": [4, 6, 8], "7": [4, 5, 6], "qc2": 4, "8": [4, 5, 6, 7], "dist_circ2": 4, "u": [4, 5, 6], "valid": [4, 5, 8], "work": [4, 5, 8], "version": [4, 5, 6, 8], "first": [4, 5, 6], "9": [4, 6], "quantum_info": [4, 5], "partial_trac": [4, 5], "10": [4, 5, 6], "sim": [4, 5], "get_backend": [4, 5, 6], "aer_simul": [4, 5, 6], "11": [4, 5, 6], "qc2_copi": 4, "copi": [4, 5], "save_statevector": [4, 5], "qobj": [4, 5, 6], "state": [4, 5, 6], "run": [4, 5, 6, 9], "get_statevector": [4, 5], "trace": [4, 5], "out": [4, 5], "commun": [4, 5, 8], "now": [4, 5, 6], "12": [4, 5, 6], "dqc2_copi": [4, 5], "As": 4, "seen": 4, "both": 4, "equival": [4, 8], "In": [4, 6, 7, 8], "more": [4, 6, 8], "than": 4, "shall": [4, 5], "need": [4, 5, 6, 8], "13": [4, 5, 6], "ccx": 4, "try": [4, 6], "abov": 4, "error": 4, "15": [4, 5, 6], "circuiterror": 4, "traceback": 4, "most": 4, "recent": 4, "call": [4, 5], "last": 4, "appdata": 4, "local": 4, "temp": 4, "ipykernel_23916": 4, "250667637": 4, "py": 4, "lt": 4, "modul": 4, "gt": 4, "e": [4, 8], "distributed_qiskit": 4, "self": 4, "221": 4, "incompat": 4, "222": 4, "rais": [4, 6], "223": 4, "34": 4, "pleas": 4, "keyword": 4, "argument": 4, "224": 4, "225": 4, "layer": [4, 8, 10], "_circuit_to_lay": 4, "To": [4, 6], "bypass": 4, "one": [4, 6, 8, 9], "put": 4, "iter": [4, 6], "decomposit": [4, 6], "until": [4, 6], "numpi": [5, 6], "np": [5, 6], "function": [5, 6, 7], "construct": 5, "def": [5, 6], "qft_rotat": 5, "n": [5, 6], "phase": [5, 6], "per": 5, "qft": [5, 6], "rang": [5, 6], "cp": [5, 6], "pi": [5, 6], "recurs": 5, "swap_regist": 5, "swap": [5, 6], "scheme": 5, "transpile_swap": 5, "fals": [5, 6], "have": [5, 6], "sys_qft": 5, "sys_qft0": 5, "sys_qft1": 5, "com_sys_qft0": 5, "com_sys_qft1": 5, "n_q": 5, "rangl": [5, 6], "circ_1": 5, "qft_circ": 5, "befor": [5, 6], "translat": 5, "dist_circ_1": 5, "19": 5, "sys_qft2": 5, "sys_qft3": 5, "com_sys_qft2": 5, "com_sys_qft3": 5, "20": 5, "21": 5, "22": 5, "circ_2": 5, "23": 5, "dist_circ_2": 5, "24": 5, "28": 5, "circ2_copi": 5, "29": 5, "random": 6, "randint": 6, "fraction": 6, "transpil": 6, "classicalregist": 6, "code": 6, "build": 6, "factor": 6, "taken": 6, "librari": [6, 8], "http": 6, "org": 6, "textbook": 6, "ch": 6, "html": 6, "thi": [6, 8], "solv": 6, "period": 6, "find": 6, "problem": 6, "where": 6, "y": 6, "ai": 6, "bmod": 6, "without": 6, "explan": 6, "x": 6, "simpli": [6, 9], "repeat": 6, "time": 6, "next": 6, "section": 6, "discuss": 6, "gener": [6, 9], "method": [6, 8], "effici": 6, "c_amod15": 6, "power": 6, "mod": 6, "valueerror": 6, "must": 6, "q": 6, "to_gat": 6, "c_u": 6, "also": [6, 9], "you": 6, "read": 6, "chapter": 6, "qft_dagger": 6, "qftdagger": 6, "don": 6, "t": 6, "forget": 6, "j": 6, "m": 6, "float": 6, "Not": 6, "difficult": 6, "spot": 6, "even": 6, "instantli": 6, "know": 6, "its": 6, "fact": 6, "specif": 6, "criteria": 6, "choos": 6, "basic": 6, "idea": [6, 8], "product": 6, "larg": [6, 8], "prime": 6, "see": [6, 8], "shortcut": 6, "integ": 6, "form": 6, "b": 6, "us": [6, 8], "worst": 6, "scenario": 6, "sinc": 6, "aim": [6, 8], "focu": 6, "part": 6, "jump": 6, "straight": 6, "small": 6, "so": [6, 8], "count": 6, "geq": 6, "step": [6, 8], "seed": 6, "sure": 6, "reproduc": 6, "print": [6, 7], "quickli": 6, "isn": 6, "alreadi": 6, "non": 6, "trivial": 6, "math": 6, "gcd": 6, "greatest": 6, "common": 6, "divisor": 6, "At": 6, "implement": 6, "qpe_amod15": 6, "n_count": 6, "initi": 6, "And": 6, "auxiliari": 6, "append": 6, "invers": 6, "aer_sim": 6, "set": 6, "memori": 6, "below": 6, "allow": 6, "sequenti": 6, "t_qc": 6, "shot": 6, "get_memori": 6, "correspond": 6, "f": 6, "modifi": 6, "conveni": 6, "minim": 6, "chang": 6, "structur": 6, "data": 6, "qpe_amod15_dist": 6, "manipul": 6, "readout": 6, "exclud": 6, "cat_measur": 6, "final_read": 6, "split": 6, "len": 6, "again": 6, "sys_shor": 6, "sys_shor0": 6, "sys_shor1": 6, "com_sys_shor0": 6, "com_sys_shor1": 6, "easili": 6, "guess": 6, "r": 6, "limit_denomin": 6, "denomin": 6, "hopefulli": 6, "tell": 6, "singl": [6, 8], "level": 6, "cutoff": 6, "minut": 6, "reach": 6, "basi": 6, "u1": 6, "u2": 6, "u3": 6, "11000000": 6, "750000": 6, "frac": 6, "numer": 6, "might": 6, "abl": 6, "mean": 6, "divid": 6, "write": 6, "cannot": 6, "go": 6, "further": 6, "valu": 6, "There": 6, "high": 6, "probabl": 6, "either": 6, "proper": 6, "cell": 6, "least": 6, "found": 6, "14": 6, "factor_found": 6, "attempt": 6, "while": 6, "nattempt": 6, "_": 6, "01000000": 6, "250000": 6, "refer": 6, "stephan": 6, "beauregard": 6, "2n": 6, "arxiv": 6, "quant": 6, "ph": 6, "0205095": 6, "nielsen": 6, "chuang": 6, "cambridg": 6, "seri": 6, "natur": 6, "scienc": 6, "univers": 6, "press": 6, "2000": 6, "page": 6, "633": 6, "sy": [7, 9], "built": 7, "support": 7, "action": 7, "sys1": 7, "sys2": 7, "format": 7, "els": 7, "sys0": 7, "quickstart": 8, "concept": 8, "propos": 8, "connect": 8, "leverag": 8, "physic": 8, "separ": 8, "necessari": 8, "addit": 8, "classic": 8, "entangl": 8, "anoth": 8, "locat": 8, "detail": 8, "blog": 8, "post": 8, "path": 8, "scale": 8, "project": [8, 9], "becaus": 8, "doe": 8, "yet": 8, "come": 8, "featur": 8, "emb": 8, "virtual": 8, "mimic": 8, "take": 8, "develop": 8, "languag": 8, "accord": 8, "artifici": 8, "segment": 8, "input": 8, "written": 8, "repres": 8, "specifi": 8, "our": 8, "achiev": 8, "acceler": 8, "vqe": 8, "statist": 8, "link": 8, "optim": 8, "encourag": 8, "user": 8, "contribut": 8, "other": 8, "avail": 9, "pypi": 9, "instal": 9, "pip": 9, "reli": 9, "therefor": 9, "usual": 9, "network_topologi": 9}, "objects": {"diskit": [[0, 0, 0, "-", "circuit_remapper"]], "diskit.circuit_remapper": [[0, 1, 1, "", "CircuitRemapper"]], "diskit.circuit_remapper.CircuitRemapper": [[0, 2, 1, "", "collate_measurements"], [0, 2, 1, "", "do_measure_ready"], [0, 2, 1, "", "remap_circuit"]], "diskit.components": [[1, 0, 0, "-", "layer"], [2, 0, 0, "-", "topology"]], "diskit.components.layer": [[1, 1, 1, "", "Layer"]], "diskit.components.layer.Layer": [[1, 2, 1, "", "add_operation"], [1, 2, 1, "", "add_operations"], [1, 2, 1, "", "non_local_operations"], [1, 3, 1, "", "operations"], [1, 2, 1, "", "remove_operation"]], "diskit.components.topology": [[2, 1, 1, "", "Topology"]], "diskit.components.topology.Topology": [[2, 2, 1, "", "add_qpu"], [2, 2, 1, "", "are_adjacent"], [2, 2, 1, "", "create_emap"], [2, 2, 1, "", "create_qmap"], [2, 2, 1, "", "get_all_qubits"], [2, 2, 1, "", "get_epr_id"], [2, 2, 1, "", "get_host"], [2, 2, 1, "", "get_qpu"], [2, 2, 1, "", "get_qubits"], [2, 2, 1, "", "get_regs"], [2, 2, 1, "", "num_hosts"], [2, 2, 1, "", "num_qubits"], [2, 3, 1, "", "qmap"], [2, 2, 1, "", "reinitialize"], [2, 2, 1, "", "remove_qpu"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method", "3": "py:property"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"], "3": ["py", "property", "Python property"]}, "titleterms": {"circuit": [0, 4, 5], "remapp": 0, "layer": 1, "topologi": [2, 7], "exampl": [3, 7], "distribut": [4, 5, 6], "cnot": 4, "gate": 4, "The": 4, "case": 4, "higher": 4, "order": 4, "quantum": 5, "fourier": 5, "transform": 5, "creat": [5, 7], "perform": 5, "For": 5, "2": 5, "processor": 5, "4": 5, "qubit": 5, "total": 5, "16": 5, "shor": 6, "": 6, "algorithm": 6, "welcom": 8, "diskit": 8, "document": 8, "content": 8, "introduct": 8, "quickstart": 9, "compon": 10}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "nbsphinx": 4, "sphinx": 57}, "alltitles": {"Topology": [[2, "module-diskit.components.topology"]], "Examples": [[3, "examples"]], "Distributed Circuit for a CNOT gates": [[4, "Distributed-Circuit-for-a-CNOT-gates"]], "The case of higher order gates": [[4, "The-case-of-higher-order-gates"]], "Distributed Quantum Fourier Transform": [[5, "Distributed-Quantum-Fourier-Transform"]], "Create a Distributed Circuit for performing Quantum Fourier Transform": [[5, "Create-a-Distributed-Circuit-for-performing-Quantum-Fourier-Transform"]], "For 2 processor with 4 qubits": [[5, "For-2-processor-with-4-qubits"]], "For 4 processors with total 16 qubits": [[5, "For-4-processors-with-total-16-qubits"]], "Distribute Shor\u2019s Algorithm": [[6, "Distribute-Shor\u2019s-Algorithm"]], "Example to create a topology": [[7, "Example-to-create-a-topology"]], "Welcome to Diskit documentation!": [[8, "welcome-to-diskit-documentation"]], "Contents": [[8, null]], "Introduction": [[8, "introduction"]], "Quickstart": [[9, "quickstart"]], "Components": [[10, "components"]], "Circuit Remapper": [[0, "module-diskit.circuit_remapper"]], "Layer": [[1, "module-diskit.components.layer"]]}, "indexentries": {"circuitremapper (class in diskit.circuit_remapper)": [[0, "diskit.circuit_remapper.CircuitRemapper"]], "collate_measurements() (diskit.circuit_remapper.circuitremapper static method)": [[0, "diskit.circuit_remapper.CircuitRemapper.collate_measurements"]], "diskit.circuit_remapper": [[0, "module-diskit.circuit_remapper"]], "do_measure_ready() (diskit.circuit_remapper.circuitremapper static method)": [[0, "diskit.circuit_remapper.CircuitRemapper.do_measure_ready"]], "module": [[0, "module-diskit.circuit_remapper"], [1, "module-diskit.components.layer"]], "remap_circuit() (diskit.circuit_remapper.circuitremapper method)": [[0, "diskit.circuit_remapper.CircuitRemapper.remap_circuit"]], "layer (class in diskit.components.layer)": [[1, "diskit.components.layer.Layer"]], "add_operation() (diskit.components.layer.layer method)": [[1, "diskit.components.layer.Layer.add_operation"]], "add_operations() (diskit.components.layer.layer method)": [[1, "diskit.components.layer.Layer.add_operations"]], "diskit.components.layer": [[1, "module-diskit.components.layer"]], "non_local_operations() (diskit.components.layer.layer method)": [[1, "diskit.components.layer.Layer.non_local_operations"]], "operations (diskit.components.layer.layer property)": [[1, "diskit.components.layer.Layer.operations"]], "remove_operation() (diskit.components.layer.layer method)": [[1, "diskit.components.layer.Layer.remove_operation"]]}}) -------------------------------------------------------------------------------- /docs/source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Components — diskit 0.1 documentation 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 112 | 113 |
117 | 118 |
119 |
120 |
121 | 128 |
129 |
130 |
131 |
132 | 133 | 134 | 157 |
158 |

Components

159 |
160 | 174 |
175 |
176 | 177 | 178 |
179 |
180 |
181 | 182 |
183 | 184 |
185 |

© Copyright 2023, Anuranan Das, Stephen DiAdamo.

186 |
187 | 188 | Built with Sphinx using a 189 | theme 190 | provided by Read the Docs. 191 | 192 | 193 |
194 |
195 |
196 |
197 |
198 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /docs/source/components/circuit_remapper.rst: -------------------------------------------------------------------------------- 1 | Circuit Remapper 2 | ================ 3 | 4 | .. automodule:: diskit.circuit_remapper 5 | :members: -------------------------------------------------------------------------------- /docs/source/components/layer.rst: -------------------------------------------------------------------------------- 1 | Layer 2 | ===== 3 | 4 | .. automodule:: diskit.components.layer 5 | :members: -------------------------------------------------------------------------------- /docs/source/components/topology.rst: -------------------------------------------------------------------------------- 1 | Topology 2 | ======== 3 | 4 | .. automodule:: diskit.components.topology 5 | :members: -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | import sphinx_rtd_theme 7 | 8 | # -- Project information ----------------------------------------------------- 9 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 10 | 11 | project = 'diskit' 12 | copyright = '2023, Anuranan Das, Stephen DiAdamo' 13 | author = 'Anuranan Das, Stephen DiAdamo' 14 | release = '0.1' 15 | 16 | # -- General configuration --------------------------------------------------- 17 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 18 | 19 | extensions = ["sphinx.ext.autodoc", 'nbsphinx', 'sphinx.ext.coverage', 'sphinx.ext.napoleon'] 20 | 21 | templates_path = ['_templates'] 22 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints'] 23 | 24 | # -- Options for HTML output ------------------------------------------------- 25 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 26 | 27 | html_theme = "sphinx_rtd_theme" 28 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 29 | html_theme_options = { 30 | "collapse_navigation": False, 31 | 'prev_next_buttons_location': None 32 | } 33 | html_static_path = ["_static"] 34 | autodoc_default_flags = ['members', 'private-members', 'inherited-members', 'show-inheritance'] 35 | -------------------------------------------------------------------------------- /docs/source/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | .. toctree:: 5 | 6 | examples/Topology 7 | examples/CNOT 8 | examples/QFT 9 | examples/Shors -------------------------------------------------------------------------------- /docs/source/examples/Topology.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "65935fec", 7 | "metadata": { 8 | "ExecuteTime": { 9 | "end_time": "2023-02-03T08:41:58.274070Z", 10 | "start_time": "2023-02-03T08:41:58.256821Z" 11 | } 12 | }, 13 | "outputs": [], 14 | "source": [ 15 | "from diskit import *\n", 16 | "import warnings\n", 17 | "\n", 18 | "warnings.filterwarnings(\"ignore\")" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "source": [ 24 | "# Example to create a topology" 25 | ], 26 | "metadata": { 27 | "collapsed": false 28 | } 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "outputs": [], 34 | "source": [ 35 | "circuit_topo = Topology()\n", 36 | "circuit_topo.create_qmap(3, [2, 3, 3], \"sys\")\n", 37 | "circuit_topo.qmap, circuit_topo.emap" 38 | ], 39 | "metadata": { 40 | "collapsed": false 41 | } 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "id": "169d787d", 46 | "metadata": {}, 47 | "source": [ 48 | "In-built functions to support actions in topology class" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 3, 54 | "id": "afe696b3", 55 | "metadata": { 56 | "ExecuteTime": { 57 | "end_time": "2023-02-03T08:42:00.214160Z", 58 | "start_time": "2023-02-03T08:42:00.197002Z" 59 | } 60 | }, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Total Number of Qubits in Topology : 8\n", 67 | "Total Number of QPUs in Topology: 3\n", 68 | "Qubit(QuantumRegister(3, 'sys1'), 2) and Qubit(QuantumRegister(3, 'sys2'), 1) are not adjacent\n", 69 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 0) --------- Host: sys0\n", 70 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 1) --------- Host: sys0\n", 71 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 0) --------- Host: sys1\n", 72 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 1) --------- Host: sys1\n", 73 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 2) --------- Host: sys1\n", 74 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 0) --------- Host: sys2\n", 75 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 1) --------- Host: sys2\n", 76 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 2) --------- Host: sys2\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "print(\"Total Number of Qubits in Topology : \", circuit_topo.num_qubits())\n", 82 | "print(\"Total Number of QPUs in Topology: \", circuit_topo.num_hosts())\n", 83 | "\n", 84 | "Qubit1 = circuit_topo.qmap[\"sys1\"][2]\n", 85 | "Qubit2 = circuit_topo.qmap[\"sys2\"][1]\n", 86 | "print(\"{} and {} are adjacent\".format(Qubit1, Qubit2)\n", 87 | " if circuit_topo.are_adjacent(Qubit1, Qubit2) else\n", 88 | " \"{} and {} are not adjacent\".format(Qubit1, Qubit2))\n", 89 | "\n", 90 | "for qubit in circuit_topo.qubits:\n", 91 | " print(\"Qubit: {} --------- Host: {}\".format(qubit, circuit_topo.get_host(qubit)))" 92 | ] 93 | } 94 | ], 95 | "metadata": { 96 | "kernelspec": { 97 | "display_name": "Python 3 (ipykernel)", 98 | "language": "python", 99 | "name": "python3" 100 | }, 101 | "language_info": { 102 | "codemirror_mode": { 103 | "name": "ipython", 104 | "version": 3 105 | }, 106 | "file_extension": ".py", 107 | "mimetype": "text/x-python", 108 | "name": "python", 109 | "nbconvert_exporter": "python", 110 | "pygments_lexer": "ipython3", 111 | "version": "3.7.10" 112 | }, 113 | "toc": { 114 | "base_numbering": 1, 115 | "nav_menu": {}, 116 | "number_sections": true, 117 | "sideBar": true, 118 | "skip_h1_title": false, 119 | "title_cell": "Table of Contents", 120 | "title_sidebar": "Contents", 121 | "toc_cell": false, 122 | "toc_position": {}, 123 | "toc_section_display": true, 124 | "toc_window_display": false 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 5 129 | } 130 | -------------------------------------------------------------------------------- /docs/source/images/SEG-QPU.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/docs/source/images/SEG-QPU.png -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to Diskit documentation! 2 | ================================ 3 | 4 | 5 | .. toctree:: 6 | :caption: Contents 7 | :includehidden: 8 | :maxdepth: 2 9 | 10 | quick_start 11 | examples 12 | source 13 | 14 | Introduction 15 | ============ 16 | 17 | Distributed quantum computing is a concept that proposes to connect multiple quantum computers in a network to leverage a collection of more, but physically separated, qubits. In order to perform distributed quantum computing, it is necessary to add the addition of classical communication and entanglement distribution so that the control information from one qubit can be applied to another that is located on another quantum computer. For more details on distributed quantum computing, see this blog post: `Distributed Quantum Computing: A path to large scale quantum computing `_ 18 | 19 | In this project, we aim to validate distributed quantum algorithms using Qiskit. Because Qiskit does not yet come with networking features, we embed a "virtual network topology" into large circuits to mimic distributed quantum computing. The idea is to take a monolithic quantum circuit developed in the Qiskit language and distribute the circuit according to an artificially segmented version of a quantum processor. The inputs to the library are a quantum algorithm written monolithically (i.e., in a single circuit) and a topology parameter that represents the artificial segmentation of the single quantum processor. 20 | 21 | The algorithm takes these two inputs and remaps the Qiskit circuit to the specified segmentation, adding all necessary steps to perform an equivalent distributed quantum circuit. Our algorithm for achieving this is based on the work: `Distributed Quantum Computing and Network Control for Accelerated VQE 22 | `_. The algorithm output is another Qiskit circuit with the equivalent measurement statistics but with all of the additional logic needed to perform a distributed version. 23 | 24 | .. figure:: ./images/SEG-QPU.png 25 | :align: center 26 | :width: 500 27 | :alt: Segmented QPU 28 | 29 | The algorithm proposed in the linked work is not yet optimized, and so we encourage users to contribute by adding other methods of distributing circuits to the library. 30 | -------------------------------------------------------------------------------- /docs/source/quick_start.rst: -------------------------------------------------------------------------------- 1 | Quickstart 2 | ========== 3 | 4 | Diskit is available as a PyPi project and is can be installed with ``pip``. :: 5 | 6 | pip install diskit 7 | 8 | Diskit relies on Qiskit and therefore it should also be installed. 9 | Once installed, to generate a distributed circuit, one can simply generate a topology, 10 | create the circuit, perform the remapping, and run it as usual. :: 11 | 12 | from diskit import * 13 | 14 | network_topology = Topology() 15 | network_topology.create_qmap(2, [1, 1], "sys") 16 | qregs = circuit_topo.get_regs() 17 | 18 | qc = QuantumCircuit(*qregs) 19 | # Qubit 0 is on QPU 1, qubit 1 on QPU 2 20 | qc.h(0) 21 | qc.cx(0, 1) 22 | 23 | remapper = CircuitRemapper(circuit_topo) 24 | dist_circ = remapper.remap_circuit(qc) 25 | -------------------------------------------------------------------------------- /docs/source/source.rst: -------------------------------------------------------------------------------- 1 | ################## 2 | Components 3 | ################## 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | :glob: 8 | 9 | components/* -------------------------------------------------------------------------------- /examples/Topology.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "65935fec", 7 | "metadata": { 8 | "ExecuteTime": { 9 | "end_time": "2023-02-03T08:41:58.274070Z", 10 | "start_time": "2023-02-03T08:41:58.256821Z" 11 | }, 12 | "tags": [] 13 | }, 14 | "outputs": [], 15 | "source": [ 16 | "import sys\n", 17 | "sys.path.append(\"..\")\n", 18 | "from diskit import *\n", 19 | "import warnings\n", 20 | "\n", 21 | "warnings.filterwarnings(\"ignore\")" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "id": "c89ccca9", 27 | "metadata": {}, 28 | "source": [ 29 | "### Example to create a topology" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 2, 35 | "id": "b3798f21", 36 | "metadata": { 37 | "collapsed": false, 38 | "jupyter": { 39 | "outputs_hidden": false 40 | }, 41 | "tags": [] 42 | }, 43 | "outputs": [ 44 | { 45 | "data": { 46 | "text/plain": [ 47 | "({'sys0': [Qubit(QuantumRegister(2, 'sys0'), 0),\n", 48 | " Qubit(QuantumRegister(2, 'sys0'), 1)],\n", 49 | " 'sys1': [Qubit(QuantumRegister(3, 'sys1'), 0),\n", 50 | " Qubit(QuantumRegister(3, 'sys1'), 1),\n", 51 | " Qubit(QuantumRegister(3, 'sys1'), 2)],\n", 52 | " 'sys2': [Qubit(QuantumRegister(3, 'sys2'), 0),\n", 53 | " Qubit(QuantumRegister(3, 'sys2'), 1),\n", 54 | " Qubit(QuantumRegister(3, 'sys2'), 2)]},\n", 55 | " {'sys0': Qubit(QuantumRegister(1, 'com_sys0'), 0),\n", 56 | " 'sys1': Qubit(QuantumRegister(1, 'com_sys1'), 0),\n", 57 | " 'sys2': Qubit(QuantumRegister(1, 'com_sys2'), 0)})" 58 | ] 59 | }, 60 | "execution_count": 2, 61 | "metadata": {}, 62 | "output_type": "execute_result" 63 | } 64 | ], 65 | "source": [ 66 | "circuit_topo = Topology()\n", 67 | "circuit_topo.create_qmap(3, [2, 3, 3], \"sys\")\n", 68 | "circuit_topo.qmap, circuit_topo.emap" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "id": "169d787d", 74 | "metadata": {}, 75 | "source": [ 76 | "In-built functions to support actions in topology class" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 3, 82 | "id": "afe696b3", 83 | "metadata": { 84 | "ExecuteTime": { 85 | "end_time": "2023-02-03T08:42:00.214160Z", 86 | "start_time": "2023-02-03T08:42:00.197002Z" 87 | }, 88 | "tags": [] 89 | }, 90 | "outputs": [ 91 | { 92 | "name": "stdout", 93 | "output_type": "stream", 94 | "text": [ 95 | "Total Number of Qubits in Topology : 8\n", 96 | "Total Number of QPUs in Topology: 3\n", 97 | "Qubit(QuantumRegister(3, 'sys1'), 2) and Qubit(QuantumRegister(3, 'sys2'), 1) are not adjacent\n", 98 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 0) --------- Host: sys0\n", 99 | "Qubit: Qubit(QuantumRegister(2, 'sys0'), 1) --------- Host: sys0\n", 100 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 0) --------- Host: sys1\n", 101 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 1) --------- Host: sys1\n", 102 | "Qubit: Qubit(QuantumRegister(3, 'sys1'), 2) --------- Host: sys1\n", 103 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 0) --------- Host: sys2\n", 104 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 1) --------- Host: sys2\n", 105 | "Qubit: Qubit(QuantumRegister(3, 'sys2'), 2) --------- Host: sys2\n" 106 | ] 107 | } 108 | ], 109 | "source": [ 110 | "print(\"Total Number of Qubits in Topology : \", circuit_topo.num_qubits())\n", 111 | "print(\"Total Number of QPUs in Topology: \", circuit_topo.num_hosts())\n", 112 | "\n", 113 | "Qubit1 = circuit_topo.qmap[\"sys1\"][2]\n", 114 | "Qubit2 = circuit_topo.qmap[\"sys2\"][1]\n", 115 | "print(\"{} and {} are adjacent\".format(Qubit1, Qubit2)\n", 116 | " if circuit_topo.are_adjacent(Qubit1, Qubit2) else\n", 117 | " \"{} and {} are not adjacent\".format(Qubit1, Qubit2))\n", 118 | "\n", 119 | "for qubit in circuit_topo.qubits:\n", 120 | " print(\"Qubit: {} --------- Host: {}\".format(qubit, circuit_topo.get_host(qubit)))" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": 4, 126 | "id": "e1a8ac9c", 127 | "metadata": { 128 | "ExecuteTime": { 129 | "end_time": "2023-02-05T12:47:27.459095Z", 130 | "start_time": "2023-02-05T12:47:21.275415Z" 131 | }, 132 | "tags": [] 133 | }, 134 | "outputs": [ 135 | { 136 | "data": { 137 | "text/html": [ 138 | "

Version Information

SoftwareVersion
qiskit0.44.0
qiskit-terra0.25.0
System information
Python version3.9.16
Python compilerMSC v.1916 64 bit (AMD64)
Python buildmain, Mar 8 2023 10:39:24
OSWindows
CPUs24
Memory (Gb)127.74683380126953
Mon Aug 21 11:45:04 2023 GTB Daylight Time
" 139 | ], 140 | "text/plain": [ 141 | "" 142 | ] 143 | }, 144 | "metadata": {}, 145 | "output_type": "display_data" 146 | } 147 | ], 148 | "source": [ 149 | "import qiskit.tools.jupyter\n", 150 | "%qiskit_version_table" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": null, 156 | "id": "10d0237a", 157 | "metadata": { 158 | "collapsed": false, 159 | "jupyter": { 160 | "outputs_hidden": false 161 | } 162 | }, 163 | "outputs": [], 164 | "source": [] 165 | } 166 | ], 167 | "metadata": { 168 | "kernelspec": { 169 | "display_name": "Python 3 (ipykernel)", 170 | "language": "python", 171 | "name": "python3" 172 | }, 173 | "language_info": { 174 | "codemirror_mode": { 175 | "name": "ipython", 176 | "version": 3 177 | }, 178 | "file_extension": ".py", 179 | "mimetype": "text/x-python", 180 | "name": "python", 181 | "nbconvert_exporter": "python", 182 | "pygments_lexer": "ipython3", 183 | "version": "3.9.16" 184 | }, 185 | "toc": { 186 | "base_numbering": 1, 187 | "nav_menu": {}, 188 | "number_sections": true, 189 | "sideBar": true, 190 | "skip_h1_title": false, 191 | "title_cell": "Table of Contents", 192 | "title_sidebar": "Contents", 193 | "toc_cell": false, 194 | "toc_position": {}, 195 | "toc_section_display": true, 196 | "toc_window_display": false 197 | } 198 | }, 199 | "nbformat": 4, 200 | "nbformat_minor": 5 201 | } 202 | -------------------------------------------------------------------------------- /examples/swap.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/examples/swap.py -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | anyio==3.6.2 2 | appnope==0.1.3 3 | argon2-cffi==21.3.0 4 | argon2-cffi-bindings==21.2.0 5 | asttokens==2.1.0 6 | attrs==22.1.0 7 | backcall==0.2.0 8 | beautifulsoup4==4.11.1 9 | bleach==5.0.1 10 | certifi==2022.9.24 11 | cffi==1.15.1 12 | charset-normalizer==2.1.1 13 | contourpy==1.0.6 14 | cryptography==38.0.3 15 | cycler==0.11.0 16 | debugpy==1.6.3 17 | decorator==5.1.1 18 | defusedxml==0.7.1 19 | dill==0.3.6 20 | entrypoints==0.4 21 | executing==1.2.0 22 | fastjsonschema==2.16.2 23 | fonttools==4.38.0 24 | idna==3.4 25 | importlib-metadata==5.0.0 26 | ipykernel==6.17.1 27 | ipython==8.6.0 28 | ipython-genutils==0.2.0 29 | ipywidgets==8.0.2 30 | jedi==0.18.1 31 | Jinja2==3.1.2 32 | jsonschema==4.17.0 33 | jupyter==1.0.0 34 | jupyter-console==6.4.4 35 | jupyter-server==1.23.2 36 | jupyter_client==7.4.6 37 | jupyter_core==5.0.0 38 | jupyterlab-pygments==0.2.2 39 | jupyterlab-widgets==3.0.3 40 | kiwisolver==1.4.4 41 | MarkupSafe==2.1.1 42 | matplotlib==3.6.2 43 | matplotlib-inline==0.1.6 44 | mistune==2.0.4 45 | mpmath==1.2.1 46 | nbclassic==0.4.8 47 | nbclient==0.7.0 48 | nbconvert==7.2.5 49 | nbformat==5.7.0 50 | nest-asyncio==1.5.6 51 | notebook==6.5.2 52 | notebook_shim==0.2.2 53 | ntlm-auth==1.5.0 54 | numpy==1.23.4 55 | packaging==21.3 56 | pandocfilters==1.5.0 57 | parso==0.8.3 58 | pbr==5.11.0 59 | pexpect==4.8.0 60 | pickleshare==0.7.5 61 | Pillow==9.3.0 62 | platformdirs==2.5.4 63 | ply==3.11 64 | prometheus-client==0.15.0 65 | prompt-toolkit==3.0.32 66 | psutil==5.9.4 67 | ptyprocess==0.7.0 68 | pure-eval==0.2.2 69 | pycparser==2.21 70 | Pygments==2.13.0 71 | pylatexenc==2.10 72 | pyparsing==3.0.9 73 | pyrsistent==0.19.2 74 | python-dateutil==2.8.2 75 | pyzmq==24.0.1 76 | qiskit==0.39.2 77 | qiskit-aer==0.11.1 78 | qiskit-ibmq-provider==0.19.2 79 | qiskit-terra==0.22.2 80 | qtconsole==5.4.0 81 | QtPy==2.3.0 82 | requests==2.28.1 83 | requests-ntlm==1.1.0 84 | retworkx==0.12.0 85 | rustworkx==0.12.0 86 | scipy==1.9.3 87 | Send2Trash==1.8.0 88 | six==1.16.0 89 | sniffio==1.3.0 90 | soupsieve==2.3.2.post1 91 | stack-data==0.6.1 92 | stevedore==4.1.1 93 | symengine==0.9.2 94 | sympy==1.11.1 95 | terminado==0.17.0 96 | tinycss2==1.2.1 97 | tornado==6.2 98 | traitlets==5.5.0 99 | tweedledum==1.1.1 100 | urllib3==1.26.12 101 | wcwidth==0.2.5 102 | webencodings==0.5.1 103 | websocket-client==1.4.2 104 | websockets==10.4 105 | widgetsnbextension==4.0.3 106 | zipp==3.10.0 107 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Interlin-q/diskit/eed9537af67fd7096bcf2eb8f0d27d8be4c362cf/setup.py -------------------------------------------------------------------------------- /sphinx_requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.13 2 | anyio==3.6.2 3 | appnope==0.1.3 4 | argon2-cffi==21.3.0 5 | argon2-cffi-bindings==21.2.0 6 | astroid==2.13.2 7 | asttokens==2.1.0 8 | attrs==22.1.0 9 | Babel==2.11.0 10 | backcall==0.2.0 11 | beautifulsoup4==4.11.1 12 | bleach==5.0.1 13 | certifi==2022.9.24 14 | cffi==1.15.1 15 | charset-normalizer==2.1.1 16 | contourpy==1.0.6 17 | cryptography==38.0.3 18 | cycler==0.11.0 19 | debugpy==1.6.3 20 | decorator==5.1.1 21 | defusedxml==0.7.1 22 | dill==0.3.6 23 | docutils==0.17.1 24 | entrypoints==0.4 25 | executing==1.2.0 26 | fastjsonschema==2.16.2 27 | fonttools==4.38.0 28 | idna==3.4 29 | imagesize==1.4.1 30 | importlib-metadata==5.0.0 31 | ipykernel==6.17.1 32 | ipython==8.6.0 33 | ipython-genutils==0.2.0 34 | ipywidgets==8.0.2 35 | isort==5.11.4 36 | jedi==0.18.1 37 | Jinja2==3.1.2 38 | jsonschema==4.17.0 39 | jupyter==1.0.0 40 | jupyter-console==6.4.4 41 | jupyter-server==1.23.2 42 | jupyter_client==7.4.6 43 | jupyter_core==5.0.0 44 | jupyterlab-pygments==0.2.2 45 | jupyterlab-widgets==3.0.3 46 | kiwisolver==1.4.4 47 | lazy-object-proxy==1.9.0 48 | MarkupSafe==2.1.1 49 | matplotlib==3.6.2 50 | matplotlib-inline==0.1.6 51 | mccabe==0.7.0 52 | mistune==2.0.4 53 | mpmath==1.2.1 54 | nbclassic==0.4.8 55 | nbclient==0.7.0 56 | nbconvert==7.2.5 57 | nbformat==5.7.0 58 | nest-asyncio==1.5.6 59 | notebook==6.5.2 60 | notebook_shim==0.2.2 61 | ntlm-auth==1.5.0 62 | numpy==1.23.4 63 | packaging==21.3 64 | pandocfilters==1.5.0 65 | parso==0.8.3 66 | pbr==5.11.0 67 | pexpect==4.8.0 68 | pickleshare==0.7.5 69 | Pillow==9.3.0 70 | platformdirs==2.5.4 71 | ply==3.11 72 | prometheus-client==0.15.0 73 | prompt-toolkit==3.0.32 74 | psutil==5.9.4 75 | ptyprocess==0.7.0 76 | pure-eval==0.2.2 77 | pycparser==2.21 78 | Pygments==2.13.0 79 | pylatexenc==2.10 80 | pylint==2.15.10 81 | pyparsing==3.0.9 82 | pyrsistent==0.19.2 83 | python-dateutil==2.8.2 84 | pytz==2022.7.1 85 | pyzmq==24.0.1 86 | qiskit==0.39.2 87 | qiskit-aer==0.11.1 88 | qiskit-ibmq-provider==0.19.2 89 | qiskit-terra==0.22.2 90 | qtconsole==5.4.0 91 | QtPy==2.3.0 92 | requests==2.28.1 93 | requests-ntlm==1.1.0 94 | retworkx==0.12.0 95 | rustworkx==0.12.0 96 | scipy==1.9.3 97 | Send2Trash==1.8.0 98 | six==1.16.0 99 | sniffio==1.3.0 100 | snowballstemmer==2.2.0 101 | soupsieve==2.3.2.post1 102 | Sphinx==5.3.0 103 | sphinx-rtd-theme==1.1.1 104 | sphinxcontrib-devhelp==1.0.2 105 | sphinxcontrib-htmlhelp==2.0.0 106 | sphinxcontrib-jsmath==1.0.1 107 | sphinxcontrib-qthelp==1.0.3 108 | sphinxcontrib-serializinghtml==1.1.5 109 | sphinxcontrib.applehelp==1.0.3 110 | stack-data==0.6.1 111 | stevedore==4.1.1 112 | symengine==0.9.2 113 | sympy==1.11.1 114 | terminado==0.17.0 115 | tinycss2==1.2.1 116 | tomli==2.0.1 117 | tomlkit==0.11.6 118 | tornado==6.2 119 | traitlets==5.5.0 120 | tweedledum==1.1.1 121 | typing_extensions==4.4.0 122 | urllib3==1.26.12 123 | wcwidth==0.2.5 124 | webencodings==0.5.1 125 | websocket-client==1.4.2 126 | websockets==10.4 127 | widgetsnbextension==4.0.3 128 | wrapt==1.14.1 129 | zipp==3.10.0 130 | -------------------------------------------------------------------------------- /tests/test_circuit_remapper.py: -------------------------------------------------------------------------------- 1 | """ Test Cases for Circuit Remapper Module """ 2 | from diskit import Topology, CircuitRemapper 3 | from qiskit.circuit import QuantumCircuit 4 | from qiskit.circuit.quantumregister import QuantumRegister, Qubit 5 | 6 | 7 | class TestClass: 8 | """ 9 | Test Cases for Circuit Remapper Module 10 | """ 11 | circuit_topo = Topology() 12 | circuit_topo.create_qmap(3, [2, 3, 3], "sys") 13 | remapper = CircuitRemapper(circuit_topo) 14 | regs = circuit_topo.get_regs() 15 | circuit = QuantumCircuit(*regs) 16 | circuit.h(0) 17 | circuit.cx(0, 5) 18 | 19 | def test_basic_creation(self): 20 | """ Test remap_circuit method """ 21 | dist_circ = self.remapper.remap_circuit(self.circuit) 22 | assert dist_circ.qubits == [Qubit(QuantumRegister(2, 'sys0'), 0), Qubit( 23 | QuantumRegister(2, 'sys0'), 1), Qubit(QuantumRegister(3, 'sys1'), 0), Qubit( 24 | QuantumRegister(3, 'sys1'), 1), Qubit(QuantumRegister(3, 'sys1'), 2), Qubit( 25 | QuantumRegister(3, 'sys2'), 0), Qubit(QuantumRegister(3, 'sys2'), 1), Qubit( 26 | QuantumRegister(3, 'sys2'), 2), Qubit(QuantumRegister(1, 'com_sys0'), 0), Qubit( 27 | QuantumRegister(1, 'com_sys1'), 0), Qubit(QuantumRegister(1, 'com_sys2'), 0)] 28 | 29 | assert dist_circ.data[0][0].name == "h" 30 | assert dist_circ.data[0][1][0] == Qubit(QuantumRegister(2, 'sys0'), 0) 31 | assert dist_circ.data[2][0].name == "cx" 32 | -------------------------------------------------------------------------------- /tests/test_circuits.py: -------------------------------------------------------------------------------- 1 | from diskit.circuit_remapper import * 2 | 3 | 4 | def test_circuit_remapping(): 5 | pass 6 | -------------------------------------------------------------------------------- /tests/test_topology.py: -------------------------------------------------------------------------------- 1 | """Test Cases for Topology Module (Test Succeeded for all unit methods)""" 2 | 3 | from qiskit.circuit.quantumregister import QuantumRegister, Qubit 4 | from diskit import Topology # pylint: disable=import-error, wrong-import-position 5 | 6 | 7 | class TestClass: 8 | """ 9 | Test Cases for Topology Module 10 | """ 11 | circuit_topo = Topology() 12 | circuit_topo.create_qmap(3, [2, 3, 3], "sys") 13 | 14 | def test_one(self): 15 | """ 16 | Test the create_qmap method 17 | """ 18 | assert self.circuit_topo.qmap["sys0"] == [Qubit(QuantumRegister(2, 'sys0'), 0), Qubit( 19 | QuantumRegister(2, 'sys0'), 1)] 20 | assert self.circuit_topo.qmap["sys1"] == [Qubit(QuantumRegister(3, 'sys1'), 0), Qubit( 21 | QuantumRegister(3, 'sys1'), 1), Qubit(QuantumRegister(3, 'sys1'), 2)] 22 | assert self.circuit_topo.qmap["sys2"] == [Qubit(QuantumRegister(3, 'sys2'), 0), Qubit( 23 | QuantumRegister(3, 'sys2'), 1), Qubit(QuantumRegister(3, 'sys2'), 2)] 24 | assert self.circuit_topo.emap["sys0"] == Qubit( 25 | QuantumRegister(1, 'com_sys0'), 0) 26 | assert self.circuit_topo.emap["sys1"] == Qubit( 27 | QuantumRegister(1, 'com_sys1'), 0) 28 | assert self.circuit_topo.emap["sys2"] == Qubit( 29 | QuantumRegister(1, 'com_sys2'), 0) 30 | 31 | def test_two(self): 32 | """ 33 | Test add_qpu method 34 | """ 35 | self.circuit_topo.add_qpu("sys3", 3, "test_name", [0, 1, 2]) 36 | assert self.circuit_topo.qmap["sys3"] == [Qubit(QuantumRegister(3, "test_name"), 0), Qubit( 37 | QuantumRegister(3, "test_name"), 1), Qubit(QuantumRegister(3, "test_name"), 2)] 38 | assert self.circuit_topo.emap["sys3"] == Qubit( 39 | QuantumRegister(1, 'com_sys3'), 0) 40 | 41 | def test_three(self): 42 | """ 43 | Test num_qubits method 44 | """ 45 | assert self.circuit_topo.num_qubits() == 11 46 | 47 | def test_four(self): 48 | """ 49 | Test num_hosts method 50 | """ 51 | assert self.circuit_topo.num_hosts() == 4 52 | 53 | def test_five(self): 54 | """ 55 | Test reinitialize method 56 | """ 57 | self.circuit_topo.reinitialize({"sys0": [Qubit(QuantumRegister(2, 'sys0'), 0), Qubit( 58 | QuantumRegister(2, 'sys0'), 1)], "sys1": [Qubit(QuantumRegister(3, 'sys1'), 0), Qubit( 59 | QuantumRegister(3, 'sys1'), 1), Qubit(QuantumRegister(3, 'sys1'), 2)]}) 60 | assert self.circuit_topo.qmap["sys0"] == [Qubit(QuantumRegister(2, 'sys0'), 0), Qubit( 61 | QuantumRegister(2, 'sys0'), 1)] 62 | assert self.circuit_topo.qmap["sys1"] == [Qubit(QuantumRegister(3, 'sys1'), 0), Qubit( 63 | QuantumRegister(3, 'sys1'), 1), Qubit(QuantumRegister(3, 'sys1'), 2)] 64 | assert self.circuit_topo.emap["sys0"] == Qubit( 65 | QuantumRegister(1, 'com_sys0'), 0) 66 | assert self.circuit_topo.emap["sys1"] == Qubit( 67 | QuantumRegister(1, 'com_sys1'), 0) 68 | assert self.circuit_topo.num_qubits() == 5 69 | assert self.circuit_topo.num_hosts() == 2 70 | 71 | def test_six(self): 72 | """ 73 | Test are_adjacent method 74 | """ 75 | qubit_1 = self.circuit_topo.qmap["sys1"][2] 76 | qubit_2 = self.circuit_topo.qmap["sys2"][1] 77 | assert self.circuit_topo.are_adjacent(qubit_1, qubit_2) is False 78 | qubit_1 = self.circuit_topo.qmap["sys1"][2] 79 | qubit_2 = self.circuit_topo.qmap["sys1"][1] 80 | assert self.circuit_topo.are_adjacent(qubit_1, qubit_2) is True 81 | 82 | def test_seven(self): 83 | """ 84 | Test get_host method 85 | """ 86 | qubit_1 = self.circuit_topo.qmap["sys1"][2] 87 | assert self.circuit_topo.get_host(qubit_1) == "sys1" 88 | 89 | def test_eight(self): 90 | """ 91 | Test get_qubits method 92 | """ 93 | assert self.circuit_topo.get_qubits("sys1") == [Qubit(QuantumRegister(3, 'sys1'), 0), Qubit( 94 | QuantumRegister(3, 'sys1'), 1), Qubit(QuantumRegister(3, 'sys1'), 2)] 95 | 96 | def test_nine(self): 97 | """ 98 | Test get_all_qubits method 99 | """ 100 | assert self.circuit_topo.get_all_qubits() == [Qubit(QuantumRegister(2, 'sys0'), 0), Qubit( 101 | QuantumRegister(2, 'sys0'), 1), Qubit(QuantumRegister(3, 'sys1'), 0), Qubit( 102 | QuantumRegister(3, 'sys1'), 1), Qubit(QuantumRegister(3, 'sys1'), 2), Qubit( 103 | QuantumRegister(3, 'sys2'), 0), Qubit(QuantumRegister(3, 'sys2'), 1), Qubit( 104 | QuantumRegister(3, 'sys2'), 2), Qubit(QuantumRegister(3, "test_name"), 0), Qubit( 105 | QuantumRegister(3, "test_name"), 1), Qubit(QuantumRegister(3, "test_name"), 2), Qubit( 106 | QuantumRegister(1, 'com_sys0'), 0), Qubit(QuantumRegister(1, 'com_sys1'), 0), Qubit( 107 | QuantumRegister(1, 'com_sys2'), 0), Qubit(QuantumRegister(1, 'com_sys3'), 0)] 108 | 109 | def test_ten(self): 110 | """ 111 | Test remove_qpu method 112 | """ 113 | self.circuit_topo.remove_qpu("sys1") 114 | assert "sys1" not in self.circuit_topo.qmap.keys() 115 | assert "sys1" not in self.circuit_topo.emap.keys() 116 | assert self.circuit_topo.num_qubits() == 8 117 | assert self.circuit_topo.num_hosts() == 3 118 | 119 | def test_twelve(self): 120 | """ 121 | Test get_regs method 122 | """ 123 | assert self.circuit_topo.get_regs() == [QuantumRegister(2, 'sys0'), QuantumRegister( 124 | 3, 'sys2'), QuantumRegister(3, "test_name"), QuantumRegister( 125 | 1, 'com_sys0'), QuantumRegister(1, 'com_sys2'), QuantumRegister(1, 'com_sys3')] 126 | --------------------------------------------------------------------------------