pyquil.api.QVM

class pyquil.api.QVM(connection, noise_model=None, gate_noise=None, measurement_noise=None, random_seed=None, requires_executable=False)[source]

A virtual machine that classically emulates the execution of Quil programs.

Parameters:
  • connection (ForestConnection) – A connection to the Forest web API.
  • noise_model – A noise model that describes noise to apply when emulating a program’s execution.
  • gate_noise – A list of three numbers [Px, Py, Pz] indicating the probability of an X, Y, or Z gate getting applied to each qubit after a gate application or reset. The default value of None indicates no noise.
  • measurement_noise – A list of three numbers [Px, Py, Pz] indicating the probability of an X, Y, or Z gate getting applied before a measurement. The default value of None indicates no noise.
  • random_seed – A seed for the QVM’s random number generators. Either None (for an automatically generated seed) or a non-negative integer.
  • requires_executable – Whether this QVM will refuse to run a Program and only accept the result of compiler.native_quil_to_executable(). Setting this to True better emulates the behavior of a QPU.
__init__(connection, noise_model=None, gate_noise=None, measurement_noise=None, random_seed=None, requires_executable=False)[source]

A virtual machine that classically emulates the execution of Quil programs.

Parameters:
  • connection (ForestConnection) – A connection to the Forest web API.
  • noise_model – A noise model that describes noise to apply when emulating a program’s execution.
  • gate_noise – A list of three numbers [Px, Py, Pz] indicating the probability of an X, Y, or Z gate getting applied to each qubit after a gate application or reset. The default value of None indicates no noise.
  • measurement_noise – A list of three numbers [Px, Py, Pz] indicating the probability of an X, Y, or Z gate getting applied before a measurement. The default value of None indicates no noise.
  • random_seed – A seed for the QVM’s random number generators. Either None (for an automatically generated seed) or a non-negative integer.
  • requires_executable – Whether this QVM will refuse to run a Program and only accept the result of compiler.native_quil_to_executable(). Setting this to True better emulates the behavior of a QPU.
Return type:

None

Methods

__init__(connection[, noise_model, …]) A virtual machine that classically emulates the execution of Quil programs.
augment_program_with_memory_values(quil_program)
get_version_info() Return version information for the QVM.
load(executable) Initialize a QAM and load a program to be executed with a call to run().
read_from_memory_region(*, region_name) Reads from a memory region named region_name on the QAM.
read_memory(*, region_name) Reads from a memory region named region_name on the QAM.
reset() Reset the Quantum Abstract Machine to its initial state, which is particularly useful when it has gotten into an unwanted state.
run() Run a Quil program on the QVM multiple times and return the values stored in the classical registers designated by the classical_addresses parameter.
wait() Blocks until the QPU enters the halted state.
write_memory(*, region_name[, offset, value]) Writes a value into a memory region on the QAM at a specified offset.