andrewmusselman commented on code in PR #472: URL: https://github.com/apache/mahout/pull/472#discussion_r1842930573
########## examples/Simple_Example.ipynb: ########## @@ -29,7 +29,7 @@ { "cell_type": "code", "source": [ - "!pip install git+https://github.com/apache/mahout.git@main" + "# pip install git+https://github.com/apache/mahout.git@main" Review Comment: Is this supposed to be commented out? ########## examples/Optimization_Example.ipynb: ########## @@ -0,0 +1,144 @@ +{ Review Comment: Does this need an "Open in Colab" button? ########## examples/Optimization_Example.ipynb: ########## @@ -0,0 +1,144 @@ +{ + "nbformat": 4, + "nbformat_minor": 2, + "cells": [ + { + "cell_type": "code", + "source": [ + "# pip install git+https://github.com/apache/mahout.git@main" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "lNDTZhztd2dp", + "outputId": "ea3b9e41-43a8-44e7-9daf-e62e71d93143" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Quantum Circuit Parameterization and Optimization\n", + "\n", + "In this notebook, we'll explore how to create parameterized quantum circuits using the QuMat framework. This feature allows us to bind values to parameters at execution time, paving the way for optimization tasks in quantum computing.\n", + "\n", + "## Overview\n", + "\n", + "1. **Parameter Handling**: We will use symbols to represent parameters in quantum gates, allowing these parameters to be updated during optimization.\n", + "2. **Circuit Execution with Binding**: We will bind parameter values to a circuit prior to its execution, a critical step in parameter optimization routines.\n", + "3. **Simple Optimization Loop**: We'll implement a basic optimization loop that updates parameters based on a cost function.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Step 1: Setting Up\n", + "\n", + "We start by setting up the backend configuration and initializing the QuMat framework. This framework interfaces with quantum computing libraries like Qiskit or Cirq to manage the underlying quantum computations.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from qumat.qumat import QuMat\n", + "\n", + "# Configure the backend to use Qiskit with a simulator\n", + "backend_config = {\n", + " 'backend_name': 'qiskit',\n", + " 'backend_options': {'simulator_type': 'qasm_simulator', 'shots': 1024}\n", + "}\n", + "\n", + "# Create an instance of QuMat\n", + "qumat_instance = QuMat(backend_config)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Step 2: Creating a Parameterized Quantum Circuit\n", + "\n", + "We create a simple quantum circuit with one qubit and apply parameterized RX, RY, and RZ gates. The parameters will be defined symbolically, allowing them to be replaced with actual values during execution.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# Create a quantum circuit with 1 qubit\n", + "qumat_instance.create_empty_circuit(1)\n", + "\n", + "# Apply parameterized RX, RY, and RZ gates\n", + "qumat_instance.apply_rx_gate(0, 'theta')\n", Review Comment: I don't see where `theta`, `phi`, and `lambda` are defined, should we add those definitions? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@mahout.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org