Skip to content

Commit

Permalink
Add a backend for IonQ. (#391)
Browse files Browse the repository at this point in the history
* Add a backend for IonQ.

* Update projectq/setups/ionq.py

Thanks for the correction!

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>

* Update docstring to match return type.

* Fix copyright header years, imports, docstring.

* Fix comment

* Fix measurement mappings and result parsing.

* Fix some bad logic with result probability mappings.
* Fix some erroneous test cases.
* Fix example code.
* Ensure qubits are "deallocated" and reset after job submit.
* Drop dependency on mappers in favor of API response mappings.
* Add better error handling for API/http errors.
* Fix tests.

* Update example notebook.

* Fix qubit mapping.

* Use a dedicated qubit mapper instead of bashing self.main_engine.
* Update backend, add tests, to reflect new mapper.

* Use response.registers instead of echoing metadata.

* Fix get_probability after register updates

* Fixes after rebase, use metadata to remamp qubit IDs on response

* Lint/CI/Format/Changelog fixes

* Always make sure to give a result, even if it's not likely

* Missed formatter issues

Co-authored-by: Nguyen Damien <ngn.damien@gmail.com>
  • Loading branch information
amilstead and Takishima committed Jun 14, 2021
1 parent 0cf7322 commit b078f67
Show file tree
Hide file tree
Showing 17 changed files with 2,939 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added ``.editorconfig` file
- Added ``pyproject.toml`` and ``setup.cfg``
- Added CHANGELOG.md
- Added backend for IonQ.

### Deprecated

Expand Down
33 changes: 32 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ targeting various types of hardware, a high-performance quantum computer
simulator with emulation capabilities, and various compiler plug-ins.
This allows users to

- run quantum programs on the IBM Quantum Experience chip, AQT devices or AWS Braket service provided devices
- run quantum programs on the IBM Quantum Experience chip, AQT devices, AWS Braket, or IonQ service provided devices
- simulate quantum programs on classical computers
- emulate quantum programs at a higher level of abstraction (e.g.,
mimicking the action of large oracles instead of compiling them to
Expand Down Expand Up @@ -172,6 +172,37 @@ IonQ from IonQ and the state vector simulator SV1:
python3 -m pip install -ve .[braket]
**Running a quantum program on IonQ devices**

To run a program on the IonQ trapped ion hardware, use the `IonQBackend` and its corresponding setup.

Currently available devices are:

* `ionq_simulator`: A 29-qubit simulator.
* `ionq_qpu`: A 11-qubit trapped ion system.

.. code-block:: python
import projectq.setups.ionq
from projectq import MainEngine
from projectq.backends import IonQBackend
token = 'MY_TOKEN'
device = 'ionq_qpu'
backend = IonQBackend(
token=token,
use_hardware=True,
num_runs=1024,
verbose=False,
device=device,
)
compiler_engines = projectq.setups.ionq.get_engine_list(
token=token,
device=device,
)
eng = MainEngine(backend, engine_list=compiler_engines)
**Classically simulate a quantum program**

ProjectQ has a high-performance simulator which allows simulating up to about 30 qubits on a regular laptop. See the `simulator tutorial <https://github.com/ProjectQ-Framework/ProjectQ/blob/feature/update-readme/examples/simulator_tutorial.ipynb>`__ for more information. Using the emulation features of our simulator (fast classical shortcuts), one can easily emulate Shor's algorithm for problem sizes for which a quantum computer would require above 50 qubits, see our `example codes <http://projectq.readthedocs.io/en/latest/examples.html#shor-s-algorithm-for-factoring>`__.
Expand Down

0 comments on commit b078f67

Please sign in to comment.