{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Backend Configuration\n", "\n", "A Backend is a loose term for a provider of a quantum computer or simulator.\n", "\n", "Currently in Nexus these are specified by a `BackendConfig`, of which we offer the following types:\n", "\n", "- `AerConfig`: targets Qiskit Aer simulator\n", "\n", "- `AerStateConfig`: targets Qiskit Aer statevector simulator\n", "\n", "- `AerUnitaryConfig`: targets Qiskit Aer unitary simulator\n", "\n", "- `BraketConfig`: targets devices available through Amazon Braket\n", "\n", "- `QuantinuumConfig`: targets Quantinuum devices and emulators\n", "\n", "- `IBMQConfig`: targets devices available through IBMQ\n", "\n", "- `IBMQEmulatorConfig`: targets emulated devices available through IBMQ (uses a noise model for simulation)\n", "\n", "- `ProjectQConfig`: targets the ProjectQ simulator\n", "\n", "- `QulacsConfig`: targets the Qulacs simulator" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import qnexus as qnx\n", "\n", "from datetime import datetime\n", "from pytket import Circuit" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a configuration to target the H1-1LE noiseless simulator\n", "my_quantinuum_config = qnx.QuantinuumConfig(\n", " device_name=\"H1-1LE\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a configuration to target the IBMQ Kyiv device through the open plan\n", "my_ibmq_config = qnx.IBMQConfig(\n", " backend_name=\"ibm_kyiv\",\n", " hub=\"ibm-q\",\n", " group=\"open\",\n", " project=\"main\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "BackendConfigs are a required parameter when running Jobs in Nexus." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_project_ref = qnx.projects.get_or_create(name=\"My Nexus Project\")\n", "\n", "my_circuit_ref = qnx.circuits.upload(\n", " name=f\"My Circuit\",\n", " circuit = Circuit(2).H(0).CX(0,1).measure_all(),\n", " project = my_project_ref,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run a CompileJob targeting an IBMQ device\n", "\n", "compile_job_IBMQ = qnx.start_compile_job(\n", " name=f\"My IBMQ compilation job from {datetime.now()}\",\n", " circuits=[my_circuit_ref],\n", " backend_config=my_ibmq_config,\n", " project=my_project_ref,\n", ")\n", "\n", "compile_job_IBMQ.df()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run an ExecuteJob targeting the H1-1 Syntax Checker device\n", "\n", "execute_job_H1_1LE = qnx.start_execute_job(\n", " name=f\"My H1-1LE execution job from {datetime.now()}\",\n", " circuits=[my_circuit_ref],\n", " n_shots=[1000],\n", " backend_config=my_quantinuum_config,\n", " project=my_project_ref,\n", ")\n", "\n", "execute_job_H1_1LE.df()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Information about a particular Backend\n", "\n", "You can find out certain features of a backend as specified by a `BackendConfig`, these are boolean values for the following:\n", "\n", "- `supports_shots`\n", "- `supports_counts`\n", "- `supports_state`\n", "- `supports_unitary`\n", "- `supports_density_matrix`\n", "- `supports_expectation`\n", "- `expectation_allows_nonhermitian`\n", "- `supports_contextual_optimisation`\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Check if the H1-1LE simulator support shots\n", "qnx.devices.supports_shots(\n", " qnx.QuantinuumConfig(device_name=\"H1-1LE\")\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "qnexus-Rou6F43i-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.8" } }, "nbformat": 4, "nbformat_minor": 2 }