Quantum Computer

pyquil.get_qc(name, *, as_qvm=None, noisy=None, connection=None)[source]

Get a quantum computer.

A quantum computer is an object of type QuantumComputer and can be backed either by a QVM simulator (“Quantum/Quil Virtual Machine”) or a physical Rigetti QPU (“Quantum Processing Unit”) made of superconducting qubits.

You can choose the quantum computer to target through a combination of its name and optional flags. There are multiple ways to get the same quantum computer. The following are equivalent:

>>> qc = get_qc("Aspen-1-16Q-A-noisy-qvm")
>>> qc = get_qc("Aspen-1-16Q-A", as_qvm=True, noisy=True)

and will construct a simulator of an Aspen-1 lattice with a noise model based on device characteristics. We also provide a means for constructing generic quantum simulators that are not related to a given piece of Rigetti hardware:

>>> qc = get_qc("9q-square-qvm")
>>> qc = get_qc("9q-square", as_qvm=True)

Finally, you can get request a QVM with “no” topology of a given number of qubits (technically, it’s a fully connected graph among the given number of qubits) with:

>>> qc = get_qc("5q-qvm") # or "6q-qvm", or "34q-qvm", ...

These less-realistic, fully-connected QVMs will also be more lenient on what types of programs they will run. Specifically, you do not need to do any compilation. For the other, realistic QVMs you must use qc.compile() or qc.compiler.native_quil_to_executable() prior to qc.run().

Redundant flags are acceptable, but conflicting flags will raise an exception:

>>> qc = get_qc("9q-square-qvm") # qc is fully specified by its name
>>> qc = get_qc("9q-square-qvm", as_qvm=True) # redundant, but ok
>>> qc = get_qc("9q-square-qvm", as_qvm=False) # Error!

Use list_quantum_computers() to retrieve a list of known qc names.

This method is provided as a convenience to quickly construct and use QVM’s and QPU’s. Power users may wish to have more control over the specification of a quantum computer (e.g. custom noise models, bespoke topologies, etc.). This is possible by constructing a QuantumComputer object by hand. Please refer to the documentation on QuantumComputer for more information.

Parameters:
  • name (str) – The name of the desired quantum computer. This should correspond to a name returned by list_quantum_computers(). Names ending in “-qvm” will return a QVM. Names ending in “-noisy-qvm” will return a QVM with a noise model. Otherwise, we will return a QPU with the given name.
  • as_qvm (Optional[bool]) – An optional flag to force construction of a QVM (instead of a QPU). If specified and set to True, a QVM-backed quantum computer will be returned regardless of the name’s suffix
  • noisy (Optional[bool]) – An optional flag to force inclusion of a noise model. If specified and set to True, a quantum computer with a noise model will be returned regardless of the name’s suffix. The noise model for QVMs based on a real QPU is an empirically parameterized model based on real device noise characteristics. The generic QVM noise model is simple T1 and T2 noise plus readout error. See decoherence_noise_with_asymmetric_ro().
  • connection (Optional[ForestConnection]) – An optional ForestConnection object. If not specified, the default values for URL endpoints, ping time, and status time will be used. Your user id and API key will be read from ~/.pyquil_config. If you deign to change any of these parameters, pass your own ForestConnection object.
Return type:

QuantumComputer

Returns:

A pre-configured QuantumComputer

pyquil.list_quantum_computers(connection=None, qpus=True, qvms=True)[source]

List the names of available quantum computers

Parameters:
  • connection (Optional[ForestConnection]) – An optional :py:class:ForestConnection` object. If not specified, the default values for URL endpoints will be used, and your API key will be read from ~/.pyquil_config. If you deign to change any of these parameters, pass your own ForestConnection object.
  • qpus (bool) – Whether to include QPU’s in the list.
  • qvms (bool) – Whether to include QVM’s in the list.
Return type:

List[str]

class pyquil.api.QuantumComputer(*, name, qam, device, compiler, symmetrize_readout=False)[source]

A quantum computer for running quantum programs.

A quantum computer has various characteristics like supported gates, qubits, qubit topologies, gate fidelities, and more. A quantum computer also has the ability to run quantum programs.

A quantum computer can be a real Rigetti QPU that uses superconducting transmon qubits to run quantum programs, or it can be an emulator like the Rigetti QVM with noise models and mimicked topologies.

Parameters:
  • name (str) – A string identifying this particular quantum computer.
  • qam (QAM) – A quantum abstract machine which handles executing quantum programs. This dispatches to a QVM or QPU.
  • device (AbstractDevice) – A collection of connected qubits and associated specs and topology.
  • symmetrize_readout (bool) – Whether to apply readout error symmetrization. See run_symmetrized_readout() for a complete description.

Methods

run(executable[, memory_map]) Run a quil executable.
run_and_measure(program, trials) Run the provided state preparation program and measure all qubits.
run_symmetrized_readout(program, trials) Run a quil program in such a way that the readout error is made collectively symmetric
qubits() Return a sorted list of this QuantumComputer’s device’s qubits
qubit_topology() Return a NetworkX graph representation of this QuantumComputer’s device’s qubit connectivity.
get_isa([oneq_type, twoq_type]) Return a target ISA for this QuantumComputer’s device.
compile(program[, to_native_gates, optimize]) A high-level interface to program compilation.