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 useqc.compile()
orqc.compiler.native_quil_to_executable()
prior toqc.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 onQuantumComputer
for more information.Parameters: - name (
str
) – The name of the desired quantum computer. This should correspond to a name returned bylist_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 toTrue
, 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 toTrue
, 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. Seedecoherence_noise_with_asymmetric_ro()
. - connection (
Optional
[ForestConnection
]) – An optionalForestConnection
object. If not specified, the default values for URL endpoints will be used. If you deign to change any of these parameters, pass your ownForestConnection
object.
Return type: QuantumComputer
Returns: A pre-configured QuantumComputer
- name (
-
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 ownForestConnection
object. - qpus (
bool
) – Whether to include QPU’s in the list. - qvms (
bool
) – Whether to include QVM’s in the list.
Return type: - connection (
-
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. Seerun_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. - name (