Skip to content

Commit 42b4e82

Browse files
Dror SegmanDror Segman
authored andcommitted
fine tune
1 parent 7c149f3 commit 42b4e82

File tree

4 files changed

+135
-3
lines changed

4 files changed

+135
-3
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# [WIP] Execution Tutorial"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"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",
15+
"\n",
16+
"\n",
17+
"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",
18+
"\n",
19+
"In this tutorial, we will cover the required knowledge for both usecases:\n",
20+
"- Specifying the quantum backend (hardware or simulator) on which to run, and the `n_shots` number of times to run.\n",
21+
"- use `ExecutionSession` as a context manager for the execution:\n",
22+
" - Choosing between `sample` (measurement aling the z-axis) and `estimate` as the execution primitive.\n",
23+
" - Creating parametric circuits and executing them for different parameter-values.\n",
24+
" - Using batch-execution to obtain multiple results in a single command.\n",
25+
"\n"
26+
]
27+
},
28+
{
29+
"cell_type": "markdown",
30+
"metadata": {},
31+
"source": [
32+
"## Specifying Backend and Number of Shots\n",
33+
"\n",
34+
"Let's look into the following quantum model:"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 1,
40+
"metadata": {},
41+
"outputs": [
42+
{
43+
"name": "stdout",
44+
"output_type": "stream",
45+
"text": [
46+
"Opening: https://platform.classiq.io/circuit/2t8Hqj0F0Ixb67vJRXiGzQLjy0G?version=0.68.0\n"
47+
]
48+
}
49+
],
50+
"source": [
51+
"from classiq import *\n",
52+
"\n",
53+
"@qfunc\n",
54+
"def main(x: Output[QBit]):\n",
55+
" allocate(1, x)\n",
56+
" RX(3.14, x)\n",
57+
"\n",
58+
"\n",
59+
"qmod = create_model(main)\n",
60+
"qprog = synthesize(qmod)"
61+
]
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"metadata": {},
66+
"source": [
67+
"[***] show how to specify BE and n_shots, both in IDE and in code."
68+
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"## Using Execution Session as a Context Manager\n"
75+
]
76+
},
77+
{
78+
"cell_type": "markdown",
79+
"metadata": {},
80+
"source": [
81+
"[***] add subsections according to details in the first section.\n",
82+
"use Nadav's notebook and the user guide as resources."
83+
]
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"metadata": {},
88+
"source": [
89+
"## [Internal]"
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": null,
95+
"metadata": {},
96+
"outputs": [],
97+
"source": [
98+
"@qfunc\n",
99+
"def main(x: Output[QBit], t: CReal, w: CReal):\n",
100+
" allocate(1, x)\n",
101+
" RX(t, x)\n",
102+
" RZ(w, x)\n",
103+
"\n",
104+
"\n",
105+
"qmod = create_model(main)\n",
106+
"qprog = synthesize(qmod)\n",
107+
"# execution_session = ExecutionSession(qprog)"
108+
]
109+
}
110+
],
111+
"metadata": {
112+
"kernelspec": {
113+
"display_name": "external-user-venv-PaJZMdG0-py3.11",
114+
"language": "python",
115+
"name": "python3"
116+
},
117+
"language_info": {
118+
"codemirror_mode": {
119+
"name": "ipython",
120+
"version": 3
121+
},
122+
"file_extension": ".py",
123+
"mimetype": "text/x-python",
124+
"name": "python",
125+
"nbconvert_exporter": "python",
126+
"pygments_lexer": "ipython3",
127+
"version": "3.11.6"
128+
}
129+
},
130+
"nbformat": 4,
131+
"nbformat_minor": 2
132+
}

tutorials/Classiq_tutorial/Qmod_tutorial_part1.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
"cell_type": "markdown",
186186
"metadata": {},
187187
"source": [
188-
"### Exercise #2 - Repeat\n",
188+
"### Exercise #2 - The Repeat Statement\n",
189189
"\n",
190190
"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",
191191
"\n",

tutorials/Classiq_tutorial/classiq_overview_tutorial.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"In this notebook we introduce a typical workflow with Classiq:\n",
99
"- **Designing a quantum algorithm** using the Qmod language and it's accompanied function library.\n",
1010
"- **Synthesizing the algorithm** into a concrete circuit implementation.\n",
11-
"- **Executing the algorithm** on a chosen simulator or quantum harware.\n",
11+
"- **Executing the algorithm** on a chosen simulator or quantum hardware.\n",
1212
"- **Post-processing** the results.\n",
1313
"\n",
1414
"Later tutorials dive into each of the above stages, providing hands-on interactive guides that go from the very basics to advanced usage. \n",

tutorials/Classiq_tutorial/synthesis_tutorial.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Synthesis\n",
7+
"# Synthesis Tutorial\n",
88
"\n",
99
"Classiq synthesis engine takes a high-level program written in Classiq's Qmod language, and compiles it into an executable gate-based circuit.\\\n",
1010
"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",

0 commit comments

Comments
 (0)