diff --git a/00_introduction.ipynb b/00_introduction.ipynb index d1d747f16..b4861e2d7 100644 --- a/00_introduction.ipynb +++ b/00_introduction.ipynb @@ -204,11 +204,11 @@ " Description: The aligned quantum kernel matrix evaluated with the optimized kernel parameters on the training data.\n", " Type: numpy.ndarray\n", "==================================================\n", - "runtime-simple:\n", - " Name: runtime-simple\n", - " Description: Simple runtime program used for testing.\n", + "sample-program:\n", + " Name: sample-program\n", + " Description: A sample runtime program.\n", " Version: 1\n", - " Creation date: 2021-05-05T23:30:21Z\n", + " Creation date: 2021-06-04T14:11:19Z\n", " Max execution time: 300\n", " Input parameters:\n", " - iterations:\n", @@ -311,7 +311,7 @@ "id": "7090db0f", "metadata": {}, "source": [ - "To print the metadata of the program `runtime-simple`:" + "To print the metadata of the program `sample-program`:" ] }, { @@ -324,11 +324,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "runtime-simple:\n", - " Name: runtime-simple\n", - " Description: Simple runtime program used for testing.\n", + "sample-program:\n", + " Name: sample-program\n", + " Description: A sample runtime program.\n", " Version: 1\n", - " Creation date: 2021-05-05T23:30:21Z\n", + " Creation date: 2021-06-04T14:11:19Z\n", " Max execution time: 300\n", " Input parameters:\n", " - iterations:\n", @@ -350,7 +350,7 @@ } ], "source": [ - "program = provider.runtime.program('runtime-simple')\n", + "program = provider.runtime.program('sample-program')\n", "print(program)" ] }, @@ -359,7 +359,7 @@ "id": "dc4339b3", "metadata": {}, "source": [ - "As you can see from above, the program `runtime-simple` is a simple program that has only 1 input parameter `iterations`, which indicates how many iterations to run. For each iteration it generates and runs a random 5-qubit circuit and returns the counts as well as the iteration number as the interim results. When the program finishes, it returns the sentence `All done!`. This program can only run for 300 seconds (5 minutes), and requires a backend that has at least 5 qubits." + "As you can see from above, the program `sample-program` is a simple program that has only 1 input parameter `iterations`, which indicates how many iterations to run. For each iteration it generates and runs a random 5-qubit circuit and returns the counts as well as the iteration number as the interim results. When the program finishes, it returns the sentence `All done!`. This program can only run for 300 seconds (5 minutes), and requires a backend that has at least 5 qubits." ] }, { @@ -391,7 +391,7 @@ "source": [ "Before we run a quantum program, we may want to define a callback function that would process interim results, which are intermediate data provided by a program while its still running. \n", "\n", - "As we saw earlier, the metadata of `runtime-simple` says that its interim results are the iteration number and the counts of the randomly generated circuit. Here we define a simple callback function that just prints these interim results:" + "As we saw earlier, the metadata of `sample-program` says that its interim results are the iteration number and the counts of the randomly generated circuit. Here we define a simple callback function that just prints these interim results:" ] }, { @@ -410,7 +410,7 @@ "id": "e2a98178", "metadata": {}, "source": [ - "The following example runs the `runtime-simple` program with 3 iterations on `ibmq_montreal` and waits for its result. You can also use a different backend that supports Qiskit Runtime:" + "The following example runs the `sample-program` program with 3 iterations on `ibmq_montreal` and waits for its result. You can also use a different backend that supports Qiskit Runtime:" ] }, { @@ -437,7 +437,7 @@ " 'iterations': 3\n", "}\n", "options = {'backend_name': backend.name()}\n", - "job = provider.runtime.run(program_id=\"runtime-simple\",\n", + "job = provider.runtime.run(program_id=\"sample-program\",\n", " options=options,\n", " inputs=program_inputs,\n", " callback=interim_result_callback\n", @@ -489,7 +489,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Job c2ajo0m0lb0ph8orsprg is an execution instance of runtime program runtime-simple.\n", + "Job c2ajo0m0lb0ph8orsprg is an execution instance of runtime program sample-program.\n", "This job ran on backend ibmq_montreal and had input parameters {'iterations': 3}\n" ] } @@ -524,7 +524,7 @@ } ], "source": [ - "retrieved_jobs = provider.runtime.jobs(limit=2)\n", + "retrieved_jobs = provider.runtime.jobs(limit=1)\n", "for rjob in retrieved_jobs:\n", " print(rjob.job_id())" ] @@ -564,7 +564,7 @@ { "data": { "text/html": [ - "

Version Information

Qiskit SoftwareVersion
QiskitNone
Terra0.17.1
Aer0.8.2
IgnisNone
AquaNone
IBM Q Provider0.13.0
System information
Python3.9.1 (default, Feb 5 2021, 11:23:59) \n", + "

Version Information

Qiskit SoftwareVersion
QiskitNone
Terra0.17.1
Aer0.8.2
IgnisNone
AquaNone
IBM Q Provider0.13.1
System information
Python3.9.1 (default, Feb 5 2021, 11:23:59) \n", "[Clang 12.0.0 (clang-1200.0.32.28)]
OSDarwin
CPUs8
Memory (Gb)16.0
Fri May 07 09:22:18 2021 EDT
" ], "text/plain": [ diff --git a/02_uploading_program.ipynb b/02_uploading_program.ipynb index d17542bee..4e8a645df 100644 --- a/02_uploading_program.ipynb +++ b/02_uploading_program.ipynb @@ -96,7 +96,7 @@ "id": "2d6c91ec", "metadata": {}, "source": [ - "There are several runtime programs in the `programs` directory in this repository. `runtime_simple.py` is one of them. It is a simple runtime program that submits random circuits for user-specified iterations:" + "There are several runtime programs in the `programs` directory in this repository. `sample_program.py` is one of them. It is a sample runtime program that submits random circuits for user-specified iterations:" ] }, { @@ -106,7 +106,7 @@ "metadata": {}, "outputs": [], "source": [ - "\"\"\"A simple runtime program that submits random circuits for user-specified iterations.\"\"\"\n", + "\"\"\"A sample runtime program that submits random circuits for user-specified iterations.\"\"\"\n", "\n", "import random\n", "\n", @@ -377,7 +377,7 @@ "id": "d229d7cf", "metadata": {}, "source": [ - "The following example tests the `runtime-simple` program we saw earlier. It uses the `qasm_simulator` from Qiskit Aer as the test backend. It serializes and unserializes input data using `RuntimeEncoder` and `RuntimeDecoder`, which are the default en/decoders used by runtime." + "The following example tests the `sample-program` program we saw earlier. It uses the `qasm_simulator` from Qiskit Aer as the test backend. It serializes and unserializes input data using `RuntimeEncoder` and `RuntimeDecoder`, which are the default en/decoders used by runtime." ] }, { @@ -398,7 +398,10 @@ } ], "source": [ - "from qiskit_runtime.runtime_simple import runtime_simple\n", + "import sys\n", + "sys.path.insert(0, '..') # Add qiskit_runtime directory to the path\n", + "\n", + "from qiskit_runtime.sample_program import sample_program\n", "from qiskit import Aer\n", "from qiskit.providers.ibmq.runtime.utils import RuntimeEncoder, RuntimeDecoder\n", "from qiskit.providers.ibmq.runtime import UserMessenger\n", @@ -410,7 +413,7 @@ "serialized_inputs = json.dumps(inputs, cls=RuntimeEncoder)\n", "unserialized_inputs = json.loads(serialized_inputs, cls=RuntimeDecoder)\n", "\n", - "runtime_simple.main(backend, user_messenger, **unserialized_inputs)" + "sample_program.main(backend, user_messenger, **unserialized_inputs)" ] }, { @@ -445,7 +448,7 @@ "id": "39e87075", "metadata": {}, "source": [ - "Below shows the metadata JSON file of the `runtime-simple` program as an example:" + "Below shows the metadata JSON file of the `sample-program` program as an example:" ] }, { @@ -459,13 +462,13 @@ "output_type": "stream", "text": [ "{\n", - " \"name\": \"runtime-simple\",\n", - " \"description\": \"Simple runtime program used for testing.\",\n", + " \"name\": \"sample-program\",\n", + " \"description\": \"A sample runtime program.\",\n", " \"max_execution_time\": 300,\n", - " \"version\": 1.0,\n", + " \"version\": \"1.0\",\n", " \"backend_requirements\": {\"min_num_qubits\": 5},\n", " \"parameters\": [\n", - " {\"name\": \"iterations\", \"description\": \"Number of iterations to run. Each iteration generates a runs a random circuit.\", \"type\": \"int\", \"required\": true}\n", + " {\"name\": \"iterations\", \"description\": \"Number of iterations to run. Each iteration generates and runs a random circuit.\", \"type\": \"int\", \"required\": true}\n", " ],\n", " \"return_values\": [\n", " {\"name\": \"-\", \"description\": \"A string that says 'All done!'.\", \"type\": \"string\"}\n", @@ -482,9 +485,9 @@ "source": [ "import os\n", "\n", - "runtime_simple_json = os.path.join(os.getcwd(), \"../qiskit_runtime/runtime_simple/runtime_simple.json\")\n", + "sample_program_json = os.path.join(os.getcwd(), \"../qiskit_runtime/sample_program/sample_program.json\")\n", "\n", - "with open(runtime_simple_json, 'r') as file:\n", + "with open(sample_program_json, 'r') as file:\n", " data = file.read()\n", "\n", "print(data)" @@ -511,7 +514,7 @@ "id": "dfea7bc0", "metadata": {}, "source": [ - "You can use the [`IBMRuntimeService.upload_program()`](https://qiskit.org/documentation/stubs/qiskit.providers.ibmq.runtime.IBMRuntimeService.html#qiskit.providers.ibmq.runtime.IBMRuntimeService.upload_program) method to upload your program. In the example below, the program data lives in the file `runtime-simple.py`, and its metadata, as described above, is in `runtime-simple.json`. " + "You can use the [`IBMRuntimeService.upload_program()`](https://qiskit.org/documentation/stubs/qiskit.providers.ibmq.runtime.IBMRuntimeService.html#qiskit.providers.ibmq.runtime.IBMRuntimeService.upload_program) method to upload your program. In the example below, the program data lives in the file `sample_program.py`, and its metadata, as described above, is in `sample_program.json`. " ] }, { @@ -519,7 +522,15 @@ "execution_count": 11, "id": "6f11e0e0", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sample-program\n" + ] + } + ], "source": [ "import os\n", "from qiskit import IBMQ\n", @@ -527,12 +538,12 @@ "IBMQ.load_account()\n", "provider = IBMQ.get_provider(project='qiskit-runtime') # Substitute with your provider.\n", "\n", - "runtime_simple_data = os.path.join(os.getcwd(), \"../qiskit_runtime/runtime_simple/runtime_simple.py\")\n", - "runtime_simple_json = os.path.join(os.getcwd(), \"../qiskit_runtime/runtime_simple/runtime_simple.json\")\n", + "sample_program_data = os.path.join(os.getcwd(), \"../qiskit_runtime/sample_program/sample_program.py\")\n", + "sample_program_json = os.path.join(os.getcwd(), \"../qiskit_runtime/sample_program/sample_program.json\")\n", " \n", "program_id = provider.runtime.upload_program(\n", - " data=runtime_simple_data,\n", - " metadata=runtime_simple_json\n", + " data=sample_program_data,\n", + " metadata=sample_program_json\n", ")\n", "print(program_id)" ] diff --git a/API_direct.ipynb b/API_direct.ipynb index 98a271e44..82bab0517 100644 --- a/API_direct.ipynb +++ b/API_direct.ipynb @@ -97,7 +97,7 @@ "Qiskit Runtime Programs:\n", "- circuit-runner: A runtime program that takes one or more circuits, compiles them, executes them, and optionally applies measurement error mitigation. \n", "- quantum-kernel-alignment: Quantum kernel alignment algorithm that learns, on a given dataset, a quantum kernel maximizing the SVM classification margin. \n", - "- runtime-simple: Simple runtime program used for testing. \n", + "- sample-program: A sample runtime program. \n", "- vqe: Variational Quantum Eigensolver (VQE) to find the minimal eigenvalue of a Hamiltonian. \n" ] } @@ -185,7 +185,7 @@ } ], "source": [ - "Runtime_program = \"runtime-simple\"\n", + "Runtime_program = \"sample-program\"\n", "\n", "program_input = {\"iterations\":2} \n", "\n",