From 5f489f4d6019c02989c99e26dd9a69af31db3750 Mon Sep 17 00:00:00 2001 From: Dror Segman Date: Sun, 16 Feb 2025 19:39:52 +0200 Subject: [PATCH] fine tune --- .../Classiq_tutorial/Execution_tutorial.ipynb | 132 ++++++++++++++++++ .../Qmod_tutorial_part1.ipynb | 2 +- .../classiq_overview_tutorial.ipynb | 2 +- .../Classiq_tutorial/synthesis_tutorial.ipynb | 2 +- 4 files changed, 135 insertions(+), 3 deletions(-) diff --git a/tutorials/Classiq_tutorial/Execution_tutorial.ipynb b/tutorials/Classiq_tutorial/Execution_tutorial.ipynb index e69de29b..757d0fa0 100644 --- a/tutorials/Classiq_tutorial/Execution_tutorial.ipynb +++ b/tutorials/Classiq_tutorial/Execution_tutorial.ipynb @@ -0,0 +1,132 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# [WIP] Execution Tutorial" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A typical workflow with classiq ends with the execution of a quantum program on a chosen simulator or hardware (and post-processing the results).\n", + "\n", + "\n", + "Another typical workflow, called _hybrid execution_ is based not on the execution of a single quantum program, but on iterative executions of quantum progarams that are tuned between iterations according to some classical logic (see for example the [VQE algorithm](https://en.wikipedia.org/wiki/Variational_quantum_eigensolver)).\n", + "\n", + "In this tutorial, we will cover the required knowledge for both usecases:\n", + "- Specifying the quantum backend (hardware or simulator) on which to run, and the `n_shots` number of times to run.\n", + "- use `ExecutionSession` as a context manager for the execution:\n", + " - Choosing between `sample` (measurement aling the z-axis) and `estimate` as the execution primitive.\n", + " - Creating parametric circuits and executing them for different parameter-values.\n", + " - Using batch-execution to obtain multiple results in a single command.\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Specifying Backend and Number of Shots\n", + "\n", + "Let's look into the following quantum model:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Opening: https://platform.classiq.io/circuit/2t8Hqj0F0Ixb67vJRXiGzQLjy0G?version=0.68.0\n" + ] + } + ], + "source": [ + "from classiq import *\n", + "\n", + "@qfunc\n", + "def main(x: Output[QBit]):\n", + " allocate(1, x)\n", + " RX(3.14, x)\n", + "\n", + "\n", + "qmod = create_model(main)\n", + "qprog = synthesize(qmod)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[***] show how to specify BE and n_shots, both in IDE and in code." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Using Execution Session as a Context Manager\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[***] add subsections according to details in the first section.\n", + "use Nadav's notebook and the user guide as resources." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## [Internal]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "@qfunc\n", + "def main(x: Output[QBit], t: CReal, w: CReal):\n", + " allocate(1, x)\n", + " RX(t, x)\n", + " RZ(w, x)\n", + "\n", + "\n", + "qmod = create_model(main)\n", + "qprog = synthesize(qmod)\n", + "# execution_session = ExecutionSession(qprog)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "external-user-venv-PaJZMdG0-py3.11", + "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.11.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/tutorials/Classiq_tutorial/Qmod_tutorial_part1.ipynb b/tutorials/Classiq_tutorial/Qmod_tutorial_part1.ipynb index f5773a46..b0347d25 100644 --- a/tutorials/Classiq_tutorial/Qmod_tutorial_part1.ipynb +++ b/tutorials/Classiq_tutorial/Qmod_tutorial_part1.ipynb @@ -185,7 +185,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Exercise #2 - Repeat\n", + "### Exercise #2 - The Repeat Statement\n", "\n", "Use Qmod's [`repeat`](https://docs.classiq.io/latest/qmod-reference/language-reference/statements/classical-control-flow/#classical-repeat) statement to create your own Hadamard Transform - a function that takes a `QArray` of an unspecified size and applies `H` to each of its qubits.\n", "\n", diff --git a/tutorials/Classiq_tutorial/classiq_overview_tutorial.ipynb b/tutorials/Classiq_tutorial/classiq_overview_tutorial.ipynb index 587bc1ef..1a69ff5b 100644 --- a/tutorials/Classiq_tutorial/classiq_overview_tutorial.ipynb +++ b/tutorials/Classiq_tutorial/classiq_overview_tutorial.ipynb @@ -8,7 +8,7 @@ "In this notebook we introduce a typical workflow with Classiq:\n", "- **Designing a quantum algorithm** using the Qmod language and it's accompanied function library.\n", "- **Synthesizing the algorithm** into a concrete circuit implementation.\n", - "- **Executing the algorithm** on a chosen simulator or quantum harware.\n", + "- **Executing the algorithm** on a chosen simulator or quantum hardware.\n", "- **Post-processing** the results.\n", "\n", "Later tutorials dive into each of the above stages, providing hands-on interactive guides that go from the very basics to advanced usage. \n", diff --git a/tutorials/Classiq_tutorial/synthesis_tutorial.ipynb b/tutorials/Classiq_tutorial/synthesis_tutorial.ipynb index 16967e30..7d10c186 100644 --- a/tutorials/Classiq_tutorial/synthesis_tutorial.ipynb +++ b/tutorials/Classiq_tutorial/synthesis_tutorial.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Synthesis\n", + "# Synthesis Tutorial\n", "\n", "Classiq synthesis engine takes a high-level program written in Classiq's Qmod language, and compiles it into an executable gate-based circuit.\\\n", "In most cases, there is not a single implementation that is superior in all manners - there might be one implementation that requires the lowest number of qubits, another that minimizes the gate-count etc. \n",