{ "cells": [ { "cell_type": "markdown", "id": "f268e562-82fd-4197-b77f-4cb66cd49716", "metadata": {}, "source": [ "# pytket-azure example usage\n", "\n", "This notebook shows how to use the pytket-azure extension to submit pytket circuits to quantinuum devices using the azure credentials.\n", "\n", "First you need to install the extension. The best way to do this is ```pip install pytket-azure```\n", "This also installs pytket if not installed already.\n", "\n" ] }, { "cell_type": "markdown", "id": "f66ab4cd-16dc-4809-9cae-9ffa4b0141f1", "metadata": {}, "source": [ "First import the Backend, it offers the needed functionality to login, send circuits and get results." ] }, { "cell_type": "code", "execution_count": 1, "id": "16f85bb6-e665-4fc0-a908-3eaf5f819591", "metadata": {}, "outputs": [], "source": [ "from pytket.extensions.azure import AzureBackend" ] }, { "cell_type": "markdown", "id": "f9af7004-a97e-48d4-bcab-ae5cf98048e1", "metadata": {}, "source": [ "The next steps is to select the device you want to use. You can find all supported devices [here](https://learn.microsoft.com/en-us/azure/quantum/provider-quantinuum?tabs=tabid-mcmr-with-q-provider%2Ctabid-arbitrary-angle-zz-gates-with-q-provider%2Ctabid-su4-with-q-provider%2Ctabid-emulator-noise-parameters-with-q-provider%2Ctabid-tket-compilation-with-q-provider)\n", "There are three groups: Syntax Checker, Emulator and devices. " ] }, { "cell_type": "markdown", "id": "a069ed6b-54c4-4394-b8a8-87aedf83f0d4", "metadata": {}, "source": [ "## Syntax Checker h1-1sc" ] }, { "cell_type": "code", "execution_count": 2, "id": "33629c9f-4b2e-4b94-b2d4-ebe0d4ac0424", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "True\n" ] } ], "source": [ "backend_sc = AzureBackend(\"quantinuum.sim.h1-1sc\")\n", "print(backend_sc.is_available())" ] }, { "cell_type": "markdown", "id": "446ce811-12c1-4f7b-a88f-fb3110c34573", "metadata": {}, "source": [ "You can use the backend to compile your pytket circuit to the right gateset and send it to the device." ] }, { "cell_type": "code", "execution_count": 3, "id": "55f9870c-9cad-4df2-887f-edddf0b43d05", "metadata": {}, "outputs": [], "source": [ "from pytket import Circuit\n", "\n", "circ = Circuit(2, 2)\n", "circ.H(0)\n", "circ.CX(0,1)\n", "circ.Measure(0, 0)\n", "circ.Measure(1, 1)\n", "compiled_circuit = backend_sc.get_compiled_circuit(circ, 3)\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "7d5b65ea-13a7-48d5-92bd-6c6e0c190b85", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "