{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Decompiler and Circuit Optimizer\n", "\n", "Qlasskit offers two useful tool for circuit analysis and optimization.\n", "\n", "- Decompiler: given a quantum circuit is able to detect section that can be represented as boolean expressions\n", "- circuit_boolean_optimizer: a pipeline that given a quantum circuit, decompose it in boolean expressions form and optimize it using boolean algebra" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We first write a qlasskit function that perform an And between the elements of a Qlist; we use the `fastOptimizer` in order to obtain an unoptimized circuit." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "QCircuit(7 gates, 6 qubits)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from qlasskit import qlassfa, qlassf, boolopt, Qlist\n", "from qlasskit.decompiler import Decompiler, circuit_boolean_optimizer\n", "\n", "\n", "@qlassfa(bool_optimizer=boolopt.fastOptimizer)\n", "def qf(a: Qlist[bool, 2]) -> bool:\n", " s = True\n", " for i in a:\n", " s = s and i\n", " return s\n", "\n", "\n", "qf.circuit()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As we can see from the circuit, this is not the best solution." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAGwCAYAAABcnuQpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA3tUlEQVR4nO3dfXwV5Z3///echJAbEkIIECCBAEmABJIgiNJaLC608kVsrfVmi1T7Zfv1u7+ysrt8iWv76Nr+s4jL1i2ljxbdum53V0qrvUGotbpoi7TaIAYRIpFAIHcHOCQhNySQk3N+f0xBIgnJOTl31+T1fDzyCJyZa64PYXLmfWauucby+/1+AQAAGMoV7QIAAACGgjADAACMRpgBAABGI8wAAACjEWYAAID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iEGQAAYDTCDAAAMBphBgAAGI0wAwAAjEaYAQAARiPMAAAAoxFmAACA0QgzAADAaIQZAABgNMIMAAAwGmEGAAAYjTADAACMRpgBAABGI8wAAACjEWYAAIDRCDMAAMBohBkAAGA0wgwAADAaYQYAABiNMAMAAIxGmAEAAEYjzAAAAKMRZgAAgNEIMwAAwGiEGQAAYDTCDAAAMBphBgAAGI0wAwAAjEaYAQAARiPMAAAAo/3/smsyVKO4ZEYAAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "qf.export().draw(\"mpl\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using the decompiler we are able to translate a quantum circuit to its boolean representation (if applicable):" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "DecompiledResults[\n", "\t(\n", "\t\t(0, 7)\n", "\t\t(X, [2], None), (CCX, [0, 2, 3], None), (CCX, [1, 3, 4], None), (CX, [4, 5], None), (CCX, [1, 3, 4], None), (CCX, [0, 2, 3], None), (X, [2], None)\n", "\t\t(q5, q4 ^ q5 ^ (q1 & (q3 ^ (q0 & ~q2))))\n", "\t)\n", "]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dc = Decompiler().decompile(qf.circuit())\n", "dc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `circuit_boolean_optimizer` allows us to perform boolean optimizations in a quantum circuit; from the previous unoptimized example, we get the following optimized circuit:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAALAAAAGwCAYAAAAJwO/qAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAdNklEQVR4nO3dfVCcB73o8e8SmiwvSxMgdSNLg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E0YCWaBqxE04CVaP8fo0PwYsUiEecAAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "qc = circuit_boolean_optimizer(qf.circuit(), preserve=[0, 1])\n", "qc.export().draw(\"mpl\")" ] } ], "metadata": { "kernelspec": { "display_name": "qlasskit_310-env", "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", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 2 }