-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dror Segman
authored and
Dror Segman
committed
Feb 16, 2025
1 parent
16fcc54
commit 5f489f4
Showing
4 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters