{ "cells": [ { "cell_type": "markdown", "id": "48c6731f-5188-41c1-afc4-123c6ed796ae", "metadata": {}, "source": [ "# Basic circuit execution\n", "This notebooks illustrates how you can run your qiskit code on the Quantum Inspire platform.\n", "## This notebook makes the following assumptions:\n", "- The qi cli tool is installed and you are logged in, see [these instructions](https://github.com/QuTech-Delft/quantuminspire?tab=readme-ov-file#installation)\n", "- account exists on the Quantum Inspire platform\n", "- qiskit plugin installed (pip install qiskit-quantuminspire) in the same environment as this notebook" ] }, { "cell_type": "markdown", "id": "0d8ba9f9-9b38-4a86-9252-0b9b9fcdc83f", "metadata": {}, "source": [ "## The necessary imports" ] }, { "cell_type": "code", "execution_count": null, "id": "3d4b3950-fe75-47cf-afb5-2286be7c01b4", "metadata": {}, "outputs": [], "source": [ "from qiskit import QuantumCircuit\n", "\n", "from qiskit_quantuminspire.qi_provider import QIProvider" ] }, { "cell_type": "markdown", "id": "0b464f03-9573-4c3c-852c-3ea4477b59ec", "metadata": {}, "source": [ "## What QI Backends are available?" ] }, { "cell_type": "code", "execution_count": null, "id": "df119aa6-6b48-43a5-aa68-ecf4f7c0dc38", "metadata": {}, "outputs": [], "source": [ "provider = QIProvider()\n", "\n", "# Show all current supported backends:\n", "print(provider.backends())" ] }, { "cell_type": "markdown", "id": "a9f9b123-9b11-4d62-a4ab-8af8f08f7153", "metadata": {}, "source": [ "## Create your Qiskit Circuit\n", "Let's create a bell state circuit." ] }, { "cell_type": "code", "execution_count": null, "id": "e6bbe6af-9908-46cb-8638-8f29966fbf61", "metadata": {}, "outputs": [], "source": [ "circuit = QuantumCircuit(3, 10)\n", "circuit.h(0)\n", "circuit.cx(0, 1)\n", "circuit.measure(0, 0)\n", "circuit.measure(1, 1)" ] }, { "cell_type": "markdown", "id": "a638262c-c785-4a4f-9ba2-32cc534225f3", "metadata": {}, "source": [ "## Create the Job in the Quantum Inspire Platform\n", "On the appropriate backend, you run your circuit. Be aware that if your circuit contains gates that are not supported by the target, compilation errors may arise." ] }, { "cell_type": "code", "execution_count": null, "id": "1f446ddc-7fe6-4731-9840-da1775e10e0f", "metadata": {}, "outputs": [], "source": [ "backend = provider.get_backend(name=\"QX emulator\")\n", "job = backend.run(circuit, shots=1024)" ] }, { "cell_type": "markdown", "id": "9645611e-bd42-4814-9266-243676877e8d", "metadata": {}, "source": [ "## Obtain the result\n", "After a while the result should be available. Depending on the current load, the time for completion may vary." ] }, { "cell_type": "code", "execution_count": null, "id": "4302f110-e5c1-47ea-8e48-994db317a74c", "metadata": {}, "outputs": [], "source": [ "result = job.result()\n", "print(result)" ] } ], "metadata": { "kernelspec": { "display_name": "qiskit-quantuminspire-C0W6c0G_-py3.12", "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.12.5" } }, "nbformat": 4, "nbformat_minor": 5 }