microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
samples/estimation/estimation-frontier-widgets.ipynb
122lines · modecode
| 1 | { |
| 2 | "cells": [ |
| 3 | { |
| 4 | "cell_type": "code", |
| 5 | "execution_count": null, |
| 6 | "metadata": {}, |
| 7 | "outputs": [], |
| 8 | "source": [ |
| 9 | "# If necessary, install the qsharp package and the qsharp-widgets\n", |
| 10 | "# by running the following command in a terminal:\n", |
| 11 | "# pip install qsharp qsharp-widgets -U\n", |
| 12 | "\n", |
| 13 | "import qsharp\n", |
| 14 | "from qsharp_widgets import SpaceChart, EstimateDetails, EstimatesOverview, EstimatesPanel\n", |
| 15 | "\n", |
| 16 | "with open(\"Dynamics.qs\", \"r\") as f:\n", |
| 17 | " contents = f.read()\n", |
| 18 | "qsharp.eval(contents)" |
| 19 | ] |
| 20 | }, |
| 21 | { |
| 22 | "cell_type": "code", |
| 23 | "execution_count": null, |
| 24 | "metadata": {}, |
| 25 | "outputs": [], |
| 26 | "source": [ |
| 27 | "result = qsharp.estimate(\n", |
| 28 | " \"Main()\",\n", |
| 29 | " [\n", |
| 30 | " {\n", |
| 31 | " \"qubitParams\": { \"name\": \"qubit_gate_ns_e3\" },\n", |
| 32 | " \"estimateType\": \"frontier\",\n", |
| 33 | " },\n", |
| 34 | " {\n", |
| 35 | " \"qubitParams\": { \"name\": \"qubit_gate_ns_e4\" },\n", |
| 36 | " \"estimateType\": \"frontier\",\n", |
| 37 | " },\n", |
| 38 | " {\n", |
| 39 | " \"qubitParams\": { \"name\": \"qubit_gate_us_e3\" },\n", |
| 40 | " \"estimateType\": \"frontier\",\n", |
| 41 | " },\n", |
| 42 | " {\n", |
| 43 | " \"qubitParams\": { \"name\": \"qubit_gate_us_e4\" },\n", |
| 44 | " \"estimateType\": \"frontier\",\n", |
| 45 | " },\n", |
| 46 | " {\n", |
| 47 | " \"qubitParams\": { \"name\": \"qubit_maj_ns_e4\" },\n", |
| 48 | " \"qecScheme\": { \"name\": \"floquet_code\" },\n", |
| 49 | " \"estimateType\": \"frontier\",\n", |
| 50 | " },\n", |
| 51 | " {\n", |
| 52 | " \"qubitParams\": { \"name\": \"qubit_maj_ns_e6\" },\n", |
| 53 | " \"qecScheme\": { \"name\": \"floquet_code\" },\n", |
| 54 | " \"estimateType\": \"frontier\",\n", |
| 55 | " },\n", |
| 56 | " ]\n", |
| 57 | ")" |
| 58 | ] |
| 59 | }, |
| 60 | { |
| 61 | "cell_type": "code", |
| 62 | "execution_count": null, |
| 63 | "metadata": {}, |
| 64 | "outputs": [], |
| 65 | "source": [ |
| 66 | "# The full experience with the summary table, the space-time diagrams, the space diagrams, and the estimate details\n", |
| 67 | "EstimatesPanel(result)" |
| 68 | ] |
| 69 | }, |
| 70 | { |
| 71 | "cell_type": "code", |
| 72 | "execution_count": null, |
| 73 | "metadata": {}, |
| 74 | "outputs": [], |
| 75 | "source": [ |
| 76 | "# Qubit usage diagram for the first (estimate index=0) run and the third (point index=2) shortest runtime\n", |
| 77 | "SpaceChart(result[0],8)" |
| 78 | ] |
| 79 | }, |
| 80 | { |
| 81 | "cell_type": "code", |
| 82 | "execution_count": null, |
| 83 | "metadata": {}, |
| 84 | "outputs": [], |
| 85 | "source": [ |
| 86 | "# Estimate details usage for the second (estimate index=0) run and the fourth (point index=3) shortest runtime\n", |
| 87 | "EstimateDetails(result[1], 4)" |
| 88 | ] |
| 89 | }, |
| 90 | { |
| 91 | "cell_type": "code", |
| 92 | "execution_count": null, |
| 93 | "metadata": {}, |
| 94 | "outputs": [], |
| 95 | "source": [ |
| 96 | "# Estimate overview with the summary table and the space-time diagram\n", |
| 97 | "EstimatesOverview(result, colors=[\"#1f77b4\", \"#ff7f0e\", \"blue\", \"red\", \"green\", \"yellow\"], runNames=[\"Gate ns e3, surface\", \"Gate ns e4, surface\", \"Gate us e3, surface\", \"Gate us e4, surface\", \"Majorana ns e4, floquet\", \"Majorana ns e6, floquet\"])" |
| 98 | ] |
| 99 | } |
| 100 | ], |
| 101 | "metadata": { |
| 102 | "kernelspec": { |
| 103 | "display_name": "Python 3", |
| 104 | "language": "python", |
| 105 | "name": "python3" |
| 106 | }, |
| 107 | "language_info": { |
| 108 | "codemirror_mode": { |
| 109 | "name": "ipython", |
| 110 | "version": 3 |
| 111 | }, |
| 112 | "file_extension": ".py", |
| 113 | "mimetype": "text/x-python", |
| 114 | "name": "python", |
| 115 | "nbconvert_exporter": "python", |
| 116 | "pygments_lexer": "ipython3", |
| 117 | "version": "3.12.1" |
| 118 | } |
| 119 | }, |
| 120 | "nbformat": 4, |
| 121 | "nbformat_minor": 2 |
| 122 | } |
| 123 | |