Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notebooks #157

Merged
merged 11 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
652 changes: 158 additions & 494 deletions docs/tutorials/0_tutorial_qiskit-braket-provider_overview.ipynb

Large diffs are not rendered by default.

81 changes: 38 additions & 43 deletions docs/tutorials/1_tutorial_vqe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,39 @@
"id": "7f19aecc",
"metadata": {},
"source": [
"# Tutorial: Runing VQE on Braket backend"
"# Running VQE on an Amazon Braket backend"
]
},
{
"cell_type": "markdown",
"id": "55c313b7",
"metadata": {},
"source": [
"Let's review an example of running algorithms using Qiskit on Braket devices.\n",
"\n",
"Qiskit provides a number of Algorithms and they are grouped by category according to the task they can perform. For instance Minimum Eigensolvers to find the smallest eigen value of an operator, for example ground state energy of a chemistry Hamiltonian or a solution to an optimization problem when expressed as an Ising Hamiltonian.\n",
"\n",
"Algorithms are configurable and often part of the configuration will be in the form of smaller building blocks, of which different instances of the building block type can be given. For instance with `VQE`, the Variational Quantum Eigensolver, it takes a trial wavefunction, in the form of a `QuantumCircuit` and a classical optimizer among other things.\n",
"\n",
"Let’s take a look at an example to construct a VQE instance. Here `TwoLocal` is the variational form (trial wavefunction), a parameterized circuit which can be varied, and SLSQP a classical optimizer. Then we pass the Hamiltonian to `compute_minimum_eigenvalue` method of `VQE` to get result.\n",
"\n",
"Full example and explanation of algorithm detail you can find [here](https://qiskit-community.github.io/qiskit-algorithms/tutorials/01_algorithms_introduction.html).\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "ebac1b5c",
"metadata": {},
"outputs": [],
"source": [
"from qiskit.algorithms.minimum_eigensolvers import VQE\n",
"from qiskit.quantum_info import SparsePauliOp\n",
"from qiskit.algorithms.optimizers import SLSQP\n",
"from qiskit.circuit.library import TwoLocal\n",
"from qiskit.utils import algorithm_globals\n",
"from qiskit.primitives import BackendEstimator\n",
"from qiskit.quantum_info import SparsePauliOp\n",
"from qiskit_algorithms.minimum_eigensolvers import VQE\n",
"from qiskit_algorithms.optimizers import SLSQP\n",
"from qiskit_algorithms.utils import algorithm_globals\n",
"\n",
"from qiskit_braket_provider import AWSBraketProvider, BraketLocalBackend\n",
"\n",
Expand All @@ -38,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "e94c63b1",
"metadata": {},
"outputs": [
Expand All @@ -48,7 +65,7 @@
"BraketBackend[default]"
]
},
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -59,34 +76,12 @@
"local_simulator"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b618fa9e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"BraketBackend[SV1]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"state_vector_simulator_backend = provider.get_backend(\"SV1\")\n",
"state_vector_simulator_backend"
]
},
{
"cell_type": "markdown",
"id": "140737fe",
"metadata": {},
"source": [
"Running VQE\n",
"## Running VQE\n",
"\n",
"\n",
"\n",
Expand All @@ -95,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "9081f3b3",
"metadata": {},
"outputs": [
Expand All @@ -105,22 +100,22 @@
"text": [
"{ 'aux_operators_evaluated': None,\n",
" 'cost_function_evals': 9,\n",
" 'eigenvalue': -1.0778032163726936,\n",
" 'optimal_circuit': <qiskit.circuit.library.n_local.two_local.TwoLocal object at 0x13801f5d0>,\n",
" 'optimal_parameters': { ParameterVectorElement(θ[0]): 3.611860069224077,\n",
" ParameterVectorElement(θ[1]): 4.19301252102391,\n",
" 'eigenvalue': -1.0522310440132328,\n",
" 'optimal_circuit': <qiskit.circuit.library.n_local.two_local.TwoLocal object at 0x17af130d0>,\n",
" 'optimal_parameters': { ParameterVectorElement(θ[1]): 4.19301252102391,\n",
" ParameterVectorElement(θ[0]): 3.611860069224077,\n",
" ParameterVectorElement(θ[2]): 0.6019852007557844,\n",
" ParameterVectorElement(θ[6]): -5.466043598406607,\n",
" ParameterVectorElement(θ[7]): 0.6984088030463615,\n",
" ParameterVectorElement(θ[3]): 5.949536809130025,\n",
" ParameterVectorElement(θ[4]): -3.3070470445355764,\n",
" ParameterVectorElement(θ[5]): 1.8462931831829383,\n",
" ParameterVectorElement(θ[6]): -5.466043598406607,\n",
" ParameterVectorElement(θ[7]): 0.6984088030463615},\n",
" ParameterVectorElement(θ[5]): 1.8462931831829383},\n",
" 'optimal_point': array([ 3.61186007, 4.19301252, 0.6019852 , 5.94953681, -3.30704704,\n",
" 1.84629318, -5.4660436 , 0.6984088 ]),\n",
" 'optimal_value': -1.0778032163726936,\n",
" 'optimal_value': -1.0522310440132328,\n",
" 'optimizer_evals': None,\n",
" 'optimizer_result': <qiskit.algorithms.optimizers.optimizer.OptimizerResult object at 0x138be0fd0>,\n",
" 'optimizer_time': 4.060570001602173}\n"
" 'optimizer_result': <qiskit_algorithms.optimizers.optimizer.OptimizerResult object at 0x12411d700>,\n",
" 'optimizer_time': 0.6713869571685791}\n"
]
}
],
Expand Down Expand Up @@ -167,7 +162,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.9.18"
}
},
"nbformat": 4,
Expand Down
Loading
Loading