-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add circuit-runner, sampler and custom VQE programs from Qiskit-Runti…
…me (#157) * Small change. * First commit * Working circuit runner. * Sampler * Sampler * VQE is working. * Headers. * Update for batches. * Update docstrigs. * CodeFactor. * Add tests for runtime. * Tests. * Test. * Test circuit runner. * Test Sampler. * Correct generate_samples * Add entry points. * More shots. * Add token arg. * Change import * Change Sampler sample. * Circuit runner kwargs test. * Shots kwargs * Change import. * Add kwargs Sampler test. * Import. * Impport again. * Import change * Add test tracker. * Update track tests. * Update tracker runtime. * Update tracker. * Update. * Codfactor changes. * Update. * Update codefactor * More codefactor. * Add callback * Update * Move vqe * Update. * Add test VQE. * Update. * delete * Update VQE test. * Add shots. * Update test * Update delete * Unused import. * More iteration. * m * Change tol. * More VQE tests. * Black * Update. * Update. * Update * Update pennylane_qiskit/vqe/__init__.py Co-authored-by: antalszava <[email protected]> * Update from review. * Update tests. * Typo. * Update from tests. * Runtime updated. * Runtime updated. * Update vqe * Update * Update from Antal review. * Update * Black. * More test. * Update parameters * Codefactor update. * Update. * Update. * Change order jac. * Typo. * Params. * Update tests. * ValueError. * print * Update. * Tol. * Update review. * Add doc. * Unused variable. * Update tests. * Update params. * Update review. * Readd mthree * Typo. * Path. * Black * Change path. * Update runtime_programs/vqe_runtime_program.py * Update doc/devices/runtime.rst Co-authored-by: antalszava <[email protected]> * Update review. * coverarc * coverarc omit + skip IBMQ and Runtime tests * Changelog Co-authored-by: antalszava <[email protected]>
- Loading branch information
1 parent
214313c
commit ef7dfa5
Showing
16 changed files
with
2,057 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Qiskit Runtime Programs | ||
======================= | ||
|
||
PennyLane-Qiskit supports running PennyLane on IBM Q hardware via the Qiskit runtime programs ``circuit-runner`` | ||
and ``sampler``. You can choose between those two runtime programs and also have the possibility to choose the | ||
backend on which the circuits will be run. Those two devices inherit directly from the ``IBMQ`` device and work the | ||
the same way, you can refer to the corresponding documentation for details about token and providers | ||
`IBMQ documentation for PennyLane <https://pennylaneqiskit.readthedocs.io/en/latest/devices/ibmq.html>`_. | ||
|
||
You can use the ``circuit_runner`` and ``sampler`` devices by using their short names, for example: | ||
|
||
.. code-block:: python | ||
dev = qml.device('qiskit.ibmq.circuit_runner', wires=2, backend='ibmq_qasm_simulator', shots=8000, **kwargs) | ||
.. code-block:: python | ||
dev = qml.device('qiskit.ibmq.sampler', wires=2, backend='ibmq_qasm_simulator', shots=8000, **kwargs) | ||
Custom Runtime Programs | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Not all Qiskit runtime programs correspond to complete devices, some solve specific problems (VQE, QAOA, etc...). | ||
We created a custom Qiskit runtime program for solving VQE problems in PennyLane ``runtime_programs\vqe_runtime_program.py``. | ||
In order to use this program you need to upload on IBMQ (only once), get the program ID and use the VQE runner. | ||
|
||
.. code-block:: python | ||
from pennylane_qiskit import upload_vqe_runner, vqe_runner | ||
IBMQ.enable_account(token) | ||
program_id = upload_vqe_runner(hub="ibm-q", group="open", project="main") | ||
def vqe_circuit(params): | ||
qml.RX(params[0], wires=0) | ||
qml.RY(params[1], wires=0) | ||
coeffs = [1, 1] | ||
obs = [qml.PauliX(0), qml.PauliZ(0)] | ||
hamiltonian = qml.Hamiltonian(coeffs, obs) | ||
job = vqe_runner( | ||
program_id=program_id, | ||
backend="ibmq_qasm_simulator", | ||
hamiltonian=hamiltonian, | ||
ansatz=vqe_circuit, | ||
x0=[3.97507603, 3.00854038], | ||
shots=shots, | ||
optimizer="SPSA", | ||
optimizer_config={"maxiter": 40}, | ||
kwargs={"hub": "ibm-q", "group": "open", "project": "main"}, | ||
) | ||
More details on Qiskit runtime programs in the `IBMQ runtime documentation <https://qiskit.org/documentation/apidoc/ibmq_runtime.html>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.