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

Add support for BackendV2 #102

Merged
merged 27 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
13745ad
Construct target and qubit properties
rathishcholarajan Jan 19, 2022
534ee94
BackendV2 first draft
rathishcholarajan Jan 19, 2022
2891d8b
Add integration tests
rathishcholarajan Jan 19, 2022
9c170d4
Test if an attribute (ex: simulator) on configuration is available on…
rathishcholarajan Jan 19, 2022
45fa1be
Check if AttributeError is raised when an invalid backend attribute i…
rathishcholarajan Jan 19, 2022
dd15502
Fix lint
rathishcholarajan Jan 19, 2022
3a9a3c9
Remove IBMSimulator class
rathishcholarajan Jan 21, 2022
23a1562
Add comments to explain more
rathishcholarajan Jan 24, 2022
507032c
Fix dt, add dtm property
rathishcholarajan Jan 27, 2022
230133d
Add meas_map property
rathishcholarajan Jan 27, 2022
8a4b06e
Add drive_channel, control_channel, acquire_channel and measure_chann…
rathishcholarajan Jan 27, 2022
e8f98bb
Fix tutorial
rathishcholarajan Jan 31, 2022
4732bef
Add Backend attributes to class doc string
rathishcholarajan Jan 31, 2022
3961023
Update backends tutorial
rathishcholarajan Feb 1, 2022
8b1ac7b
Fix accidental commit of personal tokens
rathishcholarajan Feb 1, 2022
599ee07
Set terra version to 0.19.2 which is the min required for BackendV2
rathishcholarajan Feb 2, 2022
7820d82
Set validators on max_shots, rep_delay_range, qubit_lo_range, and mea…
rathishcholarajan Feb 3, 2022
115cfda
Fix style
rathishcholarajan Feb 3, 2022
8b6c72a
Check if property exists in configuration before validating
rathishcholarajan Feb 3, 2022
5bd63e1
Use hasattr to check if attribute exists in configuration
rathishcholarajan Feb 4, 2022
193d19c
qubit_lo_range and meas_lo_range are per qubit and is not possible to…
rathishcholarajan Feb 4, 2022
9ff7da4
Fix acquire_alignment spelling
rathishcholarajan Feb 14, 2022
a8802fd
Use BackendConfiguration, BackendProperties and PulseDefaults classes…
rathishcholarajan Feb 16, 2022
2fd7d28
Initialize target with num_qubits from configuration
rathishcholarajan Feb 18, 2022
26e6e63
Fix retired backend
rathishcholarajan Feb 18, 2022
81d38c5
Merge branch 'main' into 73-backendv2
rathishcholarajan Feb 18, 2022
f57fe67
Fix tests
rathishcholarajan Feb 19, 2022
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
298 changes: 280 additions & 18 deletions docs/tutorials/03_backends.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
{
"data": {
"text/plain": [
"[<IBMSimulator('ibmq_qasm_simulator')>,\n",
" <IBMSimulator('simulator_stabilizer')>,\n",
" <IBMSimulator('simulator_mps')>,\n",
" <IBMSimulator('simulator_extended_stabilizer')>,\n",
" <IBMSimulator('simulator_statevector')>]"
"[<IBMBackend('ibmq_qasm_simulator')>,\n",
" <IBMBackend('simulator_stabilizer')>,\n",
" <IBMBackend('simulator_mps')>,\n",
" <IBMBackend('simulator_extended_stabilizer')>,\n",
" <IBMBackend('simulator_statevector')>]"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -112,7 +112,7 @@
{
"data": {
"text/plain": [
"<IBMSimulator('ibmq_qasm_simulator')>"
"<IBMBackend('ibmq_qasm_simulator')>"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -190,7 +190,7 @@
{
"data": {
"text/plain": [
"<IBMSimulator('ibmq_qasm_simulator')>"
"<IBMBackend('ibmq_qasm_simulator')>"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -250,14 +250,18 @@
{
"data": {
"text/plain": [
"[<IBMSimulator('ibmq_qasm_simulator')>,\n",
"[<IBMBackend('ibmq_qasm_simulator')>,\n",
" <IBMBackend('ibmq_santiago')>,\n",
" <IBMBackend('ibmq_bogota')>,\n",
" <IBMBackend('ibmq_casablanca')>,\n",
" <IBMBackend('ibmq_lima')>,\n",
" <IBMBackend('ibmq_belem')>,\n",
" <IBMBackend('ibmq_quito')>,\n",
" <IBMSimulator('simulator_statevector')>,\n",
" <IBMSimulator('simulator_mps')>,\n",
" <IBMSimulator('simulator_extended_stabilizer')>,\n",
" <IBMSimulator('simulator_stabilizer')>,\n",
" <IBMBackend('ibm_lagos')>]"
" <IBMBackend('simulator_statevector')>,\n",
" <IBMBackend('simulator_mps')>,\n",
" <IBMBackend('simulator_extended_stabilizer')>,\n",
" <IBMBackend('simulator_stabilizer')>,\n",
" <IBMBackend('ibmq_manila')>]"
]
},
"execution_count": 7,
Expand All @@ -266,7 +270,7 @@
}
],
"source": [
"legacy_service.backends(**program.backend_requirements)"
"legacy_service.backends(min_num_qubits=5)"
]
},
{
Expand All @@ -282,13 +286,271 @@
"id": "345f6414",
"metadata": {},
"source": [
"As mentioned earlier, the attributes of a backend provides information about the backend. **TODO** - finish when BackendV2 is done"
"As mentioned earlier, the attributes of [IBMBackend](https://qiskit.org/documentation/partners/qiskit_ibm_runtime/stubs/qiskit_ibm_runtime.IBMBackend.html#qiskit_ibm_runtime.IBMBackend) class provides information about the backend."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4f60899c",
"execution_count": 8,
"id": "1a0b6659",
"metadata": {},
"outputs": [],
"source": [
"backend = service.backend(\"ibmq_qasm_simulator\")"
]
},
{
"cell_type": "markdown",
"id": "f1ae6dff",
"metadata": {},
"source": [
"Name of the backend."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "2c7e254d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'ibmq_qasm_simulator'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.name"
]
},
{
"cell_type": "markdown",
"id": "db124d13",
"metadata": {},
"source": [
"Version of the backend."
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "969b2a6e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0.1.547'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.backend_version"
]
},
{
"cell_type": "markdown",
"id": "d80ceba6",
"metadata": {},
"source": [
"Check if the backend is a simulator or real system."
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "2f2676d9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.simulator"
]
},
{
"cell_type": "markdown",
"id": "79cd9dd7",
"metadata": {},
"source": [
"Number of qubits the backend has."
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "5983257b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"32"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.num_qubits"
]
},
{
"cell_type": "markdown",
"id": "02ea81a6",
"metadata": {},
"source": [
"Maximum number of circuits per job."
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "faff03d7",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"300"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.max_circuits"
]
},
{
"cell_type": "markdown",
"id": "65c3f744",
"metadata": {},
"source": [
"A list of instructions the backend supports."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "d7c117ea",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"[(Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (0,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (1,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (2,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (3,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (4,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (5,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (6,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (7,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (8,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (9,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (10,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (11,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (12,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (13,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (14,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (15,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (16,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (17,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (18,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (19,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (20,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (21,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (22,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (23,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (24,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (25,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (26,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (27,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (28,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (29,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (30,)),\n",
" (Instruction(name='measure', num_qubits=1, num_clbits=1, params=[]), (31,))]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.instructions"
]
},
{
"cell_type": "markdown",
"id": "c91b3de3",
"metadata": {},
"source": [
"Coupling map of the backend."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "9b219fae",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"<qiskit.transpiler.coupling.CouplingMap at 0x7f7e482abf40>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"backend.coupling_map"
]
},
{
"cell_type": "markdown",
"id": "06590dbc",
"metadata": {},
"source": [
"For a complete list of backend attributes refer to the [IBMBackend](https://qiskit.org/documentation/partners/qiskit_ibm_runtime/stubs/qiskit_ibm_runtime.IBMBackend.html#qiskit_ibm_runtime.IBMBackend) class documentation."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "f6948a08",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -327,7 +589,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/qka.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
" \"initial_layout\": initial_layout,\n",
"}\n",
"\n",
"options = {\"backend_name\": backend.name()}\n",
"options = {\"backend_name\": backend.name}\n",
"\n",
"job = service.run(\n",
" program_id=\"quantum-kernel-alignment\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
" pairs if return_stddev=True.\n",
" \"\"\"\n",
" if not isinstance(backend, str):\n",
" backend = backend.name()\n",
" backend = backend.name\n",
" options = {\"backend_name\": backend}\n",
"\n",
" if isinstance(circuits, list) and len(circuits) != 1:\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
"# Use the local Aer simulator\n",
"from qiskit import Aer\n",
"\n",
"backend = Aer.get_backend(\"qasm_simulator\")"
"backend = Aer.backend(\"qasm_simulator\")"
]
},
{
Expand Down Expand Up @@ -1121,7 +1121,7 @@
" Returns:\n",
" OptimizeResult: The result in SciPy optimization format.\n",
" \"\"\"\n",
" options = {\"backend_name\": backend.name()}\n",
" options = {\"backend_name\": backend.name}\n",
"\n",
" inputs = {}\n",
"\n",
Expand Down
Loading