diff --git a/MQT Tutorial/2d_example.png b/MQT Tutorial/2d_example.png deleted file mode 100644 index d3f2e8e..0000000 Binary files a/MQT Tutorial/2d_example.png and /dev/null differ diff --git a/MQT Tutorial/2dqed.png b/MQT Tutorial/2dqed.png deleted file mode 100644 index 4ac0c27..0000000 Binary files a/MQT Tutorial/2dqed.png and /dev/null differ diff --git a/MQT Tutorial/MQT Qudits Tutorial.ipynb b/MQT Tutorial/MQT Qudits Tutorial.ipynb deleted file mode 100644 index c463e83..0000000 --- a/MQT Tutorial/MQT Qudits Tutorial.ipynb +++ /dev/null @@ -1,836 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "53702878", - "metadata": {}, - "source": [ - "# MQT Qudits 🌌\n", - "*Discover a New Dimension in Quantum Computing*\n", - "\n", - "Embark on a journey with MQT Qudits, a cutting-edge toolkit for Mixed-Dimensional Quantum Computing.\n", - "\n", - "
\n", - "

Delve into the realm of mixed-dimensional quantum computing with NeQSTβ€”a project funded by the European Union and developed at the Chair for Design Automation at the Technical University of Munich, as part of the Munich Quantum Toolkit.

Our team is focused on creating design automation methods and software for quDit-based systems. Explore our Jupyter file to discover the initial tools and contributions we've made to advance Quantum Information Processing for Science and Technology.\n", - "\"Logo \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "e3f8addb", - "metadata": {}, - "source": [ - "## Installation steps:\n", - "\n", - "\n", - "```\n", - "!pip install mqt.qudits\n", - "```\n", - "\n", - "For those seeking hands-on customization, simply clone our repository and execute the installation script:\n", - "\n", - "```\n", - "git clone git@github.com:KevinMTO/mqt-qudits.git\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "bfe14179", - "metadata": {}, - "source": [ - "# User Inputs πŸ’»\n", - "\n", - "πŸš€ **New QASM Extension:**\n", - "Dive into a language meticulously designed to express quantum algorithms and circuits. MQT extends the openQASM 2.0 grammar, effortlessly adapting to registers that feature a harmonious mix of qudits and qubits in diverse combinations. \n", - "\n", - "🐍 **Python Interface** \n", - "\n", - "Constructing and manipulating quantum programs becomes a breeze with Python. You have the flexibility to:\n", - "\n", - "1. **Initialize Quantum Circuits:** Start by creating your quantum circuits effortlessly.\n", - "\n", - "2. **Create Quantum Registers:** Build dedicated quantum registers tailored to your needs.\n", - "\n", - "3. **Compose Circuits:** Seamlessly bring together your quantum registers, forming a unified and powerful circuit.\n", - "\n", - "4. **Apply Operations:** Easily apply a variety of qudit operations, without worrying about the right representation. \n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c248f22a", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "from mqt.qudits.qudit_circuits.circuit import QuantumCircuit" - ] - }, - { - "cell_type": "markdown", - "id": "2a47bfc3", - "metadata": {}, - "source": [ - "After the import of the quantum circuit object, it is possible starting from a __DITQASM__ program to automatically create a circuit and manipulate it, if not simulate it or compile it to a more suitable gate-set for the machine.\n", - "In the next cell the program is explicitly written, although several methods for importing programs from files are present in the library." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5274efd5", - "metadata": {}, - "outputs": [], - "source": [ - "qasm = \"\"\"\n", - " DITQASM 2.0;\n", - " \n", - " qreg field [7][5,5,5,5,5,5,5];\n", - " qreg matter [2];\n", - " \n", - " creg meas_matter[7];\n", - " creg meas_fields[3];\n", - " \n", - " h matter[0] ctl field[0] field[1] [0,0];\n", - " cx field[2], matter[0];\n", - " cx field[2], matter[1];\n", - " rxy (0, 1, pi, pi/2) field[3];\n", - " \n", - " measure q[0] -> meas[0];\n", - " measure q[1] -> meas[1];\n", - " measure q[2] -> meas[2];\n", - " \"\"\"" - ] - }, - { - "cell_type": "markdown", - "id": "e718e589", - "metadata": {}, - "source": [ - "A new feature is the __control syntax__: _operation_ __ctl__ _quditline_ \\[list of qudit control levels\\]\n", - "
\n", - "We can import the QASM program and construct a quantum circuit.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "356d82c2", - "metadata": {}, - "outputs": [], - "source": [ - "circuit = QuantumCircuit()\n", - "circuit.from_qasm(qasm)\n", - "\n", - "print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4d2b2cf2", - "metadata": {}, - "outputs": [], - "source": [ - "circuit.dimensions" - ] - }, - { - "cell_type": "markdown", - "id": "101de68e", - "metadata": {}, - "source": [ - "##### Let's construct a quantum circuit from scratch, with the python interface.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9a283781", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.qudit_circuits.components.registers.quantum_register import QuantumRegister\n", - "\n", - "circuit = QuantumCircuit()\n", - "\n", - "field_reg = QuantumRegister(\"fields\", 1, [7])\n", - "matter_reg = QuantumRegister(\"matter\", 1, [2])\n", - "\n", - "circuit.append(field_reg)\n", - "circuit.append(matter_reg)\n", - "\n", - "print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "192d09b0", - "metadata": {}, - "outputs": [], - "source": [ - "circuit.gate_set" - ] - }, - { - "cell_type": "markdown", - "id": "a23644c5", - "metadata": {}, - "source": [ - "##### No operations were inserted yet, let's take a look at how operations can be applied!" - ] - }, - { - "cell_type": "markdown", - "id": "2dd17aed", - "metadata": {}, - "source": [ - "The size of every line is detected automatically and the right operations are applied to the right qudits" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0ed0c548", - "metadata": {}, - "outputs": [], - "source": [ - "h = circuit.h(field_reg[0])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "22bd7e9b", - "metadata": {}, - "outputs": [], - "source": [ - "csum = circuit.csum([field_reg[0], matter_reg[0]])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bc8489ec", - "metadata": {}, - "outputs": [], - "source": [ - "print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")" - ] - }, - { - "cell_type": "markdown", - "id": "52b43bbf", - "metadata": {}, - "source": [ - "\n", - "##### It is possible to export the code as well and share your program in a QASM file.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b79ad7c3", - "metadata": {}, - "outputs": [], - "source": [ - "print(circuit.to_qasm())" - ] - }, - { - "cell_type": "markdown", - "id": "e6c76f81", - "metadata": {}, - "source": [ - "#### Let's save the circuit to file" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a6e17342", - "metadata": {}, - "outputs": [], - "source": [ - "circuit.save_to_file(\"my_circuit\", \"/home/k3vn/Desktop\")" - ] - }, - { - "cell_type": "markdown", - "id": "9e47c69a", - "metadata": {}, - "source": [ - "#### Load from file" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c6f66e02", - "metadata": {}, - "outputs": [], - "source": [ - "circuit.load_from_file(\"/home/k3vn/Desktop/my_circuit.qasm\")\n", - "\n", - "print(\"Program:\\n\\n\", circuit.to_qasm())\n", - "print(\"Dimensions: \", circuit.dimensions)" - ] - }, - { - "cell_type": "markdown", - "id": "4d59b4c7", - "metadata": {}, - "source": [ - "### Custom gates" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cf9b9720", - "metadata": {}, - "outputs": [], - "source": [ - "n = 5\n", - "random_matrix = np.random.randn(n, n) + 1j * np.random.randn(n, n)\n", - "\n", - "Q, R = np.linalg.qr(random_matrix)\n", - "\n", - "unitary_matrix = Q\n", - "cu = circuit.cu_one(field_reg[0], unitary_matrix)" - ] - }, - { - "cell_type": "markdown", - "id": "25105c05", - "metadata": {}, - "source": [ - "##### Gates follow the order:\n", - "- target qudit/s : list or single number\n", - "- parameters lis with order lower level, upper level, control level, theta, phi\n", - "- control data" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f9dcf9b4", - "metadata": {}, - "outputs": [], - "source": [ - "r = circuit.r(field_reg[0], [0, 1, np.pi / 5, np.pi / 7])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "43221ade", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.qudit_circuits.components.instructions.gate_extensions.controls import ControlData\n", - "\n", - "r_c1 = circuit.r(field_reg[0], [0, 1, np.pi / 5, np.pi / 7], ControlData([matter_reg[0]], [1]))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "480417f5", - "metadata": {}, - "outputs": [], - "source": [ - "r_c2 = circuit.r(field_reg[0], [0, 1, np.pi / 5, np.pi / 7]).control([matter_reg[0]], [1])" - ] - }, - { - "cell_type": "markdown", - "id": "b2f8b1f6", - "metadata": {}, - "source": [ - "##### Representation of the matrix is dynamic:\n", - "- 0: no identities\n", - "- 1: identities in between long-range gates are introduced\n", - "- 2: full circuit unitary" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "20f638dc", - "metadata": {}, - "outputs": [], - "source": [ - "print(r._name)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "effbb9a5", - "metadata": {}, - "outputs": [], - "source": [ - "r.to_matrix()" - ] - }, - { - "cell_type": "markdown", - "id": "a030d94b", - "metadata": {}, - "source": [ - "##### you can dagger a gate anytime\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "720bb90b", - "metadata": {}, - "outputs": [], - "source": [ - "rd = r.dag()\n", - "print(rd._name)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f42f7ec4", - "metadata": {}, - "outputs": [], - "source": [ - "rd.to_matrix()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8695a95e", - "metadata": {}, - "outputs": [], - "source": [ - "r_c1.control_info" - ] - }, - { - "cell_type": "markdown", - "id": "b74cc7f8", - "metadata": {}, - "source": [ - "##### Two and Multi qudits gates follow the rule:\n", - "- two : target_qudits first is control, second is target\n", - "- multi: all are controls, except last one is target" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bc118b90", - "metadata": {}, - "outputs": [], - "source": [ - "r_c1.reference_lines" - ] - }, - { - "cell_type": "markdown", - "id": "d67f883c", - "metadata": {}, - "source": [ - "# Simulation πŸš€\n", - "\n", - "After crafting your quantum circuit with precision, take it for a spin using two distinct engines, each flaunting its unique set of data structures.\n", - "\n", - "- **External Tensor-Network Simulator:** Delve into the quantum realm with a robust external tensor-network simulator. Can simulate all the gate-set.\n", - "\n", - "- **MiSiM (C++-Powered):** Unleash the power of decision-diagram-based simulation with MiSiM, seamlessly interfaced with Python for a fluid and efficient experience. πŸŒπŸ’‘ Can simulate only the machine set." - ] - }, - { - "cell_type": "markdown", - "id": "13fa1ac7", - "metadata": {}, - "source": [ - "#### Supported by MISIM now:\n", - "csum\n", - "cx\n", - "h\n", - "rxy\n", - "rz\n", - "virtrz\n", - "s\n", - "x\n", - "z\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "39904844", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.qudit_circuits.components.registers.quantum_register import QuantumRegister\n", - "\n", - "circuit = QuantumCircuit()\n", - "\n", - "field_reg = QuantumRegister(\"fields\", 1, [3])\n", - "matter_reg = QuantumRegister(\"matter\", 1, [3])\n", - "\n", - "circuit.append(field_reg)\n", - "circuit.append(matter_reg)\n", - "\n", - "h = circuit.h(field_reg[0])\n", - "csum = circuit.csum([field_reg[0], matter_reg[0]])\n", - "\n", - "print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "13be385f", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.simulation.provider.qudit_provider import MQTQuditProvider\n", - "\n", - "provider = MQTQuditProvider()\n", - "provider.backends(\"sim\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ab6d2c80", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.visualisation.plot_information import plot_counts, plot_state\n", - "\n", - "backend = provider.get_backend(\"tnsim\")\n", - "\n", - "job = backend.run(circuit)\n", - "result = job.result()\n", - "\n", - "state_vector = result.get_state_vector()\n", - "\n", - "plot_state(state_vector, circuit)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e18653e8", - "metadata": {}, - "outputs": [], - "source": [ - "backend = provider.get_backend(\"misim\")\n", - "\n", - "job = backend.run(circuit)\n", - "result = job.result()\n", - "\n", - "state_vector = result.get_state_vector()\n", - "\n", - "plot_state(state_vector, circuit)" - ] - }, - { - "cell_type": "markdown", - "id": "63baa60f", - "metadata": {}, - "source": [ - "### Extending Engines with Noise Model and Properties for FakeBackend\n", - "\n", - "Enhance your quantum simulation experience by extending the engines with a noise model and incorporating various properties. This process allows you to create a FakeBackend, inspired by the best machines in experimental laboratories.\n", - "\n", - "#### Noise Model Integration\n", - "\n", - "Introduce realism into your simulations by incorporating a noise model. Simulate the effects of environmental factors and imperfections, bringing your quantum algorithms closer to real-world scenarios.\n", - "\n", - "\n", - "#### Creating a FakeBackend\n", - "\n", - "By combining a noise model and carefully tuned properties, you can craft a FakeBackend that closely emulates the performance of the best quantum machines in experimental laboratories. This allows for more realistic and insightful quantum simulations.\n", - "\n", - "Experiment, iterate, and simulate quantum circuits with the sophistication of real-world conditions, all within the controlled environment of your simulation. πŸ› οΈπŸ”¬\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7ddd23dc", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.simulation.provider.noise_tools.noise import Noise, NoiseModel\n", - "\n", - "# Depolarizing quantum errors\n", - "local_error = Noise(probability_depolarizing=0.001, probability_dephasing=0.001)\n", - "local_error_rz = Noise(probability_depolarizing=0.03, probability_dephasing=0.03)\n", - "\n", - "entangling_error = Noise(probability_depolarizing=0.1, probability_dephasing=0.001)\n", - "entangling_error_extra = Noise(probability_depolarizing=0.1, probability_dephasing=0.1)\n", - "\n", - "entangling_error_on_target = Noise(probability_depolarizing=0.1, probability_dephasing=0.0)\n", - "entangling_error_on_control = Noise(probability_depolarizing=0.01, probability_dephasing=0.0)\n", - "\n", - "# Add errors to noise_tools model\n", - "\n", - "noise_model = NoiseModel() # We know that the architecture is only two qudits\n", - "# Very noisy gate\n", - "noise_model.add_all_qudit_quantum_error(local_error, [\"csum\"])\n", - "noise_model.add_recurrent_quantum_error_locally(local_error, [\"csum\"], [0])\n", - "# Entangling gates\n", - "noise_model.add_nonlocal_quantum_error(entangling_error, [\"cx\", \"ls\", \"ms\"])\n", - "noise_model.add_nonlocal_quantum_error_on_target(entangling_error_on_target, [\"cx\", \"ls\", \"ms\"])\n", - "noise_model.add_nonlocal_quantum_error_on_control(entangling_error_on_control, [\"csum\", \"cx\", \"ls\", \"ms\"])\n", - "# Super noisy Entangling gates\n", - "noise_model.add_nonlocal_quantum_error(entangling_error_extra, [\"csum\"])\n", - "# Local Gates\n", - "noise_model.add_quantum_error_locally(local_error, [\"h\", \"rxy\", \"s\", \"x\", \"z\"])\n", - "noise_model.add_quantum_error_locally(local_error_rz, [\"rz\", \"virtrz\"])\n", - "\n", - "print(noise_model.quantum_errors)" - ] - }, - { - "cell_type": "markdown", - "id": "7e2effb3", - "metadata": {}, - "source": [ - "##### We can set the noise model for the simulation, but also set several other flags:\n", - "- shots : number of shots for the stochatsic simulation\n", - "- memory : flag for saving shots (True/False)\n", - "- full_state_memory: save the full noisy states \n", - "- file_path: file path of the h5 database storing the data#\n", - "- file_name" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "505715d1", - "metadata": {}, - "outputs": [], - "source": [ - "backend = provider.get_backend(\"tnsim\")\n", - "\n", - "job = backend.run(circuit, noise_model=noise_model)\n", - "\n", - "result = job.result()\n", - "counts = result.get_counts()\n", - "\n", - "plot_counts(counts, circuit)" - ] - }, - { - "cell_type": "markdown", - "id": "2a9ebf27", - "metadata": {}, - "source": [ - "## Fakebackends\n", - "#### You can invoke also a fake banckend a retrieve a few relevant properties, that already embedded in them" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f8a44ca3", - "metadata": {}, - "outputs": [], - "source": [ - "provider = MQTQuditProvider()\n", - "provider.backends(\"fake\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3f8d02e3", - "metadata": {}, - "outputs": [], - "source": [ - "backend_ion = provider.get_backend(\"faketraps2trits\", shots=1000)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "792435eb", - "metadata": {}, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt\n", - "import networkx as nx\n", - "\n", - "mapping = backend_ion.energy_level_graphs\n", - "\n", - "pos = nx.circular_layout(mapping[0])\n", - "nx.draw(mapping[0], pos, with_labels=True, node_size=2000, node_color=\"lightblue\", font_size=12, font_weight=\"bold\")\n", - "plt.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0d712293", - "metadata": {}, - "outputs": [], - "source": [ - "job = backend_ion.run(circuit)\n", - "result = job.result()\n", - "counts = result.get_counts()\n", - "\n", - "plot_counts(counts, circuit)" - ] - }, - { - "cell_type": "markdown", - "id": "0a132d35", - "metadata": {}, - "source": [ - "## Compilation βš™οΈ\n", - "\n", - "Tailor your quantum compilation process to achieve optimal performance and emulate the intricacies of experimental setups.\n", - "\n", - "#### Compiler Customization with Modern Passes\n", - "\n", - "1. **Optimization Strategies:** Implement specific optimization strategies based on your quantum algorithm's characteristics. Fine-tune compilation for better resource utilization and reduced gate counts.\n", - "\n", - "2. **Gate Decomposition:** Customize gate decomposition techniques to match the capabilities of experimental quantum hardware. Aligning with the native gate set enhances the efficiency of your compiled circuits.\n", - "\n", - "##### Experimental-Inspired Compilation\n", - "\n", - "Emulate the features of the best experimental laboratories in your compilation process. Leverage modern compiler passes to customize optimization, gate decomposition, and noise-aware strategies, creating compiled circuits that closely resemble the challenges and advantages of cutting-edge quantum hardware.\n", - "\n", - "Customize, compile, and push the boundaries of quantum algorithms with a tailored approach to quantum compilation. πŸ› οΈπŸ”§πŸš€\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8e187e94", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.compiler.dit_manager import QuditCompiler" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "58daadf2", - "metadata": {}, - "outputs": [], - "source": [ - "qudit_compiler = QuditCompiler()\n", - "\n", - "passes = [\"PhyLocQRPass\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d21fe400", - "metadata": {}, - "outputs": [], - "source": [ - "compiled_circuit_qr = qudit_compiler.compile(backend_ion, circuit, passes)\n", - "\n", - "print(\n", - " f\"\\n Number of operations: {len(compiled_circuit_qr.instructions)}, \\n Number of qudits in the circuit: {compiled_circuit_qr.num_qudits}\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "85b295ef", - "metadata": {}, - "outputs": [], - "source": [ - "job = backend_ion.run(compiled_circuit_qr)\n", - "\n", - "result = job.result()\n", - "counts = result.get_counts()\n", - "\n", - "plot_counts(counts, compiled_circuit_qr)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a1b22b44", - "metadata": {}, - "outputs": [], - "source": [ - "passes = [\"PhyLocAdaPass\", \"ZPropagationPass\", \"ZRemovalPass\"]\n", - "\n", - "compiled_circuit_ada = qudit_compiler.compile(backend_ion, circuit, passes)\n", - "\n", - "print(\n", - " f\"\\n Number of operations: {len(compiled_circuit_ada.instructions)}, \\n Number of qudits in the circuit: {compiled_circuit_ada.num_qudits}\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5a807930", - "metadata": {}, - "outputs": [], - "source": [ - "job = backend_ion.run(compiled_circuit_ada)\n", - "\n", - "result = job.result()\n", - "counts = result.get_counts()\n", - "\n", - "plot_counts(counts, compiled_circuit_ada)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "632aca35", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.visualisation.drawing_routines import draw_qudit_local\n", - "\n", - "draw_qudit_local(compiled_circuit_ada)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python (qenvoff)", - "language": "python", - "name": "qenv" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/MQT Tutorial/MQT Qudits in Short.ipynb b/MQT Tutorial/MQT Qudits in Short.ipynb deleted file mode 100644 index 9fa9b8e..0000000 --- a/MQT Tutorial/MQT Qudits in Short.ipynb +++ /dev/null @@ -1,278 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "69b78731", - "metadata": {}, - "source": [ - "# MQT Qudits 🌌\n", - "*Discover a New Dimension in Quantum Computing*\n", - "\n", - "Embark on a journey with MQT Qudits, a cutting-edge toolkit for Mixed-Dimensional Quantum Computing.\n", - "\n", - "
\n", - "

Delve into the realm of mixed-dimensional quantum computing with NeQSTβ€”a project funded by the European Union and developed at the Chair for Design Automation at the Technical University of Munich, as part of the Munich Quantum Toolkit.

Our team is focused on creating design automation methods and software for quDit-based systems. Explore our Jupyter file to discover the initial tools and contributions we've made to advance Quantum Information Processing for Science and Technology.\n", - "\"Logo \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "b95c4040", - "metadata": {}, - "source": [ - "# User Inputs πŸ’»\n", - "\n", - "πŸš€ **New QASM Extension:**\n", - "Dive into a language meticulously designed to express quantum algorithms and circuits. MQT extends the openQASM 2.0 grammar, effortlessly adapting to registers that feature a harmonious mix of qudits and qubits in diverse combinations. \n", - "\n", - "🐍 **Python Interface** \n", - "\n", - "Constructing and manipulating quantum programs becomes a breeze with Python. You have the flexibility to:\n", - "\n", - "1. **Initialize Quantum Circuits:** Start by creating your quantum circuits effortlessly.\n", - "\n", - "2. **Create Quantum Registers:** Build dedicated quantum registers tailored to your needs.\n", - "\n", - "3. **Compose Circuits:** Seamlessly bring together your quantum registers, forming a unified and powerful circuit.\n", - "\n", - "4. **Apply Operations:** Easily apply a variety of qudit operations, without worrying about the right representation. \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "7bc57c87", - "metadata": {}, - "source": [ - "\"2dqed.png\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ac47688d", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.qudit_circuits.circuit import QuantumCircuit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f0157fd8", - "metadata": {}, - "outputs": [], - "source": [ - "qasm = \"\"\"\n", - " DITQASM 2.0;\n", - " \n", - " qreg fields [3][5,5,5];\n", - " qreg matter [2][2,2];\n", - " \n", - " h fields[2] ctl matter[0] matter[1] [0,0];\n", - " cx fields[2], matter[0];\n", - " cx fields[2], matter[1];\n", - " rxy (0, 1, pi, pi/2) fields[2];\n", - " \n", - " measure q[0] -> meas[0];\n", - " measure q[1] -> meas[1];\n", - " measure q[2] -> meas[2];\n", - " \"\"\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3c421902", - "metadata": {}, - "outputs": [], - "source": [ - "circuit = QuantumCircuit()\n", - "circuit.from_qasm(qasm)\n", - "\n", - "print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")" - ] - }, - { - "cell_type": "markdown", - "id": "fdd6eef4", - "metadata": {}, - "source": [ - "##### Let's construct a quantum circuit from scratch.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "468735a3", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.qudit_circuits.components.registers.quantum_register import QuantumRegister\n", - "\n", - "circuit = QuantumCircuit()\n", - "\n", - "field_reg = QuantumRegister(\"fields\", 1, [3])\n", - "ancilla_reg = QuantumRegister(\"ancillas\", 1, [3])\n", - "\n", - "circuit.append(field_reg)\n", - "circuit.append(ancilla_reg)\n", - "\n", - "h = circuit.h(field_reg[0])\n", - "csum = circuit.csum([field_reg[0], ancilla_reg[0]])\n", - "\n", - "print(h.to_matrix())\n", - "print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")" - ] - }, - { - "cell_type": "markdown", - "id": "53329ff9", - "metadata": {}, - "source": [ - "\n", - "##### It is possible to export the code and share your program in a QASM file.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "32658fe9", - "metadata": {}, - "outputs": [], - "source": [ - "print(circuit.to_qasm())" - ] - }, - { - "cell_type": "markdown", - "id": "3a6b2672", - "metadata": {}, - "source": [ - "# Simulation πŸš€\n", - "\n", - "After crafting your quantum circuit with precision, take it for a spin using two distinct engines, each flaunting its unique set of data structures.\n", - "\n", - "- **External Tensor-Network Simulator:** Delve into the quantum realm with a robust external tensor-network simulator.\n", - "\n", - "- **MiSiM (C++-Powered):** Unleash the power of decision-diagram-based simulation with MiSiM, seamlessly interfaced with Python for a fluid and efficient experience. πŸŒπŸ’‘" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9d2a8eb0", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.simulation.provider.qudit_provider import MQTQuditProvider\n", - "\n", - "provider = MQTQuditProvider()\n", - "provider.backends(\"sim\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5b16d935", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.visualisation.plot_information import plot_counts, plot_state\n", - "\n", - "backend = provider.get_backend(\"tnsim\")\n", - "\n", - "job = backend.run(circuit)\n", - "result = job.result()\n", - "\n", - "state_vector = result.get_state_vector()\n", - "\n", - "plot_state(state_vector, circuit)" - ] - }, - { - "cell_type": "markdown", - "id": "cc320e6b", - "metadata": {}, - "source": [ - "# Compilation βš™οΈ\n", - "\n", - "Emulate the features of the best experimental laboratories in your compilation process. Leverage modern compiler passes to customize optimization, gate decomposition, and noise-aware strategies, creating compiled circuits that closely resemble the challenges and advantages of cutting-edge quantum hardware.\n", - "\n", - "Customize, compile, and push the boundaries of quantum algorithms with a tailored approach to quantum compilation. πŸ› οΈπŸ”§πŸš€\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dd61551f", - "metadata": {}, - "outputs": [], - "source": [ - "from mqt.qudits.compiler.dit_manager import QuditCompiler\n", - "\n", - "backend_ion = provider.get_backend(\"faketraps2trits\", shots=1000)\n", - "\n", - "qudit_compiler = QuditCompiler()\n", - "\n", - "passes = [\"PhyLocQRPass\"]\n", - "\n", - "compiled_circuit_qr = qudit_compiler.compile(backend_ion, circuit, passes)\n", - "\n", - "print(\n", - " f\"\\n Number of operations: {len(compiled_circuit_qr.instructions)}, \\n Number of qudits in the circuit: {compiled_circuit_qr.num_qudits}\"\n", - ")" - ] - }, - { - "cell_type": "markdown", - "id": "21a11514", - "metadata": {}, - "source": [ - "### Extending Simulation with Noise Model Integration\n", - "\n", - "Introduce realism into your simulations by incorporating a noise model. Simulate the effects of environmental factors and imperfections, bringing your quantum algorithms closer to real-world scenarios." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a7fa4150", - "metadata": {}, - "outputs": [], - "source": [ - "job = backend_ion.run(compiled_circuit_qr)\n", - "result = job.result()\n", - "counts = result.get_counts()\n", - "\n", - "plot_counts(counts, compiled_circuit_qr)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/MQT Tutorial/MQT slide.pdf b/MQT Tutorial/MQT slide.pdf deleted file mode 100644 index 234844c..0000000 Binary files a/MQT Tutorial/MQT slide.pdf and /dev/null differ diff --git a/MQT Tutorial/foot.png b/MQT Tutorial/foot.png deleted file mode 100644 index 30d646e..0000000 Binary files a/MQT Tutorial/foot.png and /dev/null differ diff --git a/test/python/compiler/__init__.py b/test/python/compiler/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/compiler/onedit/__init__.py b/test/python/compiler/onedit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/compiler/onedit/test_log_local_adaptive_decomp.py b/test/python/compiler/onedit/test_log_local_adaptive_decomp.py new file mode 100644 index 0000000..874e36c --- /dev/null +++ b/test/python/compiler/onedit/test_log_local_adaptive_decomp.py @@ -0,0 +1,46 @@ +from unittest import TestCase + + +class TestLogLocAdaPass(TestCase): + def test_transpile(self): + pass + + +class TestLogAdaptiveDecomposition(TestCase): + + def test_execute(self): + pass + # dim = 5 + # test_sample_edges = [(0, 4, {"delta_m": 0, "sensitivity": 1}), + # (0, 3, {"delta_m": 1, "sensitivity": 3}), + # (0, 2, {"delta_m": 1, "sensitivity": 3}), + # (1, 4, {"delta_m": 0, "sensitivity": 1}), + # (1, 3, {"delta_m": 1, "sensitivity": 3}), + # (1, 2, {"delta_m": 1, "sensitivity": 3}) + # ] + # test_sample_nodes = [0, 1, 2, 3, 4] + # test_sample_nodes_map = [3, 2, 4, 1, 0] + # + # graph_1 = level_Graph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0]) + # graph_1.phase_storing_setup() + # + # Htest = H(dim) + # + # #----------------- + # QR = QR_decomp( Htest, graph_1, Z_prop = False, not_stand_alone = True ) + # + # decomp_qr, algorithmic_cost_qr, total_cost_qr = QR.execute() + # #---------------- + # + # ADA = Adaptive_decomposition(Htest, graph_1, cost_limit=(1.1 * algorithmic_cost_qr, 1.1 * total_cost_qr), dimension=dim, Z_prop=False) + # + # matrices_decomposed, best_cost, final_graph = ADA.execute() + # ############################################## + # + # + # V = Verifier(matrices_decomposed, Htest, test_sample_nodes, test_sample_nodes_map, graph_1.lpmap, dim) + # self.assertEqual( len(matrices_decomposed), 17) + # self.assertTrue(V.verify()) + + def test_dfs(self): + pass diff --git a/test/python/compiler/onedit/test_log_local_qr_decomp.py b/test/python/compiler/onedit/test_log_local_qr_decomp.py new file mode 100644 index 0000000..b4108aa --- /dev/null +++ b/test/python/compiler/onedit/test_log_local_qr_decomp.py @@ -0,0 +1,44 @@ +from unittest import TestCase + +from mqt.qudits.compiler.compilation_minitools import UnitaryVerifier +from mqt.qudits.compiler.onedit.mapping_un_aware_transpilation.log_local_qr_decomp import QrDecomp +from mqt.qudits.core import LevelGraph +from mqt.qudits.quantum_circuit import QuantumCircuit + + +class TestLogLocQRPass(TestCase): + def test_transpile(self): + pass + + +class TestQrDecomp(TestCase): + def test_execute(self): + # DIM 3 + dim = 3 + test_sample_edges = [(0, 2, {"delta_m": 0, "sensitivity": 1}), + (1, 2, {"delta_m": 0, "sensitivity": 1}), + ] + test_sample_nodes = [0, 1, 2] + test_sample_nodes_map = [0, 1, 2] + + circuit_3 = QuantumCircuit(1, [3], 0) + graph_1 = LevelGraph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0], 0, circuit_3) + + Htest = circuit_3.h(0) + + QR = QrDecomp(Htest, graph_1, Z_prop=False, not_stand_alone=False) + # gate, graph_orig, Z_prop=False, not_stand_alone=True + + decomp, algorithmic_cost, total_cost = QR.execute() + + V = UnitaryVerifier(decomp, Htest.to_matrix(identities=0), [dim], + test_sample_nodes, test_sample_nodes_map, graph_1.log_phy_map) + # sequence, target, dimensions, nodes=None, initial_map=None, final_map=None + self.assertEqual(len(decomp), 5) + self.assertTrue(V.verify()) + + self.assertEqual((decomp[0].lev_a, decomp[0].lev_b), (1, 2)) + self.assertEqual((decomp[1].lev_a, decomp[1].lev_b), (0, 1)) + self.assertEqual((decomp[2].lev_a, decomp[2].lev_b), (1, 2)) + self.assertEqual(decomp[3].lev_a, 1) + self.assertEqual(decomp[4].lev_a, 2) diff --git a/test/python/compiler/onedit/test_propagate_virtrz.py b/test/python/compiler/onedit/test_propagate_virtrz.py new file mode 100644 index 0000000..5473c90 --- /dev/null +++ b/test/python/compiler/onedit/test_propagate_virtrz.py @@ -0,0 +1,53 @@ +from unittest import TestCase +import numpy as np + + +class TestZPropagationPass(TestCase): + + """def test_tag_generator(self): + gates = [R(np.pi, np.pi / 2, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 2, 0, 1, 3), + R(np.pi, np.pi / 2, 0, 1, 3), Rz(np.pi / 3, 0, 3)] + tags = tag_generator(gates) + + self.assertEqual([0, 1, 1, 1, 2], tags) + + def test_propagate_z(self): + QC = QuantumCircuit(1, 0, 3, None, False) + QC.qreg[0] = [R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 3, 0, 1, 3), + R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] + + list_of_XYrots, Zseq = propagate_z(QC, 0, True) + + self.assertEqual(list_of_XYrots[1].phi, 2 * np.pi / 3) + self.assertEqual(list_of_XYrots[2].phi, 2 * np.pi / 3) + self.assertEqual(list_of_XYrots[0].phi, np.pi) + + self.assertEqual(Zseq[1].theta, 4 * np.pi) + self.assertEqual(Zseq[2].theta, 4 * np.pi) + self.assertEqual(Zseq[0].theta, 2 * np.pi / 3) + + def test_remove_z(self): + QC = QuantumCircuit(1, 0, 3, None, False) + QC.qreg[0] = [R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 3, 0, 1, 3), + R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] + remove_Z(QC, back=True) + + self.assertIsInstance(QC.qreg[0][0], Rz) + self.assertIsInstance(QC.qreg[0][1], Rz) + self.assertIsInstance(QC.qreg[0][2], Rz) + self.assertIsInstance(QC.qreg[0][3], R) + self.assertIsInstance(QC.qreg[0][4], R) + self.assertIsInstance(QC.qreg[0][4], R) + + QC = QuantumCircuit(1, 0, 3, None, False) + QC.qreg[0] = [R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 3, 0, 1, 3), + R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] + remove_Z(QC, False) + + self.assertIsInstance(QC.qreg[0][0], R) + self.assertIsInstance(QC.qreg[0][1], R) + self.assertIsInstance(QC.qreg[0][2], R) + self.assertIsInstance(QC.qreg[0][3], Rz) + self.assertIsInstance(QC.qreg[0][4], Rz) + self.assertIsInstance(QC.qreg[0][4], Rz) +""" \ No newline at end of file diff --git a/test/python/compiler/onedit/test_remove_phase_rotations.py b/test/python/compiler/onedit/test_remove_phase_rotations.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/compiler/onedit/test_swap_routine.py b/test/python/compiler/onedit/test_swap_routine.py new file mode 100644 index 0000000..9d36b52 --- /dev/null +++ b/test/python/compiler/onedit/test_swap_routine.py @@ -0,0 +1,106 @@ +from unittest import TestCase + +import numpy as np + +from mqt.qudits.compiler.onedit.local_operation_swap.swap_routine import cost_calculator, find_logic_from_phys, \ + gate_chain_condition, \ + graph_rule_ongate, \ + graph_rule_update, route_states2rotate_basic +from mqt.qudits.core import LevelGraph +from mqt.qudits.quantum_circuit import QuantumCircuit +from mqt.qudits.quantum_circuit.gates import R + + +class Test(TestCase): + def setUp(self) -> None: + test_sample_edges = [(0, 4, {"delta_m": 0, "sensitivity": 1}), + (0, 3, {"delta_m": 1, "sensitivity": 3}), + (0, 2, {"delta_m": 1, "sensitivity": 3}), + (1, 4, {"delta_m": 0, "sensitivity": 1}), + (1, 3, {"delta_m": 1, "sensitivity": 3}), + (1, 2, {"delta_m": 1, "sensitivity": 3}) + ] + test_sample_nodes = [0, 1, 2, 3, 4] + test_sample_nodes_map = [3, 2, 4, 1, 0] + + self.circuit = QuantumCircuit(1, [5], 0) + self.graph_1 = LevelGraph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0], 0, self.circuit) + self.graph_1.phase_storing_setup() + + def test_find_logic_from_phys(self): + plev_a = 0 + plev_b = 1 + + la, lb = find_logic_from_phys(plev_a, plev_b, self.graph_1) + self.assertEqual(la, 4) + self.assertEqual(lb, 3) + + def test_graph_rule_update(self): + self.circuit = QuantumCircuit(1, [5], 0) + gate = self.circuit.r(0, [0, 1, np.pi, np.pi / 2]) # R(np.pi, np.pi / 2, 0, 1, 5) + nodes_data = self.graph_1.nodes(data=True) + + la, lb = find_logic_from_phys(0, 1, self.graph_1) + self.assertEqual(nodes_data[lb]['phase_storage'], 0.0) + + graph_rule_update(gate, self.graph_1) + + self.assertEqual(nodes_data[lb]['phase_storage'], np.pi) + + def test_graph_rule_ongate(self): + self.circuit = QuantumCircuit(1, [5], 0) + gate = self.circuit.r(0, [0, 1, np.pi, np.pi / 2]) + nodes_data = self.graph_1.nodes(data=True) + + graph_rule_update(gate, self.graph_1) + + new_gate = graph_rule_ongate(gate, self.graph_1) + + self.assertEqual(new_gate.phi, 3 / 2 * np.pi) + + def test_gate_chain_condition(self): + R(self.circuit, "R", 0, [0, 1, np.pi, np.pi / 2], self.circuit.dimensions[0]) + pi_pulses = [R(self.circuit, "R", 0, [0, 1, np.pi, np.pi / 2], self.circuit.dimensions[0]), + R(self.circuit, "R", 0, [1, 2, np.pi, np.pi / 2], self.circuit.dimensions[0])] + gate = R(self.circuit, "R", 0, [0, 2, np.pi / 3, np.pi / 2], self.circuit.dimensions[0]) + # R(np.pi / 3, np.pi / 2, 0, 2, 5) + + new_gate = gate_chain_condition(pi_pulses, gate) + + self.assertEqual(new_gate.theta, -np.pi / 3) + + def test_cost_calculator(self): + test_sample_edges_1 = [(0, 1, {"delta_m": 1, "sensitivity": 1}), + (0, 3, {"delta_m": 0, "sensitivity": 1}), + (4, 3, {"delta_m": 0, "sensitivity": 1}), + (4, 5, {"delta_m": 0, "sensitivity": 1}), + (4, 2, {"delta_m": 0, "sensitivity": 1}) + ] + test_sample_nodes_1 = [0, 1, 2, 3, 4, 5] + test_sample_nodes_map = [0, 1, 2, 3, 4, 5] + non_zeros = 2 + self.circuit_6 = QuantumCircuit(1, [6], 0) + # NODES CAN BE INFERRED BY THE EDGES + test_graph_1 = LevelGraph(test_sample_edges_1, test_sample_nodes_1, test_sample_nodes_map, + [1], 0, self.circuit_6) + r_1 = R(self.circuit_6, "R", 0, [1, 4, np.pi / 4, 0.], self.circuit_6.dimensions[0]) + # R(np.pi / 4, 0, 1, 4, 6) + + total_costing, pi_pulses_routing, new_placement, cost_of_pi_pulses, gate_cost = cost_calculator(r_1, + test_graph_1, + non_zeros) + + self.assertEqual(total_costing, 0.00425) + self.assertEqual(len(pi_pulses_routing), 2) + + self.assertEqual(cost_of_pi_pulses, 2e-3) + + def test_route_states2rotate_basic(self): + self.circuit_5 = QuantumCircuit(1, [5], 0) + gate = R(self.circuit_5, "R", 0, [2, 4, np.pi / 3, np.pi / 2], self.circuit_5.dimensions[0]) + # R(np.pi / 3, np.pi / 2, 2, 4, 5) + cost_of_pi_pulses, pi_pulses_routing, placement = route_states2rotate_basic(gate, self.graph_1) + + self.assertEqual(cost_of_pi_pulses, 0.0004) + self.assertEqual(len(pi_pulses_routing), 1) + self.assertEqual(placement.log_phy_map, [0, 2, 4, 1, 3]) diff --git a/test/python/compiler/twodit/__init__.py b/test/python/compiler/twodit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/compiler/twodit/entangled_qr/__init__.py b/test/python/compiler/twodit/entangled_qr/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/compiler/twodit/entangled_qr/test_crot.py b/test/python/compiler/twodit/entangled_qr/test_crot.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/compiler/twodit/entangled_qr/test_pswap.py b/test/python/compiler/twodit/entangled_qr/test_pswap.py new file mode 100644 index 0000000..e69de29 diff --git a/test/python/test.py b/test/python/test.py deleted file mode 100644 index 5e69f4c..0000000 --- a/test/python/test.py +++ /dev/null @@ -1,42 +0,0 @@ -from __future__ import annotations - -from mqt.qudits._qudits.misim import state_vector_simulation -from mqt.qudits.quantum_circuit import QuantumCircuit, QuantumRegister -from mqt.qudits.simulation.noise_tools import Noise, NoiseModel - -qreg_example = QuantumRegister("reg", 2, [2, 3]) -circ = QuantumCircuit(qreg_example) -h = circ.h(0) -csum = circ.csum([0, 1]) -# x = circ.x(1).control([0], [1]) -# r = circ.r(0, [0, 1, np.pi/3, -np.pi / 2]) -# r2 = circ.r(0, [0, 1, np.pi, np.pi / 2]).control([1], [1]) - -# Depolarizing quantum errors -local_error = Noise(probability_depolarizing=0.001, probability_dephasing=0.001) -local_error_rz = Noise(probability_depolarizing=0.03, probability_dephasing=0.03) -entangling_error = Noise(probability_depolarizing=0.1, probability_dephasing=0.001) -entangling_error_extra = Noise(probability_depolarizing=0.1, probability_dephasing=0.1) -entangling_error_on_target = Noise(probability_depolarizing=0.1, probability_dephasing=0.0) -entangling_error_on_control = Noise(probability_depolarizing=0.01, probability_dephasing=0.0) - -# Add errors to noise_tools model - -noise_model = NoiseModel() # We know that the architecture is only two qudits -# Very noisy gate_matrix -noise_model.add_all_qudit_quantum_error(local_error, ["csum"]) -noise_model.add_recurrent_quantum_error_locally(local_error, ["csum"], [0]) -# Entangling gates -noise_model.add_nonlocal_quantum_error(entangling_error, ["cx", "ls", "ms"]) -noise_model.add_nonlocal_quantum_error_on_target(entangling_error_on_target, ["cx", "ls", "ms"]) -noise_model.add_nonlocal_quantum_error_on_control(entangling_error_on_control, ["csum", "cx", "ls", "ms"]) -# Super noisy Entangling gates -noise_model.add_nonlocal_quantum_error(entangling_error_extra, ["csum"]) -# Local Gates -noise_model.add_quantum_error_locally(local_error, ["h", "rxy", "s", "x", "z"]) -noise_model.add_quantum_error_locally(local_error_rz, ["rz", "virtrz"]) - -print("HELLOO") - -# num_qudits, dimensions, props = qcread.get_quantum_circuit_properties(circ) -print(state_vector_simulation(circ, NoiseModel()))