The qvm Reference Manual

This is the qvm Reference Manual, version 1.17.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Fri Sep 15 06:26:55 2023 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 qvm

An implementation of the Quantum Abstract Machine.

Author

Robert Smith <>

License

Apache License 2.0 (See LICENSE.txt)

Version

1.17.2

Defsystem Dependency

cffi-grovel (system).

Dependencies
  • alexandria (system).
  • abstract-classes (system).
  • ieee-floats (system).
  • lparallel (system).
  • magicl (system)., at least version "0.7.0"
  • trivial-garbage (system).
  • global-vars (system).
  • cffi (system).
  • static-vectors (system)., at least version "1.8.3"
  • trivial-garbage (system).
  • cl-quil (system)., at least version "1.17.0"
  • mt19937 (system).
  • sb-introspect (system).
  • trivial-features (system).
Source

qvm.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 qvm/qvm.asd

Source

qvm.asd.

Parent Component

qvm (system).

ASDF Systems

qvm.


3.1.2 qvm/package.lisp

Source

qvm.asd.

Parent Component

qvm (system).

Packages

qvm.


3.1.3 qvm/grovel-system-constants.lisp

If Feature

:unix

Dependency

package.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).


3.1.4 qvm/grovel-shared-memory.lisp

If Feature

:unix

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.5 qvm/config.lisp

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.6 qvm/impl/allegro.lisp

If Feature

:allegro

Dependency

config.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).


3.1.7 qvm/impl/clozure.lisp

If Feature

:clozure

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.8 qvm/impl/sbcl.lisp

If Feature

:sbcl

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).

Internals

3.1.9 qvm/impl/sbcl-intrinsics.lisp

If Feature

(:and :sbcl :qvm-intrinsics)

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.10 qvm/impl/sbcl-avx-vops.lisp

If Feature

(:and :sbcl :qvm-intrinsics :avx2)

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.11 qvm/impl/sbcl-x86-vops.lisp

If Feature

(:and :sbcl :qvm-intrinsics)

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.12 qvm/impl/linear-algebra-intrinsics.lisp

If Feature

:qvm-intrinsics

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.13 qvm/impl/prefetch-intrinsics.lisp

If Feature

:qvm-intrinsics

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.14 qvm/impl/lispworks.lisp

If Feature

:lispworks

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).


3.1.15 qvm/utilities.lisp

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.16 qvm/floats.lisp

Dependency

utilities.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.17 qvm/allocator.lisp

Dependency

floats.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.18 qvm/shm.lisp

If Feature

:unix

Dependency

allocator.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface

allocate-vector (method).

Internals

3.1.19 qvm/linear-algebra.lisp

Dependencies
Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.20 qvm/qam.lisp

Dependency

linear-algebra.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.21 qvm/classical-memory.lisp

Dependency

qam.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.22 qvm/classical-memory-mixin.lisp

Dependency

classical-memory.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.23 qvm/serial-kernels.lisp

Dependency

classical-memory-mixin.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Internals

3.1.24 qvm/wavefunction.lisp

Dependency

serial-kernels.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.25 qvm/subsystem.lisp

Dependency

wavefunction.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface

print-object (method).

Internals

3.1.26 qvm/state-representation.lisp

Dependency

subsystem.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.27 qvm/qvm.lisp

Dependency

state-representation.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.28 qvm/mixed-state-qvm.lisp

Dependency

qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface

initialize-instance (method).

Internals

3.1.29 qvm/compile-gate.lisp

Dependency

mixed-state-qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.30 qvm/apply-gate.lisp

Dependency

compile-gate.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface

apply-gate-to-state (generic function).

Internals

3.1.31 qvm/measurement.lisp

Dependency

apply-gate.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.32 qvm/transition.lisp

Dependency

measurement.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

force-parameter (function).


3.1.33 qvm/transition-classical-instructions.lisp

Dependency

transition.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.34 qvm/stabilizer-qvm.lisp

Dependency

transition-classical-instructions.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.35 qvm/execution.lisp

Dependency

stabilizer-qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

nop-count (function).


3.1.36 qvm/path-simulate.lisp

Dependency

execution.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.37 qvm/misc.lisp

Dependency

path-simulate.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface

program-matrix (function).


3.1.38 qvm/noise-models.lisp

Dependency

misc.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.39 qvm/channel-qvm.lisp

Dependency

noise-models.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.40 qvm/basic-noise-qvm.lisp

Dependency

channel-qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.41 qvm/density-qvm.lisp

Dependency

basic-noise-qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.42 qvm/noisy-qvm.lisp

Dependency

density-qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

3.1.43 qvm/depolarizing-noise.lisp

Dependency

noisy-qvm.lisp (file).

Source

qvm.asd.

Parent Component

qvm (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 qvm

Package containing an implementation of a quantum virtual machine.

Source

package.lisp.

Use List
  • common-lisp.
  • org.tfeb.hax.abstract-classes.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *compile-before-running*

Compile programs loaded into the QVM before running them.

Package

qvm.

Source

config.lisp.

Special Variable: *qubits-required-for-parallelization*

The number of qubits required of a quantum state before it gets operated on in parallel.

See also *QUBIT-LIMIT-FOR-USING-SERIAL-KERNELS*.

Package

qvm.

Source

config.lisp.

Special Variable: *transition-verbose*

Controls whether each transition is printed with a timing.

Package

qvm.

Source

config.lisp.


5.1.2 Macros

Macro: defun-inlinable (name lambda-list &body body)

Define an INLINE-able function.

Package

qvm.

Source

utilities.lisp.

Macro: pdotimes ((i n &optional ret) &body body)

Selectively perform DOTIMES or LPARALLEL:DOTIMES, depending on whether the number of iterations N exceeds the threshold set by *QUBITS-REQUIRED-FOR-PARALLELIZATION*.

Package

qvm.

Source

utilities.lisp.

Macro: psum-dotimes ((i range) &body body)

Compute the sum of BODY for I in ranging over 0 <= I < RANGE. RANGE must be a non-negative fixnum.

Package

qvm.

Source

utilities.lisp.

Macro: with-random-state ((state) &body body)
Package

qvm.

Source

utilities.lisp.


5.1.3 Compiler macros

Compiler Macro: cflonum (x)
Package

qvm.

Source

floats.lisp.

Compiler Macro: flonum (x)
Package

qvm.

Source

floats.lisp.


5.1.4 Ordinary functions

Function: add-noise-models (nm1 nm2)

Combines two noise models NM1 and NM2 by concatenating their rules. This way, either rule can be matched by an instruction.

Package

qvm.

Source

noise-models.lisp.

Function: apply-matrix-operator (matrix wavefunction qubits)

Apply the matrix operator OPERATOR to the amplitudes of WAVEFUNCTION specified by the qubits QUBITS.

Package

qvm.

Source

wavefunction.lisp.

Function: apply-operator (operator wavefunction qubits)

Apply an operator OPERATOR to the amplitudes of WAVEFUNCTION specified by the qubits QUBITS. OPERATOR shall be a unary function taking a QUANTUM-STATE as an argument and modifying it.

Package

qvm.

Source

wavefunction.lisp.

Function: boolean-bit (boolean)

Convert a generalized boolean BOOLEAN into a good ol’ BIT.

Package

qvm.

Source

utilities.lisp.

Function: cflonum (x)

Coerce X into a CFLONUM.

Package

qvm.

Source

floats.lisp.

Function: copy-wavefunction (wf &optional destination)

Create a copy of the wavefunction WF. If DESTINATION is NIL, allocate a new vector on the Lisp heap. If DESTINATION is provided, copy the wavefunction WF into the DESTINATION vector. Only copy as many elements as can be copied, namely min(|wf|, |destination|).

Package

qvm.

Source

wavefunction.lisp.

Function: count-logical-cores ()

Compute the number of logical cores on the machine.

Package

qvm.

Source

utilities.lisp.

Function: damping-kraus-map (t1 elapsed-time)

Given a value for T1 and a ELAPSED-TIME, generates the kraus operators corresponding to the amplitude damping noise.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: dephasing-kraus-map (t-phi elapsed-time)

Given a value for T-PHI (dephasing time) and a ELAPSED-TIME, calculates the kraus operators corresponding to the dephasing noise.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: depolarizing-kraus-map (prob)

Given a probability of depolarization PROB, calculate the kraus operation elements for the depolarizing channel.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: flonum (x)

Coerce X into a FLONUM.

Package

qvm.

Source

floats.lisp.

Function: kraus-kron (k1s k2s)

Calculate the tensor product of two kraus maps K1S and K2S by tensoring their elems. If one of the kraus maps is NIL, tensor the other with the identity matrix.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: load-program (qvm program &key supersede-memory-subsystem)

Load the program PROGRAM into the quantum virtual machine QVM. If SUPERSEDE-MEMORY-SUBSYSTEM is true (default: NIL), then the memory subsystem will be recomputed for the QVM based off of the program.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: magicl-matrix-to-quantum-operator (m)

Convert a MAGICL matrix M to a QUANTUM-OPERATOR.

Package

qvm.

Source

linear-algebra.lisp.

Function: make-classical-memory (size)

Allocate SIZE octets of memory.

Package

qvm.

Source

classical-memory.lisp.

Function: make-density-matrix-state (num-qubits &key allocation)
Package

qvm.

Source

state-representation.lisp.

Function: make-density-qvm (num-qubits &rest kws &key allocation &allow-other-keys)
Package

qvm.

Source

density-qvm.lisp.

Function: make-matrix (size &rest elements)

Make a SIZE x SIZE complex matrix whose elements are ELEMENTS. Each of ELEMENTS must be able to be coerced into a CFLONUM.

Package

qvm.

Source

linear-algebra.lisp.

Function: make-noise-model (noise-rules)

Returns a noise model with NOISE-RULES.

Package

qvm.

Source

noise-models.lisp.

Function: make-noise-predicate (predicate-function priority noise-position &optional name)

Creates a NOISE-PREDICATE with the given PREDICATE-FUNCTION (function designator), PRIORITY, and NOISE-POSITION.

Package

qvm.

Source

noise-models.lisp.

Function: make-noise-rule (predicate &rest kraus-maps)

Returns a noise rule with the specified PREDICATE and list KRAUS-MAPS.

Package

qvm.

Source

noise-models.lisp.

Function: make-pauli-noise-map (px py pz)

Generates a Kraus map for a noisy identity channel:

M[rho] = (1-px-py-pz) rho + px X rho X + py Y rho Y + pz Z rho Z.

The arguments PX, PY and PZ can be interpreted as probabilities of a X, Y or Z error affecting the qubit.

Package

qvm.

Source

noisy-qvm.lisp.

Function: make-pure-state (num-qubits &key allocation)

ALLOCATION is an optional argument with the following behavior.
- If NULL (default), then a standard wavefunction in the Lisp heap will be allocated.
- If STRING, then the wavefunction will be allocated as a shared memory object, accessible by that name.
- Otherwise, it’s assumed to be an object that is compatible with the ALLOCATION-LENGTH and ALLOCATE-VECTOR methods. - will probs have to redo this in multiple places, have a helper function do the allocation stuff.

Package

qvm.

Source

state-representation.lisp.

Function: make-qvm (num-qubits &key classical-memory-model allocation)

Make a new quantum virtual machine with NUM-QUBITS number of qubits and a classical memory size of CLASSICAL-MEMORY-SIZE bits. ALLOCATION is an optional argument with the following behavior. - If NULL (default), then a standard wavefunction in the Lisp heap will be allocated.
- If STRING, then the wavefunction will be allocated as a shared memory object, accessible by that name.
- Otherwise, it’s assumed to be an object that is compatible with the ALLOCATION-LENGTH and ALLOCATE-VECTOR methods

Package

qvm.

Source

qvm.lisp.

Function: map-amplitudes (qvm f)

Apply the function F to the amplitudes of the QVM in standard order.

Package

qvm.

Source

qvm.lisp.

Function: match-all-gates ()

The returned function is true if the instruction contains a gate (not a MEASURE).

Package

qvm.

Source

noise-models.lisp.

Function: match-all-nq-gates (n)

The returned function is true if the instruction operates on N qubits.

Package

qvm.

Source

noise-models.lisp.

Function: match-any-gates (&rest gates)

The returned function is true if there is any intersection between the instruction’s gate and GATES.

Package

qvm.

Source

noise-models.lisp.

Function: match-any-n-qubits (n qubit-list)

The returned function is true if there is any intersection between the instruction’s qubits and the QUBIT-LIST for an N-qubit operation. We need to specify N in the rule because a 2 qubit gate CNOT 0 1 could match a rule with qubits that has operation elements for a 1q gate. We want to prevent this, so we require the user to specify the number of qubits expected in the gate.

Package

qvm.

Source

noise-models.lisp.

Function: match-instr-idxs (parsed-prog &rest idxs)

The returned function is true if the index of the INSTR in the program PARSED-PROG matches IDXS.

Package

qvm.

Source

noise-models.lisp.

Function: match-measure ()

The returned function is true if the instruction is a MEASURE.

Package

qvm.

Source

noise-models.lisp.

Function: match-measure-at-any (&rest qubits)

The returned function is true if the instruciton is a MEASURE on any of the specified QUBITS.

Package

qvm.

Source

noise-models.lisp.

Function: match-measure-at-strict (qubit)

The returned function is true if the instruciton is a MEASURE on the specified QUBIT.

Package

qvm.

Source

noise-models.lisp.

Function: match-strict-gate (gate)

The returned function is true if the instruction is a GATE-APPLICATION that is exactly equal to GATE.

Package

qvm.

Source

noise-models.lisp.

Function: match-strict-qubits (&rest qubits)

The returned function is true if QUBITS exactly equals the gate application’s qubits in the same order (CNOT 0 1 does NOT match CNOT 1 0).

Package

qvm.

Source

noise-models.lisp.

Function: memory-bit-ref (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: (setf memory-bit-ref) (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: memory-descriptors-to-qvm-memory-model (descrs)

Given a list of memory descriptors DESCRS (as if by QUIL:PARSED-PROGRAM-MEMORY-DEFINITIONS), produce a memory model object suitable for creating a CLASSICAL-MEMORY-SUBSYSTEM.

Package

qvm.

Source

classical-memory.lisp.

Function: memory-integer-ref (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: (setf memory-integer-ref) (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: memory-octet-ref (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: (setf memory-octet-ref) (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: memory-real-ref (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: (setf memory-real-ref) (mem i)
Package

qvm.

Source

classical-memory.lisp.

Function: memory-ref (qvm memory-name i)

Get the memory named MEMORY-NAME at index I in the QVM.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: (setf memory-ref) (qvm memory-name i)

Set the memory named MEMORY-NAME at index I in the QVM to NEW-VALUE.

Package

qvm.

Source

classical-memory-mixin.lisp.

Reader: memory-size (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

size.

Function: multiply-noise-models (nm1 nm2)

Combines two noise models NM1 and NM2 in a way such that both set of rules, or one and not the other could be matched by an instruction.

Package

qvm.

Source

noise-models.lisp.

Function: normalize-wavefunction (wavefunction &key length)

Normalize the wavefunction WAVEFUNCTION, making it a unit vector in the constituent Hilbert space.

If the length/norm of WAVEFUNCTION is known, it can be passed as the LENGTH parameter.

Package

qvm.

Source

wavefunction.lisp.

Function: nth-amplitude (qvm n)

Get the Nth amplitude of the quantum virtual machine QVM.

Package

qvm.

Source

qvm.lisp.

Function: (setf nth-amplitude) (qvm n)

Set the Nth amplitude of the quantum virtual machine QVM.

Package

qvm.

Source

qvm.lisp.

Function: octets-required-for-quantum-state (state)

The number of octets reqquired to represent a given quantum state.

Package

qvm.

Source

linear-algebra.lisp.

Function: octets-required-for-qubits (n)

The number of octets required to represent a state of N qubits.

Package

qvm.

Source

linear-algebra.lisp.

Function: path-simulate (parsed-prog initial-classical-state final-classical-states)

Simulate the parsed program PARSED-PROG starting with the initial classical state INITIAL-CLASSICAL-STATE and ending with the final classical states FINAL-CLASSICAL-STATES. FINAL-CLASSICAL-STATES should be a list of classical states.

Return a list of amplitudes associated with the classical states.

PARSED-PROG must be a program that only contains gate applications.

Package

qvm.

Source

path-simulate.lisp.

Function: predicate-and (noise-predicate1 noise-predicate2)

Logical AND of 2 noise predicates. The NOISE-POSITION is taken from NOISE-PREDICATE1 and the priority is taken to be the max PRIORITY between the two predicates.

Package

qvm.

Source

noise-models.lisp.

Function: predicate-or (noise-predicate1 noise-predicate2)

Logical OR of 2 noise predicates. The NOISE-POSITION is taken from NOISE-PREDICATE1 and the priority is taken to be the max PRIORITY between the two predicates.

Package

qvm.

Source

noise-models.lisp.

Function: prepare-for-parallelization (&optional num-workers)

Create a worker pool if none exists or if NUM-WORKERS has changed.

If NUM-WORKERS is not provided, the number of workers will be set to the number of logical cores of your machine. This function does nothing if NUM-WORKERS workers have already been created.
If NUM-WORKERS is provided it should be less than or equal to the number of logical cores of your machine.

NOTE: This must be called before computations can be done.

Package

qvm.

Source

utilities.lisp.

Function: probability (amplitude)

Convert an amplitude into a probability.

Package

qvm.

Source

wavefunction.lisp.

Function: program-matrix (pp)

Compute the matrix of the parsed program PP by way of simulating it on every basis element.

Package

qvm.

Source

misc.lisp.

Function: qubit-probability (qvm qubit)

DEPRECATED // The probability that the physical qubit addressed by QUBIT is 1.

Package

qvm.

Source

qvm.lisp.

Function: run-program (num-qubits program)

Run the program PROGRAM on a QVM of NUM-QUBITS qubits.

Package

qvm.

Source

execution.lisp.

Function: seeded-random-state (seed)

Return an MT19937 random state that has been initialized from SEED, which should be either NIL (meaning to use the current value of MT19937:*RANDOM-STATE*), or an integer or a specialized vector of (unsigned-byte 32), which will result in a reproducible random state.

Package

qvm.

Source

utilities.lisp.

Function: tphi (t1 t2)

Calculate t_phi from T1 and T2. T-PHI = (2*T1*T2) / (2*T1 + T2). T2 must be strictly less than 2 * T1.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: warm-apply-matrix-operator-cache (&key max-qubits)

Warm up the **APPLY-MATRIX-OPERATOR-FUNCTIONS** cache for Hilbert spaces B_i and B_i (x) B_j for 0 <= i, j <= MAX-QUBITS.

Package

qvm.

Source

compile-gate.lisp.

Function: wavefunction-excited-state-probability (wavefunction qubit)

Compute the probability that qubit QUBIT is in the excited state.

Package

qvm.

Source

wavefunction.lisp.

Function: wavefunction-from-path-simulation (parsed-prog)

Compute the wavefunction of the program PARSED-PROG using path simulation.

Package

qvm.

Source

path-simulate.lisp.

Function: wavefunction-ground-state-probability (wavefunction qubit)

Compute the probability that qubit QUBIT is in the ground state.

Package

qvm.

Source

wavefunction.lisp.

Function: wf (elt &rest elts)

Construct a wavefunction from the elements (ELT . ELTS).

Package

qvm.

Source

wavefunction.lisp.

Function: zero-out-classical-memory (mem)

Zero out the classical memory MEM.

Package

qvm.

Source

classical-memory.lisp.


5.1.5 Generic functions

Generic Function: allocate-vector (description)

Allocate a fresh zero-initialized CFLONUM-VECTOR described by DESCRIPTION. Return two values:

1. The allocated vector (a CFLONUM-VECTOR).

2. A finalizer thunk of type FINALIZER, which should be called when the memory is OK to be freed.

NOTE: Note that the finalizer may close over the allocated vector.

Package

qvm.

Source

allocator.lisp.

Methods
Method: allocate-vector ((descr posix-shared-memory-allocation))
Source

shm.lisp.

Method: allocate-vector ((descr c-allocation))
Method: allocate-vector ((descr lisp-allocation))
Generic Reader: allocation-length (description)

The length of memory to be allocated, measured in the element type of the vector.

Package

qvm.

Source

allocator.lisp.

Methods
Reader Method: allocation-length ((posix-shared-memory-allocation posix-shared-memory-allocation))

automatically generated reader method

Target Slot

length.

Reader Method: allocation-length ((c-allocation c-allocation))

automatically generated reader method

Target Slot

length.

Reader Method: allocation-length ((lisp-allocation lisp-allocation))

automatically generated reader method

Target Slot

length.

Generic Function: apply-gate-to-state (gate state qubits &rest parameters)

Apply a gate GATE to the state STATE on the sub-Hilbert space defined by the NAT-TUPLE of qubit indexes QUBITS. PARAMETERS is a list of numeric parameters passed to a dynamic gate.

Package

qvm.

Source

apply-gate.lisp.

Methods
Method: apply-gate-to-state ((gate simple-gate) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate parameterized-gate) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate permutation-gate) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate controlled-gate) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate forked-gate) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate dagger-gate) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate compiled-matrix-gate-application) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate compiled-inlined-matrix-gate-application) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate compiled-permutation-gate-application) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate superoperator) (state pure-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate superoperator) (state density-matrix-state) qubits &rest parameters)
Method: apply-gate-to-state ((gate gate) (state density-matrix-state) qubits &rest parameters)
Generic Reader: classical-memory-subsystem (object)
Package

qvm.

Methods
Reader Method: classical-memory-subsystem ((classical-memory-mixin classical-memory-mixin))

The classical memory subsystem of the QVM. No memory by default.

Source

classical-memory-mixin.lisp.

Target Slot

classical-memory-subsystem.

Generic Function: force-measurement (measured-value qubit state excited-probability)

Manipulate the STATE as to force the QUBIT in STATE to collapse to the MEASURED-VALUE. EXCTIED-PROBABILITY is the probability that the specified QUBIT measures to |1>, regardless of the MEASURED-VALUE it is being forced to.

Package

qvm.

Source

measurement.lisp.

Methods
Method: force-measurement (measured-value qubit (state density-matrix-state) excited-probability)

Force the density-matrix-state STATE to have the qubit QUBIT collapse/measure to MEASURED-VALUE. Modify the density matrix appropriately.EXCITED-PROBABILITY should be the probability that QUBIT measured to |1>, regardless of what it’s being forced as.

Method: force-measurement (measured-value qubit (state pure-state) excited-probability)

Force the quantum system of the PURE-STATE STATE to have the qubit QUBIT collapse/measure to MEASURED-VALUE. Modify the amplitudes of all other qubits accordingly. EXCITED-PROBABILITY should be the probability that QUBIT measured to |1>, regardless of what it’s being forced as.

Generic Reader: invalid-instruction (condition)
Package

qvm.

Methods
Reader Method: invalid-instruction ((condition invalid-instruction-encountered))
Source

transition.lisp.

Target Slot

instruction.

Generic Reader: invalid-reason (condition)
Package

qvm.

Methods
Reader Method: invalid-reason ((condition invalid-instruction-encountered))
Source

transition.lisp.

Target Slot

reason.

Generic Function: measure (qam q)

Non-deterministically perform a measurement on the qubit addressed by Q in the quantum abstract machine QAM.

Return two values:

1. The resulting QAM.
2. The measured classical bit.

Package

qvm.

Source

qam.lisp.

Methods
Method: measure ((qvm stabilizer-qvm) q)
Source

stabilizer-qvm.lisp.

Method: measure ((qvm base-qvm) q)
Source

measurement.lisp.

Generic Function: measure-all (qam)

Non-deterministically perform a measurement on all qubits in the quantum abstract machine QAM. Return two values:

1. The resulting QAM.
2. A list of measured bits.

Package

qvm.

Source

qam.lisp.

Methods
Method: measure-all ((qvm noisy-qvm))
Source

noisy-qvm.lisp.

Method: measure-all ((qvm density-qvm))
Source

density-qvm.lisp.

Method: measure-all ((qvm base-qvm))
Source

measurement.lisp.

Method: measure-all (qam)
Generic Reader: name (object)
Package

qvm.

Methods
Reader Method: name ((noise-predicate noise-predicate))

Name or descriptor for noise.

Source

noise-models.lisp.

Target Slot

name.

Generic Reader: noise-model (object)
Package

qvm.

Methods
Reader Method: noise-model ((channel-qvm channel-qvm))

automatically generated reader method

Source

channel-qvm.lisp.

Target Slot

noise-model.

Generic Writer: (setf noise-model) (object)
Package

qvm.

Methods
Writer Method: (setf noise-model) ((channel-qvm channel-qvm))

automatically generated writer method

Source

channel-qvm.lisp.

Target Slot

noise-model.

Generic Reader: noise-position (object)
Package

qvm.

Methods
Reader Method: noise-position ((noise-predicate noise-predicate))

Should application of a channel happen before or after the instruction?

Source

noise-models.lisp.

Target Slot

noise-position.

Generic Reader: noise-predicate (object)
Generic Writer: (setf noise-predicate) (object)
Package

qvm.

Methods
Reader Method: noise-predicate ((noise-rule noise-rule))
Writer Method: (setf noise-predicate) ((noise-rule noise-rule))

A function that is true when an instruction is matched, false otherwise.

Source

noise-models.lisp.

Target Slot

noise-predicate.

Generic Reader: noise-rules (object)
Generic Writer: (setf noise-rules) (object)
Package

qvm.

Methods
Reader Method: noise-rules ((noise-model noise-model))
Writer Method: (setf noise-rules) ((noise-model noise-model))

A list of NOISE-RULEs.

Source

noise-models.lisp.

Target Slot

noise-rules.

Generic Function: number-of-qubits (qam)

Return the number of qubits configured on the quantum abstract machine QAM.

Package

qvm.

Source

qam.lisp.

Methods
Method: number-of-qubits ((qvm stabilizer-qvm))
Source

stabilizer-qvm.lisp.

Reader Method: number-of-qubits ((base-qvm base-qvm))

Number of qubits being simulated by the QVM.

Source

qvm.lisp.

Target Slot

number-of-qubits.

Generic Reader: predicate-function (object)
Package

qvm.

Methods
Reader Method: predicate-function ((noise-predicate noise-predicate))

Does the instruction trigger the application of a channel?

Source

noise-models.lisp.

Target Slot

predicate-function.

Generic Function: predicate-not (noise-predicate)
Package

qvm.

Methods
Method: predicate-not (noise-predicate)

Logical NOT of a NOISE-PREDICATE. The PRIORITY of the predicate is ’inverted’, by taking the difference between itself and +MAXPRIORITY+.

Source

noise-models.lisp.

Generic Reader: priority (object)
Package

qvm.

Methods
Reader Method: priority ((noise-predicate noise-predicate))

For ordering when checking for an instruction’s matching predicates. The convention we use is that more specific predicates get higher priorities.

Source

noise-models.lisp.

Target Slot

priority.

Generic Function: run (qam)

Simulate the quantum abstract machine QAM until completion. Return the QAM in its end state.

Package

qvm.

Source

qam.lisp.

Methods
Method: run :before ((qvm basic-noise-qvm))
Source

basic-noise-qvm.lisp.

Method: run :after ((qvm base-qvm))
Source

execution.lisp.

Method: run ((qvm classical-memory-mixin))
Source

execution.lisp.

Method: run :before ((qvm pure-state-qvm))
Source

execution.lisp.

Generic Function: set-noisy-gate (qvm gate-name qubits kraus-ops)

Add noisy gate definition to QVM for a SIMPLE-GATE specified by GATE-NAME in terms of the Kraus operator representation

rho -> sum_{j=1}^n K_j rho K_j^H.

The argument KRAUS-OPS should hold the Kraus operators as list of MAGICL matrices ’(K1 K2 ... Kn).

Package

qvm.

Source

density-qvm.lisp.

Methods
Method: set-noisy-gate ((qvm noisy-qvm) gate-name qubits kraus-ops)
Source

noisy-qvm.lisp.

Method: set-noisy-gate ((qvm density-qvm) gate-name qubits kraus-ops)
Generic Function: set-to-zero-state (state)

Set the initial state to the pure zero state.

Package

qvm.

Source

state-representation.lisp.

Methods
Method: set-to-zero-state ((state density-matrix-state))
Method: set-to-zero-state ((state pure-state))
Generic Function: state-elements (state)

Extract the state data from the STATE. This is AMPLITUDES for a PURE-STATE, or ELEMENTS-VECTOR for a DENSITY-MATRIX-STATE.

Package

qvm.

Source

state-representation.lisp.

Methods
Method: state-elements ((state density-matrix-state))
Method: state-elements ((state pure-state))
Generic Function: (setf state-elements) (state)
Package

qvm.

Methods
Method: (setf state-elements) ((state density-matrix-state))
Source

state-representation.lisp.

Method: (setf state-elements) ((state pure-state))
Source

state-representation.lisp.

Generic Function: transition (qvm instr)

Execute the instruction INSTR on the QVM.

Return just the resulting (possibly modified) QVM after executing INSTR. (Historical note: used to also return pc)

Package

qvm.

Source

transition.lisp.

Methods
Method: transition :before ((qvm depolarizing-qvm) (instr measurement))
Source

depolarizing-noise.lisp.

Method: transition :after ((qvm depolarizing-qvm) (instr reset))
Source

depolarizing-noise.lisp.

Method: transition :after ((qvm depolarizing-qvm) (instr application))
Source

depolarizing-noise.lisp.

Method: transition :around ((qvm noisy-qvm) (instr measurement))
Source

noisy-qvm.lisp.

Method: transition ((qvm noisy-qvm) (instr gate-application))
Source

noisy-qvm.lisp.

Method: transition :around ((qvm density-qvm) (instr measurement))
Source

density-qvm.lisp.

Method: transition ((qvm density-qvm) (instr gate-application))
Source

density-qvm.lisp.

Method: transition :around ((qvm basic-noise-qvm) (instr measurement))
Source

basic-noise-qvm.lisp.

Method: transition :after ((qvm basic-noise-qvm) (instr gate-application))
Source

basic-noise-qvm.lisp.

Method: transition :around ((qvm channel-qvm) (instr measurement))
Source

channel-qvm.lisp.

Method: transition :after ((qvm channel-qvm) (instr gate-application))
Source

channel-qvm.lisp.

Method: transition :before ((qvm channel-qvm) (instr gate-application))
Source

channel-qvm.lisp.

Method: transition ((qvm pure-state-qvm) (instr clifford-application))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm stabilizer-qvm) (instr clifford-application))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm stabilizer-qvm) (instr gate-application))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm stabilizer-qvm) (instr measure-discard))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm stabilizer-qvm) (instr measure))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm stabilizer-qvm) (instr reset-qubit))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm stabilizer-qvm) (instr reset))
Source

stabilizer-qvm.lisp.

Method: transition ((qvm classical-memory-mixin) (instr wait))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-equal-bit/bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-greater-than-bit/bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-equal-bit/bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-less-than-bit/bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-equality-bit/bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-store))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-load))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-division-real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-division-real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-division-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-division-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-multiplication-real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-multiplication-real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-multiplication-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-multiplication-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-subtraction-real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-subtraction-real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-subtraction-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-subtraction-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-addition-real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-addition-real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-addition-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-addition-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-convert-bit/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-convert-bit/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-convert-real/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-convert-real/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-convert-integer/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-convert-integer/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exchange))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-real/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-real/real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-move-octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exclusive-or-octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exclusive-or-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exclusive-or-bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exclusive-or-octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exclusive-or-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-exclusive-or-bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-inclusive-or-octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-inclusive-or-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-inclusive-or-bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-inclusive-or-octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-inclusive-or-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-inclusive-or-bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-and-octet/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-and-integer/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-and-bit/immediate))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-and-octet/octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-and-integer/integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-and-bit/bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-not-integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-not-octet))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-not-bit))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-negate-integer))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm classical-memory-mixin) (instr classical-negate-real))
Source

transition-classical-instructions.lisp.

Method: transition ((qvm pure-state-qvm) (instr compiled-measurement))
Method: transition ((qvm pure-state-qvm) (instr compiled-gate-application))
Method: transition ((qvm base-qvm) (instr gate-application))
Method: transition ((qvm base-qvm) (instr measure-all))
Method: transition ((qvm base-qvm) (instr measure-discard))
Method: transition ((qvm base-qvm) (instr measure))
Method: transition ((qvm classical-memory-mixin) (instr jump-unless))
Method: transition ((qvm classical-memory-mixin) (instr jump-when))
Method: transition ((qvm classical-memory-mixin) (instr unconditional-jump))
Method: transition ((qvm pure-state-qvm) (instr reset-qubit))
Method: transition ((qvm base-qvm) (instr reset))
Method: transition ((qvm classical-memory-mixin) (instr halt))
Method: transition ((qvm classical-memory-mixin) (instr pragma))
Method: transition ((qvm classical-memory-mixin) (instr no-operation))
Method: transition (qvm (instr unresolved-application))
Method: transition :around (qvm instr)

5.1.6 Standalone methods

Method: initialize-instance :after ((qvm pure-state-qvm) &rest args)
Source

qvm.lisp.

Method: initialize-instance :after ((qvm noisy-qvm) &rest args)
Source

noisy-qvm.lisp.

Method: initialize-instance :after ((state pure-state) &key num-qubits &allow-other-keys)
Source

state-representation.lisp.

Method: initialize-instance :after ((predicate noise-predicate) &rest args)
Source

noise-models.lisp.

Method: initialize-instance :after ((state density-matrix-state) &key num-qubits &allow-other-keys)
Source

state-representation.lisp.

Method: initialize-instance :after ((qvm basic-noise-qvm) &rest args)
Source

basic-noise-qvm.lisp.

Method: initialize-instance :after ((nm noise-model) &rest args)
Source

noise-models.lisp.

Method: initialize-instance :after ((instance classical-memory-subsystem) &rest initargs)
Source

classical-memory.lisp.

Method: initialize-instance :after ((qvm density-qvm) &rest args)
Source

density-qvm.lisp.

Method: initialize-instance :after ((qvm channel-qvm) &rest args)
Source

channel-qvm.lisp.

Method: initialize-instance :after ((qvm base-qvm) &rest args)
Source

qvm.lisp.

Method: initialize-instance :after ((qvm mixed-state-qvm) &rest args)
Source

mixed-state-qvm.lisp.

Method: make-load-form ((obj classical-memory) &optional env)
Source

classical-memory.lisp.

Method: make-load-form ((object-0 single-kraus) &optional environment-3)
Source

linear-algebra.lisp.

Method: make-load-form ((object-0 kraus-list) &optional environment-3)
Source

linear-algebra.lisp.

Method: print-object ((obj classical-memory) stream)
Source

classical-memory.lisp.

Method: print-object ((object single-kraus) stream)
Source

linear-algebra.lisp.

Method: print-object ((o clifford-application) stream)
Source

stabilizer-qvm.lisp.

Method: print-object ((ss subsystem) stream)
Source

subsystem.lisp.

Method: print-object ((obj memory-view) stream)
Source

classical-memory.lisp.

Method: print-object ((object kraus-list) stream)
Source

linear-algebra.lisp.


5.1.7 Conditions

Condition: invalid-instruction-encountered

An error raised when a gate is invoked incorrectly.

Package

qvm.

Source

transition.lisp.

Direct superclasses

error.

Direct methods
Direct Default Initargs
InitargValue
:becausenil
Direct slots
Slot: instruction
Initargs

:instruction

Readers

invalid-instruction.

Writers

This slot is read-only.

Slot: reason
Initargs

:because

Readers

invalid-reason.

Writers

This slot is read-only.

Condition: memory-index-out-of-bounds
Package

qvm.

Source

classical-memory.lisp.

Direct superclasses

error.

Direct methods
Direct slots
Slot: index
Initargs

:index

Readers

oob-index.

Writers

This slot is read-only.

Slot: from
Initargs

:from

Readers

oob-from.

Writers

This slot is read-only.

Slot: to
Initargs

:to

Readers

oob-to.

Writers

This slot is read-only.

Slot: name
Initform

(quote nil)

Initargs

:name

Readers

oob-name.

Writers

This slot is read-only.


5.1.8 Structures

Structure: classical-memory

A representation of a chunk of allocated classical memory.

Package

qvm.

Source

classical-memory.lisp.

Direct superclasses

structure-object.

Direct methods
Direct slots
Slot: size
Type

alexandria:non-negative-fixnum

Initform

0

Readers

memory-size.

Writers

This slot is read-only.

Slot: pointer
Type

cffi-sys:foreign-pointer

Initform

(cffi-sys:null-pointer)

Readers

memory-pointer.

Writers

This slot is read-only.


5.1.9 Classes

Class: basic-noise-qvm

BASIC-NOISE-QVM is a QVM that supports a noise model defined by T1, T2, T-phi, depolarization probability, and readout fidelities on each qubit. At each instruction, damping, dephasing, and depolarizing noise is applied for the qubits involved in the instruction. If READOUT-POVMS are defined for a qubit, the readout noise is applied after a MEASURE instruction on that qubit.

Package

qvm.

Source

basic-noise-qvm.lisp.

Direct superclasses

base-qvm.

Direct methods
Direct Default Initargs
InitargValue
:t1-vals(make-hash-table test (quote eql))
:tphi-vals(make-hash-table test (quote eql))
:t2-vals(make-hash-table test (quote eql))
:depolarization-ops(make-hash-table test (quote eql))
:readout-povms(make-hash-table test (quote eql))
:avg-gate-time(error :avg-gate-time is a required initarg to basic-noise-qvm)
:elapsed-time0.0d0
Direct slots
Slot: t1-vals

Hash table of qubit idx to T1 value for each qubit to simulate

Initargs

:t1-vals

Readers

t1-vals.

Writers

(setf t1-vals).

Slot: t2-vals

Hash table of qubit idx to T2 value for each qubit to simulate

Initargs

:t2-vals

Readers

t2-vals.

Writers

(setf t2-vals).

Slot: tphi-vals

Hash table of qubit idx to TPHI value for each qubit to simulate.

Initargs

:tphi-vals

Readers

tphi-vals.

Writers

(setf tphi-vals).

Slot: depolarization-ops

A hash table of qubit to depolarization operators, representing gate application noise. Gate over-rotations and under-rotations average out to the depolarizing channel.

Initargs

:depolarization-ops

Readers

depolarization-ops.

Writers

(setf depolarization-ops).

Slot: readout-povms

A hash-table of qubit idx to a list of povms, representing the readout assignment probabilities (p(0|0) p(0|1) p(1|0) p(1|1)).

Initargs

:readout-povms

Readers

readout-povms.

Writers

(setf readout-povms).

Slot: avg-gate-time

To calculate the kraus operators for T1, T2, etc. noise, a gate time value is needed. Ideally, this gate time should be the duration of the gate preceding the application of the kraus noise. As an approximation, this value should represent the average gate time of the gates that will be run.

Initargs

:avg-gate-time

Readers

avg-gate-time.

Writers

This slot is read-only.

Slot: elapsed-time

A value to keep track of the elpased time of the program. The elapsed time is used for calculating the kraus operators of some noise value at a given point in the program.

Initargs

:elapsed-time

Readers

elapsed-time.

Writers

(setf elapsed-time).

Class: c-allocation

A description of an allocation in foreign memory.

Package

qvm.

Source

allocator.lisp.

Direct methods
Direct slots
Slot: length
Package

common-lisp.

Initargs

:length

Readers

allocation-length.

Writers

This slot is read-only.

Class: channel-qvm

The CHANNEL-QVM is a QVM that supports a fully explicit NOISE-MODEL. The NOISE-MODEL is an explicit definition of where and how different channels should be applied to a program running in the CHANNEL-QVM.

Package

qvm.

Source

channel-qvm.lisp.

Direct superclasses

base-qvm.

Direct methods
Direct Default Initargs
InitargValue
:noise-model(make-noise-model nil)
Direct slots
Slot: noise-model
Initargs

:noise-model

Readers

noise-model.

Writers

(setf noise-model).

Class: classical-memory-mixin

A mixin for quantum abstract machines making use of a classical memory subsystem and a program vector.

Package

qvm.

Source

classical-memory-mixin.lisp.

Direct subclasses
Direct methods
Direct Default Initargs
InitargValue
:classical-memory-subsystem(make-instance (quote classical-memory-subsystem))
:wait-function(quote warning-wait-function)
:gate-definitions(copy-hash-table **default-gate-definitions**)
Direct slots
Slot: classical-memory-subsystem

The classical memory subsystem of the QVM. No memory by default.

Initargs

:classical-memory-subsystem

Readers

classical-memory-subsystem.

Writers

This slot is read-only.

Slot: program-counter

The program counter.

Initform

0

Readers

pc.

Writers

(setf pc).

Slot: program

The program to be executed.

Initform

#()

Readers

program.

Writers

(setf program).

Slot: wait-function

A unary function taking a QVM and implementing Quil’s WAIT logic. (The default does nothing and just warns.)

Initargs

:wait-function

Readers

wait-function.

Writers

This slot is read-only.

Slot: gate-definitions

A table mapping gate names to their GATE-instance definition.

Initargs

:gate-definitions

Readers

gate-definitions.

Writers

(setf gate-definitions).

Class: classical-memory-subsystem

The standard Quil memory subsystem.

Package

qvm.

Source

classical-memory.lisp.

Direct methods
Direct Default Initargs
InitargValue
:classical-memory-model**empty-memory-model**
Direct slots
Slot: classical-memory-model

A description of the structure of the memory of the abstract machine.

Type

cl-quil:memory-model

Initargs

:classical-memory-model

Readers

classical-memory-model.

Writers

This slot is read-only.

Slot: classical-memories

A table mapping names to allocated memories.

Type

hash-table

Readers

classical-memories.

Writers

This slot is read-only.

Class: density-matrix-state

A DENSITY-MATRIX-STATE is a general quantum state of N qubits described by a density matrix ρ, representing a statistical mixture of PURE-STATEs. The elements of ρ are represented by the length 2^(2*N) vector ELEMENTS-VECTOR which is in row-major order. MATRIX-VIEW is the 2D ’traditional’ matrix representation of ρ.

Package

qvm.

Source

state-representation.lisp.

Direct superclasses

quantum-system-state.

Direct methods
Direct Default Initargs
InitargValue
:elements-vectornil
:temporary-statenil
Direct slots
Slot: elements-vector

The contents of a density matrix ρ as a one-dimensional vector. For a state of N qubits, this vector should be of length 2^(2*N).

Initargs

:elements-vector

Readers

elements-vector.

Writers

(setf elements-vector).

Slot: matrix-view

2D array displaced to ELEMENTS-VECTOR

Readers

matrix-view.

Writers

This slot is read-only.

Slot: temporary-state

A placeholder for computations on the elements-vector of a DENSITY-MATRIX-STATE.

Initargs

:temporary-state

Readers

temporary-state.

Writers

(setf temporary-state).

Class: density-qvm

A density matrix simulator.

Package

qvm.

Source

density-qvm.lisp.

Direct superclasses

base-qvm.

Direct methods
Direct slots
Slot: noisy-gate-definitions
Initform

(make-hash-table :test (quote equalp))

Initargs

:noisy-gate-definitions

Readers

noisy-gate-definitions.

Writers

(setf noisy-gate-definitions).

Slot: readout-povms
Initform

(make-hash-table)

Initargs

:readout-povms

Readers

readout-povms.

Writers

(setf readout-povms).

Class: depolarizing-qvm

A quantum virtual machine with parametric depolarizing noise.

Package

qvm.

Source

depolarizing-noise.lisp.

Direct superclasses

pure-state-qvm.

Direct methods
Direct Default Initargs
InitargValue
:x0.0
:y0.0
:z0.0
:measure-x0.0
:measure-y0.0
:measure-z0.0
Direct slots
Slot: probability-gate-x

Probability of a Pauli X gate happening after a gate application or reset.

Initargs

:x

Readers

probability-gate-x.

Writers

(setf probability-gate-x).

Slot: probability-gate-y

Probability of a Pauli Y gate happening after a gate application or reset.

Initargs

:y

Readers

probability-gate-y.

Writers

(setf probability-gate-y).

Slot: probability-gate-z

Probability of a Pauli Z gate happening after a gate application or reset.

Initargs

:z

Readers

probability-gate-z.

Writers

(setf probability-gate-z).

Slot: probability-measure-x

Probability of a Pauli X gate happening before a measurement.

Initargs

:measure-x

Readers

probability-measure-x.

Writers

(setf probability-measure-x).

Slot: probability-measure-y

Probability of a Pauli Y gate happening before a measurement.

Initargs

:measure-y

Readers

probability-measure-y.

Writers

(setf probability-measure-y).

Slot: probability-measure-z

Probability of a Pauli Z gate happening before a measurement.

Initargs

:measure-z

Readers

probability-measure-z.

Writers

(setf probability-measure-z).

Class: lisp-allocation

A description of an allocation on the Lisp heap.

Package

qvm.

Source

allocator.lisp.

Direct methods
Direct slots
Slot: length
Package

common-lisp.

Initargs

:length

Readers

allocation-length.

Writers

This slot is read-only.

Class: measure-all

A pseudo-instruction for measuring all qubits simultaneously.

Package

qvm.

Source

compile-gate.lisp.

Direct methods
Direct slots
Slot: storage

A list of qubit-mref pairs to store, in order.

Initargs

:storage

Readers

measure-all-storage.

Writers

This slot is read-only.

Class: noise-model

A NOISE-MODEL is a collection of NOISE-RULES, describing what type of noise should be applied to a program that goes through a QVM, and where that noise should be applied.

Package

qvm.

Source

noise-models.lisp.

Direct methods
Direct Default Initargs
InitargValue
:noise-rulesnil
:readout-povms(make-hash-table test (quote eql))
Direct slots
Slot: noise-rules

A list of NOISE-RULEs.

Initargs

:noise-rules

Readers

noise-rules.

Writers

(setf noise-rules).

Slot: readout-povms

A hash table of qubit to readout noise assignment probabilities, given as a 4-element list ((p(0|0) p(0|1) p(1|0) p(1|1)).

Initargs

:readout-povms

Readers

readout-povms.

Writers

(setf readout-povms).

Class: noise-predicate

A NOISE-PREDICATE describes a collection of program instructions. When used in a NOISE-RULE, the NOISE-PREDICATE describes which instructions should be matched by the noise described in the OPERATION-ELEMENTS. Optionally, the NOISE-PREDICATE can be given a NAME. If none is provided, use the default ’NOISE-NAME’.

Package

qvm.

Source

noise-models.lisp.

Direct methods
Direct Default Initargs
InitargValue
:predicate-functionnil
:priority10
:noise-position(quote after)
:name+default-noise-predicate-name+
Direct slots
Slot: predicate-function

Does the instruction trigger the application of a channel?

Initargs

:predicate-function

Readers

predicate-function.

Writers

This slot is read-only.

Slot: priority

For ordering when checking for an instruction’s matching predicates. The convention we use is that more specific predicates get higher priorities.

Initargs

:priority

Readers

priority.

Writers

This slot is read-only.

Slot: noise-position

Should application of a channel happen before or after the instruction?

Type

qvm:noise-position

Initargs

:noise-position

Readers

noise-position.

Writers

This slot is read-only.

Slot: name

Name or descriptor for noise.

Initargs

:name

Readers

name.

Writers

This slot is read-only.

Class: noise-rule

A NOISE-RULE consists of noise data (OPERATION-ELEMENTS) and a specification of where the noise data should be applied to the program (NOISE-PREDICATE).

Package

qvm.

Source

noise-models.lisp.

Direct methods
Direct slots
Slot: noise-predicate

A function that is true when an instruction is matched, false otherwise.

Initargs

:noise-predicate

Readers

noise-predicate.

Writers

(setf noise-predicate).

Slot: operation-elements

A list of kraus maps to apply when the rule is matched. Each kraus map is a list of kraus operators.

Initargs

:operation-elements

Readers

operation-elements.

Writers

This slot is read-only.

Class: noisy-qvm
Package

qvm.

Source

noisy-qvm.lisp.

Direct superclasses

pure-state-qvm.

Direct methods
Direct slots
Slot: noisy-gate-definitions

Noisy gate definitions that, if present, override those stored in GATE-DEFINITIONS.

Initform

(make-hash-table :test (quote equalp))

Initargs

:noisy-gate-definitions

Readers

noisy-gate-definitions.

Writers

(setf noisy-gate-definitions).

Slot: readout-povms

Noisy readout encoded as diagonal single qubit
POVM given as a 4-element list

(p(0|0) p(0|1)
p(1|0) p(1|1))

which for each qubit gives the probability p(j|k) of measuring outcome j given actual state k. Note that we model purely classical readout error, i.e., the post measurement qubit state is always k, but the recorded outcome j may be different.

Initform

(make-hash-table :test (quote eql))

Initargs

:readout-povms

Readers

readout-povms.

Writers

(setf readout-povms).

Class: posix-shared-memory-allocation

A description of an allocation in POSIX shared memory.

Package

qvm.

Source

allocator.lisp.

Direct methods
Direct slots
Slot: length
Package

common-lisp.

Initargs

:length

Readers

allocation-length.

Writers

This slot is read-only.

Slot: name
Initargs

:name

Readers

allocation-name.

Writers

This slot is read-only.

Class: pure-state

A PURE-STATE contains the quantum mechanical state for a system that can be described by a vector |ψ> of N qubits with unit length in a Hilbert space. The elements of this length 2^N vector is represented by AMPLITUDES.

Package

qvm.

Source

state-representation.lisp.

Direct superclasses

quantum-system-state.

Direct methods
Direct Default Initargs
InitargValue
:amplitudesnil
:trial-amplitudesnil
:original-amplitudesnil
Direct slots
Slot: amplitudes

The wavefunction of a pure state.

Initargs

:amplitudes

Readers

amplitudes.

Writers

(setf amplitudes).

Slot: trial-amplitudes

A second wavefunction used when applying a noisy quantum channel. Applying a Kraus map generally requires evaluating psi_j = K_j * psi for several different j, making it necessary to keep the original wavefunction around. This value should be a QUANTUM-STATE whose size is compatible with the number of qubits of the CHANNEL-QVM. The actual values can be initialized in any way because they will be overwritten. As such, it merely is scratch space for intermediate computations, and hence should not be otherwise directly accessed.

Initargs

:trial-amplitudes

Readers

%trial-amplitudes.

Writers

(setf %trial-amplitudes).

Slot: original-amplitudes

A reference to the original pointer of amplitude memory, so the amplitudes can sit in the right place at the end of a computation.

Readers

original-amplitudes.

Writers

This slot is read-only.

Class: pure-state-qvm

An pure-state implementation of the Quantum Abstract Machine.

Package

qvm.

Source

qvm.lisp.

Direct superclasses

base-qvm.

Direct subclasses
Direct methods
Direct slots
Slot: state

The unpermuted wavefunction in standard order.

Type

(or null qvm:pure-state)

Initargs

:state

Readers

state.

Writers

%set-state.


5.1.10 Types

Type: amplitude-address ()

An address into an array of amplitudes.

Package

qvm.

Source

wavefunction.lisp.

Type: cflonum ()

The complex float type used in computations. Typically these will represent wavefunction amplitudes.

Package

qvm.

Source

floats.lisp.

Type: flonum (&optional min)

The float type used in computations.

Package

qvm.

Source

floats.lisp.

Type: noise-position ()

Describes the position of a noise rule relative to an instruction. Should the noise be applied :BEFORE or :AFTER the instruction is executed?

Package

qvm.

Source

noise-models.lisp.

Type: parallelization-limit ()

A limit on the number of qubits that can be parallelized across.

Package

qvm.

Source

config.lisp.

Type: probability ()
Package

qvm.

Source

basic-noise-qvm.lisp.

Type: quantum-operator (&optional n)

A representation of an operator on a quantum state. This will be a unitary square matrix where each dimension is a power-of-two.

Package

qvm.

Source

linear-algebra.lisp.

Type: quantum-state (&optional n)

A representation of a quantum state. This will have a power-of-2 length.

Package

qvm.

Source

linear-algebra.lisp.

Type: quil-bit ()
Package

qvm.

Source

classical-memory.lisp.

Type: quil-octet ()
Package

qvm.

Source

classical-memory.lisp.

Type: qvm-integer ()
Package

qvm.

Source

classical-memory.lisp.

Type: qvm-real ()
Package

qvm.

Source

classical-memory.lisp.


5.2 Internals


5.2.1 Constants

Constant: +default-noise-predicate-name+
Package

qvm.

Source

noise-models.lisp.

Constant: +max-nat-tuple-cardinality+
Package

qvm.

Source

utilities.lisp.

Constant: +maxpriority+
Package

qvm.

Source

noise-models.lisp.

Constant: +minpriority+
Package

qvm.

Source

noise-models.lisp.

Constant: +octets-per-cflonum+
Package

qvm.

Source

floats.lisp.

Constant: +octets-per-flonum+
Package

qvm.

Source

floats.lisp.


5.2.2 Special variables

Special Variable: *available-kernels*

An association list of kernels. The keys are integers representing number of qubits, and values are symbols designating function names corresponding to an operator whose lambda list is that described in DEFINE-SERIAL-KERNEL.

Package

qvm.

Source

serial-kernels.lisp.

Special Variable: *compile-measure-chains*

Compile chains of measures into an efficient sampling.

Package

qvm.

Source

config.lisp.

Special Variable: *fuse-gates-during-compilation*

Should gates be fused during compilation?

Package

qvm.

Source

config.lisp.

Special Variable: *inline-static-gates-during-compilation*

Inline the actual gate matrices into the compiled instructions.

Package

qvm.

Source

config.lisp.

Special Variable: *optimize-briskly*

Optimization qualities for when the code should go fast, but have safety.

Package

qvm.

Source

config.lisp.

Special Variable: *optimize-dangerously-fast*

Optimization qualities for when the code should go as fast as possible.

Package

qvm.

Source

config.lisp.

Special Variable: *optimize-safely*

Optimization qualities for when the code should emphasize safety and debugability.

Package

qvm.

Source

config.lisp.

Special Variable: *qubit-limit-for-using-serial-kernels*

The maximum number of qubits allowed in order to use a specified serial kernel.

Package

qvm.

Source

config.lisp.


5.2.3 Macros

Macro: define-binary-transition (class compute-fn accessor)
Package

qvm.

Source

transition-classical-instructions.lisp.

Macro: define-direct-comparator (comparator &rest classes)
Package

qvm.

Source

transition-classical-instructions.lisp.

Macro: define-indirect-comparator (comparator &rest classes)
Package

qvm.

Source

transition-classical-instructions.lisp.

Macro: define-matmul (name size)

Define a matrix multiplier function named NAME for square matrices operating on vectors of length SIZE. The defined function will take three arguments:

1. MATRIX: An object of type QUANTUM-OPERATOR, the multiplier.
2. COLUMN: An object of type QUANTUM-STATE, the vector being multipled.
3. RESULT: An object of type QUANTUM-STATE, where the result is deposited.

The function will just return NIL, and modify the contents of RESULT.

Package

qvm.

Source

linear-algebra.lisp.

Macro: define-serial-kernel (name num-qubits)

Define a function named NAME which has the lambda list

(OP WF Q0 ... Qn-1)

which applies the gate OP (represented as a QUANTUM-OPERATOR) to the wavefunction WF (represented as a QUANTUM-STATE) with qubits Q0 ... Qn-1, where N = NUM-QUBITS.

This function mutates WF and is unsafe.

Package

qvm.

Source

serial-kernels.lisp.

Macro: do-nat-tuple ((elt nt) &body body)

Iterate over the elements of the nat tuple NT in increasing order. The return value is unspecified.

ELT will be bound to the element itself.

Package

qvm.

Source

utilities.lisp.

Macro: measuring-gc ((time-var bytes-var) &body body)

Execute BODY setting TIME-VAR to the number of milliseconds spent garbage collecting, and BYTES-VAR to roughly the number of bytes allocated.

Package

qvm.

Source

utilities.lisp.

Macro: probabilistically (p &body body)

Execute BODY with probability 0 <= P <= 1.

Package

qvm.

Source

utilities.lisp.

Macro: shm-open (name oflag &rest varargs0)
Package

qvm.

Source

shm.lisp.

Macro: sum-dotimes ((i range) &body body)

Compute the sum of BODY for I in ranging over 0 <= I < RANGE. RANGE must be a non-negative fixnum.

Package

qvm.

Source

utilities.lisp.

Macro: with-modified-amplitudes ((col wavefunction qubits starting-address) &body body)

Given a quantum state WAVEFUNCTION, a NAT-TUPLE of qubits QUBITS, and a starting address STARTING-ADDRESS, bind dynamically to the symbol COL the list of amplitudes that correspond to the qubits provided.

Package

qvm.

Source

wavefunction.lisp.

Macro: with-parallel-subdivisions ((start end count &key num-divisions force-parallel) &body body)
Package

qvm.

Source

utilities.lisp.


5.2.4 Ordinary functions

Function: %check-depol-entry (qubit kraus-map)

Check that a key value pair in the DEPOLARIZATION-OPS slot is valid. The QUBIT must be a non-negative integer, and the KRAUS-MAP must be a valid kraus map.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: %check-noise-entry (qubit noise-val)

Check that a key value pair in T1-VALS, T2-VALS, or TPHI-VALS is valid. The QUBIT must be a NON-NEGATIVE INTEGER, and the NOISE-VAL must be of VALID-NOISE-VALUE type for T1-VALS, T2-VALS, and TPHI-VALS.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: %check-povm-entry (qubit povm)

Check that a key value pair in READOUT-POVMS is valid. The QUBIT must be a NON-NEGATIVE INTEGER, and the POVM must be a correctly formatted POVM.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: %close (fd)
Package

qvm.

Source

shm.lisp.

Function: %collapse-integer-by-mask (integer mask)

Let INTEGER and MASK be integers of the same bit-length. Remove the bits of INTEGER that correspond to the zeros of MASK.

Package

qvm.

Source

subsystem.lisp.

Function: %corrupt-qvm-memory-with-povm (qvm instr povm-map)

Apply POVM-MAP to the measured result of the INSTR application.

Package

qvm.

Source

channel-qvm.lisp.

Function: %evolve-density-matrix-with-superoperator (sop state qubits ghost-qubits &key params)

Apply a superoperator SOP to a vectorized density matrix given in the DENSITY-MATRIX-STATE STATE, where QUBITS and GHOST-QUBITS are tuples of qubit indices which the superoperator acts on (from the left and right respectively). The computation may require the STATE’s TEMPORARY-STATE, a vector of the same length as the AMPLITUDES of the STATE. Returns the pair of updated STATE and (perhaps freshly allocated) TEMPORARY-STORAGE.

Package

qvm.

Source

apply-gate.lisp.

Function: %evolve-pure-state-stochastically (kraus-map state qubits)

Uniformly at random select one of the kraus operators in KRAUS-MAP to apply for the PURE-STATE STATE. Randomly select one of the Kraus operators by inverse transform sampling (cf [1]): We divide the unit interval [0,1] into n bins where the j-th bin size equals the probability p_j with which the j-th Kraus operator k_j should be applied. We know that the Kraus operators are normalized such that p_j = <psi|k_j^H k_j |psi> where x^H denotes hermitian conjugation of x and can therefore perform this sampling lazily: First generate a uniformly sampled random number r in [0,1]. Next, find j such that

sum_{k=1}^{j-1} p_k < r <= sum_{k=1}^{j} p_k

This is possible by evaluating only all p_k for k<=j. Then pick this j as the choice of Kraus operator to apply.
[1]: https://en.wikipedia.org/wiki/Inverse_transform_sampling

Package

qvm.

Source

apply-gate.lisp.

Function: %ftruncate (fd offset)
Package

qvm.

Source

shm.lisp.

Function: %make-classical-memory (size pointer)
Package

qvm.

Source

classical-memory.lisp.

Function: %make-nat-tuple (n)
Package

qvm.

Source

utilities.lisp.

Function: %make-shared-memory (&key name size pointer)
Package

qvm.

Source

shm.lisp.

Function: %mmap (addr len prot flags fd offset)
Package

qvm.

Source

shm.lisp.

Function: %munmap (addr len)
Package

qvm.

Source

shm.lisp.

Function: %perform-and (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-integer-add (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-integer-div (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-integer-mul (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-integer-sub (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-ior (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-move (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-real-add (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-real-div (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-real-mul (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-real-sub (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %perform-xor (qvm target-mref left right)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: %serial-norm (wavefunction)
Package

qvm.

Source

wavefunction.lisp.

Function: %strerror (errnum)
Package

qvm.

Source

shm.lisp.

Function: add-depolarizing-noise (qvm qubits px py pz)

Apply depolarizing noise to the list QUBITS of the QVM with the following probabilities:

* Probability of an X-gate PX,
* Probability of a Y-gate PY, and
* Probability of a Z-gate PZ.

It should be that PX + PY + PZ <= 1.

Package

qvm.

Source

depolarizing-noise.lisp.

Function: allocate-memory-for-model (model &key bypass-size-limit)

Allocate memory for a given MEMORY-MODEL MODEL.

Return a hash table mapping memory names to their MEMORY-VIEWs which contain allocated CLASSICAL-MEMORYs.

If BYPASS-SIZE-LIMIT is T (default: NIL), then the size limit dictated by **CLASSICAL-MEMORY-SIZE-LIMIT** will be ignored.

Package

qvm.

Source

classical-memory.lisp.

Function: and-predicate-names (name1 name2)

Returns the concatenated predicate name (NAME1 & NAME2)

Package

qvm.

Source

noise-models.lisp.

Function: apply-1q-operator (op wf q0)

Apply a 1-qubit operator OP to the wavefunction WF on qubits Q0.

Note: This function is raw and unsafe. Pass bad data => get a crash.

Package

qvm.

Source

serial-kernels.lisp.

Function: apply-2q-operator (op wf q0 q1)

Apply a 2-qubits operator OP to the wavefunction WF on qubits Q0, Q1.

Note: This function is raw and unsafe. Pass bad data => get a crash.

Package

qvm.

Source

serial-kernels.lisp.

Function: apply-3q-operator (op wf q0 q1 q2)

Apply a 3-qubits operator OP to the wavefunction WF on qubits Q0, Q1, Q2.

Note: This function is raw and unsafe. Pass bad data => get a crash.

Package

qvm.

Source

serial-kernels.lisp.

Function: assert-in-bounds (i a b &optional name)
Package

qvm.

Source

classical-memory.lisp.

Function: barf-memory (vector pointer)

Barf out the memory designated by the vector of QUIL-OCTETS into the pointer POINTER.

Package

qvm.

Source

classical-memory.lisp.

Function: bit= (a b)
Package

qvm.

Source

compile-gate.lisp.

Function: bring-to-zero-state (v)

Modify the quantum state V to be |...000>.

Package

qvm.

Source

wavefunction.lisp.

Function: calculate-dephasing-map (qubit-tphi qubit-t1 qubit-t2 elapsed-time)

Build the dephasing map. If TPHI is not null, use that to calculate the dephasing map. In the absence of a TPHI value, use T1 and T2 to calculate TPHI if those values exist. T2 is upper bounded by 2 * T1.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: call-at-exit (fun)

Ensure that FUN is called when the Lisp implementation stops.

Package

qvm.

Source

impl/sbcl.lisp.

Function: check-all-kraus-ops (seq)

Call CHECK-KRAUS-OPS on each element of SEQ.

Package

qvm.

Source

channel-qvm.lisp.

Function: check-all-povms (seq)

Call CHECK-POVM on each element of SEQ.

Package

qvm.

Source

channel-qvm.lisp.

Function: check-classical-memory-bounds (i type-name mem)
Package

qvm.

Source

classical-memory.lisp.

Function: check-kraus-ops (kraus-ops)

Verify that a list KRAUS-OPS of Kraus operators given as MAGICL:MATRIX objects encodes a proper kraus map. In particular, we require that the Kraus operators are all of equal matrix dimension with equal numbers of rows and columns. Furthermore, to ensure that the Kraus map preserves trace, they must be normalized such that sum_{j=1}^n K_j^H K_j = I, where I is the identity matrix of equal dimensions.

Package

qvm.

Source

channel-qvm.lisp.

Function: check-povm (povm)

Verify that the list POVM contains a valid single qubit diagonal POVM, given as the list (p(0|0) p(0|1) p(1|0) p(1|1)).

Package

qvm.

Source

channel-qvm.lisp.

Function: check-superoperators (superoperators)

Convert each SUPEROPERATOR in SUPEROPERATORS to a matrix and call CHECK-ALL-KRAUS-OPS on the resulting list.

Package

qvm.

Source

qvm.lisp.

Function: classical-memory-p (object)
Package

qvm.

Source

classical-memory.lisp.

Function: compile-clifford (c &key cache)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: compile-lambda (form)

Compile the lambda form FORM into a FUNCTION object.

Package

qvm.

Source

compile-gate.lisp.

Function: compile-measure-chains (code n)

Given a code vector CODE of N qubits, compile all measure chains.

Package

qvm.

Source

compile-gate.lisp.

Function: compose-operators (a b)

Compute the product of the matrices A and B.

Package

qvm.

Source

linear-algebra.lisp.

Function: convert-to-kraus-list (kraus-ops)

Converts a list of magicl matrices KRAUS-OPS to a SUPEROPERATOR KRAUS-LIST, which is a list of SINGLE-KRAUS.

Package

qvm.

Source

apply-gate.lisp.

Function: copy-hash-table (hash-table)

Copy the hash table HASH-TABLE.

NOTE: This will not copy any multiprocessing aspects.

Package

qvm.

Source

utilities.lisp.

Function: copy-memory-view (instance)
Package

qvm.

Source

classical-memory.lisp.

Function: copy-posix-shared-memory (instance)
Package

qvm.

Source

shm.lisp.

Function: copy-subsystem (instance)
Package

qvm.

Source

subsystem.lisp.

Function: cumulative-distribution-function (state)

Compute the CDF of a quantum state STATE. This is a vector C such that C_i = sum_{0 <= j <= i} Pr(j).

Package

qvm.

Source

wavefunction.lisp.

Function: current-instruction (qvm)

What is the next instruction to be executed on the QVM?

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: dagger (m)

Compute the Hermitian transpose of M in-place.

Package

qvm.

Source

linear-algebra.lisp.

Function: deallocate-all-shared-memories ()

Deallocate all valid shared memories that we’ve remembered.

Package

qvm.

Source

shm.lisp.

Function: density-matrix-state-measurement-probabilities (state)

Computes the probability distribution of measurement outcomes (a vector) associated with the specified density matrix state in the MIXED-STATE-QVM.

For example, if (NUMBER-OF-QUBITS QVM) is 2, then this will return a vector

#(p[0,0] p[0,1] p[1,0] p[1,1])

where p[i,j] denotes the probability that a simultaneous measurement of qubits 0,1 results in the outcome i,j.

Package

qvm.

Source

state-representation.lisp.

Function: density-qvm-measurement-probabilities (qvm)

Computes the probability distribution of measurement outcomes (a vector) associated with the STATE of the DENSITY-QVM.

Package

qvm.

Source

density-qvm.lisp.

Function: dereference-mref (qvm mref)

Look up the value of the quil:memory-ref MREF in the QVM.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: (setf dereference-mref) (qvm mref)

Set the value at the quil:memory-ref MREF in the QVM to NEW-VALUE.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: dummy-finalizer ()

A "finalizer" that does nothing. Used for objects managed by the GC.

Package

qvm.

Source

allocator.lisp.

Function: eject-bit (x n)

Remove the nth bit. Example:

(EJECT-BIT #b1101 1) => #b111

Package

qvm.

Source

utilities.lisp.

Function: eject-bit-code (n)
Package

qvm.

Source

utilities.lisp.

Function: eject-qubit-from-subsystem (ss qubit)

Eject the qubit QUBIT from the subsystem SS. Return two values:

1. A subsystem with the qubit factored out. (If the qubit is not a part of the system, it is assumed to be in the zero state.)

2. The state of the factored out qubit.

Package

qvm.

Source

subsystem.lisp.

Function: enable-all-qvm-optimizations ()
Package

qvm.

Source

config.lisp.

Function: ensure-s64 (n)

Ensure that an integer N is in range of a 64-bit 2’s complement signed integer. Wrap-around if needed.

Package

qvm.

Source

transition-classical-instructions.lisp.

Function: ensure-signed-integer (n bits)
Package

qvm.

Source

transition-classical-instructions.lisp.

Function: ensure-superoperator (mat)

Converts a magicl matrix MAT into a SINGLE-KRAUS SUPEROPERATOR.

Package

qvm.

Source

linear-algebra.lisp.

Function: extract-amplitudes (wavefunction qubits starting-address)

Returns a column vector of amplitudes represented by the tuple of qubits QUBITS.

Package

qvm.

Source

wavefunction.lisp.

Function: find-matching-rule (rules instr position)

Return the first rule that matches INSTR/POSITION in the list RULES.

Package

qvm.

Source

channel-qvm.lisp.

Function: find-measure-chains (n code)

Find measure chains containing all qubits 0 <= q < n.

Package

qvm.

Source

compile-gate.lisp.

Function: find-or-make-apply-matrix-operator-function (qubits)

Find a matrix application function for the Hilbert subspace designated by QUBITS (a NAT-TUPLE).

This function will compile new ones on-demand.

Package

qvm.

Source

compile-gate.lisp.

Function: find-or-make-projector-operator-function (qubit)

Find a projector function for the Hilbert subspace designated by QUBIT (a QUIL:QUBIT).

This function will compile new ones on-demand.

Package

qvm.

Source

compile-gate.lisp.

Function: find-serial-kernel (n)

Find a serial gate application kernel for an N-qubit operator.

Package

qvm.

Source

serial-kernels.lisp.

Function: force-parameter (param qvm)

Force evaluation of an application parameter PARAM, with respect to the specified QVM.

Package

qvm.

Source

transition.lisp.

Function: free-posix-shared-memory (shm)

Free the memory associated with the POSIX shared memory object SHM.

Package

qvm.

Source

shm.lisp.

Function: full-density-number-of-qubits (vec-density)

Computes the number of qubits encoded by a vectorized density matrix.

Package

qvm.

Source

mixed-state-qvm.lisp.

Function: gate-application-to-clifford (gate-app)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: gaussian-random-complex ()

Return a complex number with Gaussian-random real and imaginary parts.

Package

qvm.

Source

wavefunction.lisp.

Function: generate-amplitude-address-code (address flags qubits)

Generate code (a single form) to modify a base address ADDRESS (as produced by a complement iteration loop; represented by a symbol bound to that address) with the flags FLAGS (a non-negative FIXNUM) and qubits QUBITS (a NAT-TUPLE).

This function is similar to the function SET-QUBIT-COMPONENTS-OF-AMPLITUDE-ADDRESS. See its documentation for details.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-complement-iteration (qubits wavefunction body-gen &key dotimes-iterator)

Generate the complement iteration loop for an operator acting on the qubits QUBITS operating on the wavefunction WAVEFUNCTION.

BODY-GEN should be a unary function which takes as an argument the symbol referring to the generated address, and produces a form that uses that address. This form should act as the operator.

DOTIMES-ITERATOR specifies the DOTIMES-like macro that is used for iteration.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-extraction-code (complement-address wavefunction qubits body-gen &key generate-extractions)

Generate LET-like code that extracts amplitudes designated by the qubits QUBITS.

COMPLEMENT-ADDRESS should be a symbol which should be (eventually) bound to the complement address, like that produced by GENERATE-COMPLEMENT-ITERATION.

WAVEFUNCTION should be a symbol which should be (eventually) bound to a wavefunction.

BODY-GEN should be a two-argument function. The first argument will be a list of symbols that will be bound to the wavefunction-addressed values in order. The second argument will be a list of SETF-able accessor forms for those values.

GENERATE-EXTRACTIONS will enable or disable the generation of the values. Setting this to NIL will cause the first argument of BODY-GEN to be NIL.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-gate-application-code (qubits)

Generate a lambda form which takes two arguments, a QUANTUM-OPERATOR and a QUANTUM-STATE, which efficiently applies that operator to that state, lifted from the Hilbert space designated by QUBITS.

QUBITS should be a NAT-TUPLE of qubits representing the Hilbert space.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-gate-application-code-with-matrix (qubits matrix)

Generate a lambda form which takes two arguments, a QUANTUM-OPERATOR and a QUANTUM-STATE, which efficiently applies that operator to that state, lifted from the Hilbert space designated by QUBITS. QUBITS should be a NAT-TUPLE of qubits representing the Hilbert space.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-inner-matrix-multiply-code (n matrix column result)

Generate N x N matrix multiplication code.

MATRIX should either be:

- a symbol which should (eventually) be bound to a QUANTUM-OPERATOR object.

- a QUANTUM-OPERATOR.

COLUMN should be a list of symbols all of which should (eventually) be bound to the vector being multiplied.

RESULT should be a list of SETF-able forms to which the result will be assigned.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-kraus-ops (standard-matrices probs)

Builds a list of kraus operators from the base matrices in STANDARD-MATRICES, each scaled by a corresponding probability in PROBS.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: generate-permutation-gate-application-code (qubits permutation)

Generate a lambda form which takes one argument, a QUANTUM-STATE, which efficiently applies a permuting operator to that state, lifted from the Hilbert space designated by QUBITS.

PERMUTATION should be the permutation representation of that operator.

QUBITS should be a NAT-TUPLE of qubits representing the Hilbert space.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-permutation-gate-code (permutation accessors)

Given a list of accessor forms ACCESSORS, generate a form which permutes those according to the permutation PERMUTATION.

This function is used to permute wavefunction amplitudes.

Package

qvm.

Source

compile-gate.lisp.

Function: generate-single-qubit-measurement-code (qubit &key dotimes-iterator)

Generate a lambda expression which takes a wavefunction and non-deterministically measures QUBIT. The lambda will mutate the wavefunction and return the bit measured.

DOTIMES-ITERATOR controls which style of DOTIMES is used.

Package

qvm.

Source

compile-gate.lisp.

Function: getpagesize ()
Package

qvm.

Source

shm.lisp.

Function: gray-bit (n)

Let G(n) be the Nth number in Gray code order with G(0) = 0, i.e., GRAY-ENCODE. Then (G (1+ n)) == (LOGXOR (G n) (ASH 1 (GRAY-BIT n))).

Package

qvm.

Source

utilities.lisp.

Function: gray-encode (n)

Compute the Nth Gray code.

Package

qvm.

Source

utilities.lisp.

Function: half (x)

Compute the floor of half of the real number X.

Package

qvm.

Source

utilities.lisp.

Function: index-to-address (index qubit state)

Given an amplitude index INDEX, find the amplitude address for the INDEX’th basis state with QUBIT in the STATE state.

Specifically, given an integer whose bit string is

INDEX = LLLLRRRR,

compute the address

Result = LLLL{0,1}RRRR

which is the index with a {1, 0} injected at the QUBIT’th position.

Package

qvm.

Source

wavefunction.lisp.

Function: initialize-random-state ()

Initialize the active MT19937 random state using the current time.

Package

qvm.

Source

utilities.lisp.

Function: inject-bit (x n)

Inject a 0 at the nth position. Example:

(INJECT-BIT #b1111 1) => #b11101

Package

qvm.

Source

utilities.lisp.

Function: inject-bit-code (n)
Package

qvm.

Source

utilities.lisp.

Function: insert-amplitudes (wavefunction column qubits starting-address)

Given a column vector of amplitudes COLUMN representing the qubits QUBITS, insert this state back into WAVEFUNCTION.

Package

qvm.

Source

wavefunction.lisp.

Function: install-gates (qvm program)

Install the gates specified by the program PROGRAM into the QVM.

This will not clear previously installed gates from the QVM.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: join-subsystems (ss1 ss2)

Join two (disjoint) qubit subsystems SS1 and SS2 into a larger qubit subsystem.

Package

qvm.

Source

subsystem.lisp.

Function: kraus-list (%0)
Package

qvm.

Source

linear-algebra.lisp.

Reader: kraus-list%0 (instance)
Package

qvm.

Source

linear-algebra.lisp.

Target Slot

%0.

Function: kronecker-multiply (a b)

Compute the Kronecker product of matrices A and B.

Package

qvm.

Source

linear-algebra.lisp.

Function: list-classical-states (classical-state qubits)

List all of the bitstring states in the order that QUBITS are specified, using CLASSICAL-STATE as the base state.

Package

qvm.

Source

path-simulate.lisp.

Function: loaded-program-length (qvm)

Number of executable instructions in the program loaded into the QVM.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: lookup-gate (qvm gate &key error)

Look up the definition of the gate named GATE (a symbol or string) within the QVM. Return NIL if not found.

If ERROR is T, then signal an error when the gate wasn’t found.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: make-clifford-application (clifford &rest qubits)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: make-lisp-cflonum-vector (length)
Package

qvm.

Source

allocator.lisp.

Function: make-mixed-state-qvm (num-qubits &key allocation &allow-other-keys)

Build a MIXED-STATE-QVM with a DENSITY-MATRIX-STATE representing NUM-QUBITS qubits.

Package

qvm.

Source

mixed-state-qvm.lisp.

Function: make-pauli-perturbed-1q-gate (gate-name px py pz)

Generate a Kraus map that represents a noisy version of the standard gate U identified by GATE-NAME. The resulting gate is equivalent to I’ * U, i.e., the ideal gate U followed by a noisy identity gate I’ as defined in MAKE-PAULI-NOISE-MAP.

Package

qvm.

Source

noisy-qvm.lisp.

Function: make-posix-shared-memory (name size)

Allocate POSIX shared memory, named by NAME whose size is at least SIZE octets. (It will be rounded to the next multiple of a page.)

Return a POSIX-SHARED-MEMORY object.

Package

qvm.

Source

shm.lisp.

Function: make-shared-array (name length element-type)

Return an array allocated to shared memory, along with a thunk which releases this memory.

Package

qvm.

Source

shm.lisp.

Function: make-stabilizer-qvm (num-qubits &key classical-memory-model)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: make-subsystem (&key state qubits)
Package

qvm.

Source

subsystem.lisp.

Function: make-subsystem-on-qubits (&rest qubits)

Make a subsystem (in the zero-state) for the qubits QUBITS.

Note: Duplicate qubits are ignored.

Package

qvm.

Source

subsystem.lisp.

Function: make-vector-from-pointer (pointer num-elements element-type)
Package

qvm.

Source

shm.lisp.

Function: map-classical-state (instruction classical-state)

Map the classical state CLASSICAL-STATE to its component amplitudes under the transformation dictated by the Quil instruction INSTRUCTION, which should be a gate application.

Return two values:

1. A list of the classical states that this state maps to.

2. A list of complex amplitude factors associated with those states.

Package

qvm.

Source

path-simulate.lisp.

Function: map-complement (function n qubits)

An optimized call to

(MAP-REORDERED-AMPLITUDES 0 FUNCTION (NAT-TUPLE-COMPLEMENT N QUBITS))

up to amplitude ordering.

Package

qvm.

Source

wavefunction.lisp.

Function: map-complement-in-parallel (function n qubits)

A parallel version of #’MAP-COMPLEMENT, when the number of qubits is large enough.

Package

qvm.

Source

wavefunction.lisp.

Function: map-complement-in-parallel-truly (function n qubits)

A parallel version of #’MAP-COMPLEMENT.

Package

qvm.

Source

wavefunction.lisp.

Function: map-reordered-amplitudes (starting-address function qubits)

Iterate through all variations of the amplitude address STARTING-ADDRESS, varying the qubits specified by the tuple QUBITS. For each newly loaded address, call the function FUNCTION.

FUNCTION should be a binary function, and will receive (1) an index running from 0 below 2^|qubits|, and (2) the varied amplitude address.

Package

qvm.

Source

wavefunction.lisp.

Function: map-reordered-amplitudes-in-parallel (starting-address function qubits)

Parallel version of #’MAP-REORDERED-AMPLITUDES, when the number of qubits is large enough.

Package

qvm.

Source

wavefunction.lisp.

Function: map-reordered-amplitudes-in-parallel-truly (starting-address function qubits)

Parallel version of #’MAP-REORDERED-AMPLITUDES.

Package

qvm.

Source

wavefunction.lisp.

Function: map-subdivisions (f total num-ranges)

Call the function F on the endpoints of NUM-RANGES half-open (on the right) intervals whose union is [0, TOTAL). The signature of F should be

START * END -> NIL.

Package

qvm.

Source

utilities.lisp.

Function: matmul2 (matrix0 column1 result2)
Package

qvm.

Source

linear-algebra.lisp.

Function: matmul4 (matrix0 column1 result2)
Package

qvm.

Source

linear-algebra.lisp.

Function: matmul8 (matrix0 column1 result2)
Package

qvm.

Source

linear-algebra.lisp.

Function: matrix-multiply (matrix column)

Compute the product of the complex matrix (represented as a square array of CFLONUMs) and a complex vector (represented as a CFLONUM vector) in-place.

Package

qvm.

Source

linear-algebra.lisp.

Function: matrix-multiply-code (n matrix column result)

Generate code to compute the product of the N x N complex matrix (represented as a square array of CFLONUMs) and a length-N complex column vector (represented as a CFLONUM vector).

Package

qvm.

Source

linear-algebra.lisp.

Function: measure-and-store (qam q c)

Performs a measurement on the qubit addressed by Q in the quantum abstract machine QAM, and stores the measured bit in the classical bit addressed by C.

Return two values:

1. The resulting QAM.
2. The measured classical bit.

Package

qvm.

Source

qam.lisp.

Function: measure-chain-at (i code)

Is there a measure chain at I in CODE?

Package

qvm.

Source

compile-gate.lisp.

Function: measure-chain-to-instruction (chain)

Convert a measure chain into a MEASURE-ALL pseudo-instruction.

Package

qvm.

Source

compile-gate.lisp.

Reader: memory-pointer (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

pointer.

Function: memory-view (root-classical-memory &key length reader writer aliasing-memory)
Package

qvm.

Source

classical-memory.lisp.

Reader: memory-view-aliasing-classical-memory (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

aliasing-classical-memory.

Function: memory-view-classical-memory (mv)

Return the CLASSICAL-MEMORY that can be read to/written from as viewed by MEMORY-VIEW.

Package

qvm.

Source

classical-memory.lisp.

Reader: memory-view-length (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

length.

Function: memory-view-p (object)
Package

qvm.

Source

classical-memory.lisp.

Reader: memory-view-reader (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

reader.

Function: memory-view-ref (mv i)
Package

qvm.

Source

classical-memory.lisp.

Function: (setf memory-view-ref) (mv i)
Package

qvm.

Source

classical-memory.lisp.

Reader: memory-view-root-classical-memory (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

root-classical-memory.

Reader: memory-view-writer (instance)
Package

qvm.

Source

classical-memory.lisp.

Target Slot

writer.

Function: midpoint (a b)

Find the midpoint of two non-negative fixnums A and B where A <= B.

Package

qvm.

Source

measurement.lisp.

Function: mixed-state-qvm-measurement-probabilities (qvm)

Computes the probability distribution of measurement outcomes (a vector) associated with the STATE of the DENSITY-QVM.

Package

qvm.

Source

mixed-state-qvm.lisp.

Function: naive-measure-all (qam)
Package

qvm.

Source

measurement.lisp.

Function: nat-tuple (&rest elements)

Create a new nat tuple with the elements ELEMENTS (each of type NAT-TUPLE-ELEMENT).

Package

qvm.

Source

utilities.lisp.

Function: nat-tuple-cardinality (nt)

Compute the number of elements in the nat tuple NT.

Package

qvm.

Source

utilities.lisp.

Function: nat-tuple-complement (n nt)

Compute the complement of the nat tuple NT in a universe of (0 1 2 ... N-1).

Package

qvm.

Source

utilities.lisp.

Function: nat-tuple-position (nt elt)

In what position is ELT in the nat-tuple NT?

Package

qvm.

Source

utilities.lisp.

Function: nat-tuple-ref (nt i)

Extract the Ith element of the nat-tuple NT.

Package

qvm.

Source

utilities.lisp.

Function: nop-count (code)

Number of NOPs in a vector of instructions CODE.

Package

qvm.

Source

execution.lisp.

Function: norm (wavefunction)

Compute the length/L2 norm of the wavefunction WAVEFUNCTION.

Package

qvm.

Source

wavefunction.lisp.

Function: not-predicate-name (name)

Returns the concatenated predicate name !NAME

Package

qvm.

Source

noise-models.lisp.

Function: or-predicate-names (name1 name2)

Returns the concatenated predicate name NAME1|NAME2

Package

qvm.

Source

noise-models.lisp.

Function: outer-multiply (u v)

Compute the outer product of two equally-sized column vectors U and V (specifically UV^dagger).

Package

qvm.

Source

linear-algebra.lisp.

Function: permutation-to-transpositions (permutation)

Decompose a permutation PERMUTATION represented as a sequence of non-negative integers into a list of transpositions represented as conses.

Package

qvm.

Source

compile-gate.lisp.

Function: perturb-measured-bits (qvm measured-bits readout-povms)

Randomly perturb the values of the bits in MEASURED-BITS in accordance with any available readout POVMs on the QVM. Returns an updated list of measured bits.

Package

qvm.

Source

measurement.lisp.

Function: perturb-measurement (actual-outcome p00 p01 p10 p11)

Given the readout error encoded in the assignment probabilities P00, P01, P10, P11, randomly sample the observed (potentially corrupted) measurement outcome.

Package

qvm.

Source

channel-qvm.lisp.

Function: posix-shared-memory-finalizer (shm)

Return a thunk suitable to releasing the memory associated with the POSIX-SHARED-MEMORY object SHM.

Package

qvm.

Source

shm.lisp.

Reader: posix-shared-memory-name (instance)
Writer: (setf posix-shared-memory-name) (instance)
Package

qvm.

Source

shm.lisp.

Target Slot

name.

Function: posix-shared-memory-p (object)
Package

qvm.

Source

shm.lisp.

Reader: posix-shared-memory-pointer (instance)
Writer: (setf posix-shared-memory-pointer) (instance)
Package

qvm.

Source

shm.lisp.

Target Slot

pointer.

Reader: posix-shared-memory-size (instance)
Writer: (setf posix-shared-memory-size) (instance)
Package

qvm.

Source

shm.lisp.

Target Slot

size.

Function: power-of-two-p (n)

Is N equal to some non-negative integer power of two?

Package

qvm.

Source

utilities.lisp.

Function: psum (f state)

Compute the sum of F(X) for X in STATE, in parallel. F should be a unary function mapping CFLONUMs to FLONUMs.

Package

qvm.

Source

linear-algebra.lisp.

Function: pull-teeth-to-get-a-gate (gate-app)

Produce a valid, applicable gate from the application GATE-APPLICATION.

Package

qvm.

Source

compile-gate.lisp.

Function: (setf qubit-depolarization) (qvm qubit)

Save the DEPOLARIZATION-PROBABILITY for QUBIT. The depolarizing channel represents the average gate over-rotation/under-rotation noise. It is specified by DEPOLARIZATION-PROBABILITY, which is the probability of overrotation/underrotation for the given QUBIT.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: (setf qubit-fro) (qvm qubit)

Save the readout POVMs for the FRO on the specified QUBIT on the QVM. The FRO is assumed to be the average readout fidelity (avg of p(1|1) and p(0|0)) so as an approximation, we set p(0|0) = p(1|1) = fR0 in the READOUT-POVMS assignment probabilities.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: qubit-limit-for-using-serial-kernels ()

The maximum number of qubits allowed in order to use a specified serial kernel. The value of this function also takes into account *QUBITS-REQUIRED-FOR-PARALLELIZATION*.

Package

qvm.

Source

config.lisp.

Function: (setf qubit-povm) (noise-model qubit)

Set the POVM for a QUBIT in this NOISE-MODEL.

Package

qvm.

Source

noise-models.lisp.

Function: (setf qubit-t1) (qvm qubit)

Evaluate that T1 is valid, and save it for the specified QUBIT in the QVM.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: (setf qubit-t2) (qvm qubit)

Evaluate that T2 is valid and save it for the specified QUBIT in the QVM.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: (setf qubit-tphi) (qvm qubit)

Evaluate that TPHI is valid and save it for the specified QUBIT in the QVM.

Package

qvm.

Source

basic-noise-qvm.lisp.

Function: quil-name (type-name)
Package

qvm.

Source

classical-memory.lisp.

Function: random-clifford-program (length max-clifford-arity num-qubits &key measure)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: random-qubits (num-qubits max-qubit)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: random-range (a b)
Package

qvm.

Source

stabilizer-qvm.lisp.

Function: randomize-wavefunction (wavefunction)

Randomize the elements of WAVEFUNCTION resulting in a valid complex unit vector.

Package

qvm.

Source

wavefunction.lisp.

Function: reset-classical-memory (qvm)

Zero out all of the classical memory of the qvm QVM.

Package

qvm.

Source

classical-memory-mixin.lisp.

Function: root-memory-view-p (mv)

Is the MEMORY-VIEW MV a root memory?

Package

qvm.

Source

classical-memory.lisp.

Function: round-to-next-page (size)
Package

qvm.

Source

shm.lisp.

Function: round-up-to-next-multiple (x multiple)

Round X up to the next multiple of MULTIPLE.

Package

qvm.

Source

utilities.lisp.

Function: rule-matches-instr-p (rule instr position)

Check if RULE is matched by instruction data INSTR and the POSITION of the match request.

Package

qvm.

Source

channel-qvm.lisp.

Function: rule-priority>= (rule1 rule2)

Comparator function for the PRIORITY of 2 noise rules. Returns true if the priority of R1 is >= to the priority of R2.

Package

qvm.

Source

noise-models.lisp.

Function: sample-wavefunction-as-distribution (wf ps)

Implementation of SAMPLE-WAVEFUNCTION-AS-DISTRIBUTION-IN-PARALLEL-TRULY, un-parallelized, but for every probability in the PS (type: (VECTOR FLONUM)). Return a
vector of sampled amplitude addresses.

Package

qvm.

Source

measurement.lisp.

Function: sample-wavefunction-as-distribution-in-parallel (wf p)
Package

qvm.

Source

measurement.lisp.

Function: sample-wavefunction-as-distribution-in-parallel-truly (wf p)

Sample the wavefunction as if it was a probability distribution.

Specifically, let C(b) = sum_{k=0}^{b} |wf[k]|^2. Compute the smallest b’ such that C(b’) > p.

Package

qvm.

Source

measurement.lisp.

Function: sample-wavefunction-multiple-times (wf num-samples)

Produce NUM-SAMPLES bitstring samples of the wavefunction WF according to its interpretation as a probability distribution.

Package

qvm.

Source

measurement.lisp.

Function: set-qubit-components-of-amplitude-address (address flags qubits)

Set the amplitude address to the bits within the non-negative integer FLAGS for the corresponding tuple of qubit indices QUBITS. (Ordered LSB to MSB.)

Package

qvm.

Source

wavefunction.lisp.

Package

qvm.

Source

shm.lisp.

Function: shm-vector-allocation-size (num-elements element-type)

Return the size, in octets, needed to store a simple-array of NUM-ELEMENTS ELEMENT-TYPE objects.

Package

qvm.

Source

impl/sbcl.lisp.

Function: shm-vector-from-pointer (pointer num-elements element-type)

Return two values: a specialized vector of NUM-ELEMENTS for ELEMENT-TYPE created at POINTER, and a finalizer that is called to clean up that vector.

Package

qvm.

Source

impl/sbcl.lisp.

Function: shm-vector-header-size ()
Package

qvm.

Source

impl/sbcl.lisp.

Function: simple-array-allocation-size (num-elements element-type)
Package

qvm.

Source

shm.lisp.

Function: single-kraus (%0)
Package

qvm.

Source

linear-algebra.lisp.

Reader: single-kraus%0 (instance)
Package

qvm.

Source

linear-algebra.lisp.

Target Slot

%0.

Function: size-of (type-name)

The size of a type in octets.

Package

qvm.

Source

classical-memory.lisp.

Function: slurp-memory (memory)

Slurp all of the memory of MEMORY into a vector.

Package

qvm.

Source

classical-memory.lisp.

Function: subdivide (total num-ranges)

Subdivide TOTAL (probably representing a vector length) into NUM-RANGES as-equal-as-possible ranges.

The result will be a list of cons cells representing half-open intervals (on the right) whose union is [0, total).

Package

qvm.

Source

utilities.lisp.

Function: subsystem-contains-qubit-p (ss qubit)

Does the subsystem SS contain the qubits QUBIT?

Package

qvm.

Source

subsystem.lisp.

Function: subsystem-contains-qubits-p (ss qubit-set)

Does the subsystem SS contain the qubits designated by the bit-set QUBIT-SET?

Package

qvm.

Source

subsystem.lisp.

Function: subsystem-num-qubits (ss)

How many qubits does the subsystem SS represent?

Package

qvm.

Source

subsystem.lisp.

Function: subsystem-physical-to-logical-qubit (ss phys-qubit)

What logical qubit number does the physical qubit PHYS-QUBIT have in the subsystem SS?

(The "logical qubit" is the relative position of the qubit in the system.)

Package

qvm.

Source

subsystem.lisp.

Reader: subsystem-qubits (instance)
Package

qvm.

Source

subsystem.lisp.

Target Slot

qubits.

Reader: subsystem-state (instance)
Package

qvm.

Source

subsystem.lisp.

Target Slot

state.

Function: subsystemp (object)
Package

qvm.

Source

subsystem.lisp.

Function: superoperator-to-component-matrices (sop)

Convert SOP into a MAGICL:MATRIX or a LIST of them.

Package

qvm.

Source

linear-algebra.lisp.

Function: sysconf (name)
Package

qvm.

Source

utilities.lisp.

Function: tr (m)

Compute the trace of M.

Package

qvm.

Source

linear-algebra.lisp.

Function: typed-reader/writer (ty)
Package

qvm.

Source

classical-memory.lisp.

Function: warning-wait-function (qvm)
Package

qvm.

Source

classical-memory-mixin.lisp.

Function: wavefunction-qubits (wavefunction)

The number of qubits represented by the wavefunction WAVEFUNCTION.

Package

qvm.

Source

wavefunction.lisp.


5.2.5 Generic functions

Generic Writer: %set-state (new-value object)
Package

qvm.

Methods
Writer Method: %set-state ((new-value mixed-state-qvm) mixed-state-qvm)

automatically generated writer method

Source

mixed-state-qvm.lisp.

Target Slot

state.

Writer Method: %set-state ((new-value pure-state-qvm) pure-state-qvm)

The unpermuted wavefunction in standard order.

Source

qvm.lisp.

Target Slot

state.

Writer Method: %set-state ((new-value base-qvm) base-qvm)

The state of the quantum system simulated by the QVM.

Source

qvm.lisp.

Target Slot

state.

Generic Function: %trial-amplitudes (object)
Package

qvm.

Methods
Method: %trial-amplitudes ((qvm noisy-qvm))
Source

noisy-qvm.lisp.

Reader Method: %trial-amplitudes ((pure-state pure-state))

A second wavefunction used when applying a noisy quantum channel. Applying a Kraus map generally requires evaluating psi_j = K_j * psi for several different j, making it necessary to keep the original wavefunction around. This value should be a QUANTUM-STATE whose size is compatible with the number of qubits of the CHANNEL-QVM. The actual values can be initialized in any way because they will be overwritten. As such, it merely is scratch space for intermediate computations, and hence should not be otherwise directly accessed.

Source

state-representation.lisp.

Target Slot

trial-amplitudes.

Generic Writer: (setf %trial-amplitudes) (object)
Package

qvm.

Methods
Writer Method: (setf %trial-amplitudes) ((pure-state pure-state))

A second wavefunction used when applying a noisy quantum channel. Applying a Kraus map generally requires evaluating psi_j = K_j * psi for several different j, making it necessary to keep the original wavefunction around. This value should be a QUANTUM-STATE whose size is compatible with the number of qubits of the CHANNEL-QVM. The actual values can be initialized in any way because they will be overwritten. As such, it merely is scratch space for intermediate computations, and hence should not be otherwise directly accessed.

Source

state-representation.lisp.

Target Slot

trial-amplitudes.

Generic Reader: allocation (object)
Package

qvm.

Methods
Reader Method: allocation ((quantum-system-state quantum-system-state))

automatically generated reader method

Source

state-representation.lisp.

Target Slot

allocation.

Generic Reader: allocation-name (object)
Package

qvm.

Methods
Reader Method: allocation-name ((posix-shared-memory-allocation posix-shared-memory-allocation))

automatically generated reader method

Source

allocator.lisp.

Target Slot

name.

Generic Function: amplitudes (object)
Package

qvm.

Methods
Method: amplitudes ((qvm noisy-qvm))
Source

noisy-qvm.lisp.

Method: amplitudes ((qvm density-qvm))
Source

density-qvm.lisp.

Method: amplitudes ((qvm base-qvm))
Source

qvm.lisp.

Reader Method: amplitudes ((pure-state pure-state))

The wavefunction of a pure state.

Source

state-representation.lisp.

Target Slot

amplitudes.

Generic Function: (setf amplitudes) (object)
Package

qvm.

Methods
Method: (setf amplitudes) ((qvm noisy-qvm))
Source

noisy-qvm.lisp.

Method: (setf amplitudes) (qvm)
Source

density-qvm.lisp.

Method: (setf amplitudes) ((qvm base-qvm))
Source

qvm.lisp.

Writer Method: (setf amplitudes) ((pure-state pure-state))

The wavefunction of a pure state.

Source

state-representation.lisp.

Target Slot

amplitudes.

Generic Function: apply-all-kraus-maps (qvm instr kraus-maps)

Apply every kraus map in the list KRAUS-MAPS to the state of the system.

Package

qvm.

Source

channel-qvm.lisp.

Methods
Method: apply-all-kraus-maps ((qvm basic-noise-qvm) (instr gate-application) kraus-ops)
Source

basic-noise-qvm.lisp.

Method: apply-all-kraus-maps ((qvm channel-qvm) (instr gate-application) kraus-maps)
Generic Function: apply-classical-readout-noise (qvm instr)

Given a QVM and a (measurement) instruction INSTR, corrupt the readout bit according to the POVM specifications of QVM.

Package

qvm.

Source

channel-qvm.lisp.

Methods
Method: apply-classical-readout-noise ((qvm noisy-qvm) (instr compiled-measurement))
Source

noisy-qvm.lisp.

Method: apply-classical-readout-noise ((qvm noisy-qvm) (instr measure))
Source

noisy-qvm.lisp.

Method: apply-classical-readout-noise ((qvm noisy-qvm) (instr measure-discard))
Source

noisy-qvm.lisp.

Method: apply-classical-readout-noise ((qvm density-qvm) (instr measure-discard))
Source

density-qvm.lisp.

Method: apply-classical-readout-noise ((qvm density-qvm) (instr measure))
Source

density-qvm.lisp.

Method: apply-classical-readout-noise ((qvm basic-noise-qvm) (instr measure-discard))
Source

basic-noise-qvm.lisp.

Method: apply-classical-readout-noise ((qvm basic-noise-qvm) (instr compiled-measurement))
Source

basic-noise-qvm.lisp.

Method: apply-classical-readout-noise ((qvm basic-noise-qvm) (instr measure))
Source

basic-noise-qvm.lisp.

Method: apply-classical-readout-noise ((qvm channel-qvm) (instr measure-discard))
Method: apply-classical-readout-noise ((qvm channel-qvm) (instr measure))
Method: apply-classical-readout-noise ((qvm channel-qvm) (instr compiled-measurement))
Generic Function: apply-kraus-map (qvm instr kraus-ops)

Apply noise from a kraus map KRAUS-OPS to the system. Randomly select a kraus operator from KRAUS-OPS using inverse transform sampling to apply to the STATE of the QVM system.

Package

qvm.

Source

channel-qvm.lisp.

Generic Function: apply-measure-discard-to-state (qvm state instr)
Package

qvm.

Methods
Method: apply-measure-discard-to-state (qvm (state density-matrix-state) (instr measure-discard))
Source

measurement.lisp.

Method: apply-measure-discard-to-state (qvm (state pure-state) (instr measure-discard))
Source

measurement.lisp.

Generic Reader: avg-gate-time (object)
Package

qvm.

Methods
Reader Method: avg-gate-time ((basic-noise-qvm basic-noise-qvm))

To calculate the kraus operators for T1, T2, etc. noise, a gate time value is needed. Ideally, this gate time should be the duration of the gate preceding the application of the kraus noise. As an approximation, this value should represent the average gate time of the gates that will be run.

Source

basic-noise-qvm.lisp.

Target Slot

avg-gate-time.

Generic Function: check-allocate-computation-space (state)
Package

qvm.

Methods
Method: check-allocate-computation-space ((state density-matrix-state))
Source

state-representation.lisp.

Method: check-allocate-computation-space ((state pure-state))
Source

state-representation.lisp.

Generic Function: classical-memories (object)
Package

qvm.

Methods
Method: classical-memories ((qvm classical-memory-mixin))
Source

classical-memory-mixin.lisp.

Reader Method: classical-memories ((classical-memory-subsystem classical-memory-subsystem))

A table mapping names to allocated memories.

Source

classical-memory.lisp.

Target Slot

classical-memories.

Generic Function: classical-memory-model (object)
Package

qvm.

Methods
Method: classical-memory-model ((qvm classical-memory-mixin))
Source

classical-memory-mixin.lisp.

Reader Method: classical-memory-model ((classical-memory-subsystem classical-memory-subsystem))

A description of the structure of the memory of the abstract machine.

Source

classical-memory.lisp.

Target Slot

classical-memory-model.

Generic Reader: clifford-application-clifford (object)
Package

qvm.

Methods
Reader Method: clifford-application-clifford ((clifford-application clifford-application))

automatically generated reader method

Source

stabilizer-qvm.lisp.

Target Slot

clifford.

Generic Function: compile-instruction (qvm isn)

Compile the instruction ISN to some more efficient representation, if possible. May return the same ISN back.

Package

qvm.

Source

compile-gate.lisp.

Methods
Method: compile-instruction ((qvm noisy-qvm) isn)
Source

noisy-qvm.lisp.

Method: compile-instruction ((qvm density-qvm) isn)
Source

density-qvm.lisp.

Method: compile-instruction ((qvm channel-qvm) isn)
Source

channel-qvm.lisp.

Method: compile-instruction ((qvm pure-state-qvm) (isn measurement))
Method: compile-instruction (qvm (isn gate-application))
Method: compile-instruction (qvm (isn compiled-instruction))
Method: compile-instruction (qvm isn)
Method: compile-instruction ((qvm mixed-state-qvm) isn)
Source

mixed-state-qvm.lisp.

Generic Function: compile-loaded-program (qam)

Compile the program loaded into the qam QAM so as to optimize execution.

Package

qvm.

Source

qam.lisp.

Methods
Method: compile-loaded-program ((qvm depolarizing-qvm))
Source

depolarizing-noise.lisp.

Method: compile-loaded-program ((qvm noisy-qvm))
Source

noisy-qvm.lisp.

Method: compile-loaded-program ((qvm density-qvm))
Source

density-qvm.lisp.

Method: compile-loaded-program ((qvm channel-qvm))
Source

channel-qvm.lisp.

Method: compile-loaded-program ((qvm mixed-state-qvm))
Source

mixed-state-qvm.lisp.

Method: compile-loaded-program ((qvm pure-state-qvm))
Source

qvm.lisp.

Generic Function: compile-operator (op qubits parameters)

Compile the operator OP into an efficient representation. Return two values:

1. The class name to instantiate.

2. The COMPILED-GATE-APPLICATION initargs.

If the gate can’t be compiled, return (VALUES NIL NIL).

Package

qvm.

Source

compile-gate.lisp.

Methods
Method: compile-operator ((op permutation-gate) qubits parameters)
Method: compile-operator ((op parameterized-gate) qubits parameters)
Method: compile-operator ((op simple-gate) qubits parameters)
Method: compile-operator (op qubits parameters)
Generic Reader: compiled-gate-apply-operator (object)
Package

qvm.

Methods
Reader Method: compiled-gate-apply-operator ((compiled-gate-application compiled-gate-application))

The operator (a FUNCTION) which, at least as one of its arguments, modifies the wavefunction.

Source

compile-gate.lisp.

Target Slot

apply-operator.

Generic Reader: compiled-matrix (object)
Package

qvm.

Methods
Reader Method: compiled-matrix ((compiled-inlined-matrix-gate-application compiled-inlined-matrix-gate-application))

The (static) matrix represented by this application.

Source

compile-gate.lisp.

Target Slot

gate-matrix.

Reader Method: compiled-matrix ((compiled-matrix-gate-application compiled-matrix-gate-application))

The (static) matrix represented by this application.

Source

compile-gate.lisp.

Target Slot

gate-matrix.

Generic Function: conjugate-entrywise (gate)

Construct a new gate from GATE with corresponding matrix entries conjugated.

Package

qvm.

Source

linear-algebra.lisp.

Methods
Method: conjugate-entrywise ((gate simple-gate))
Method: conjugate-entrywise ((gate permutation-gate))
Method: conjugate-entrywise ((gate parameterized-gate))
Generic Reader: depolarization-ops (object)
Generic Writer: (setf depolarization-ops) (object)
Package

qvm.

Methods
Reader Method: depolarization-ops ((basic-noise-qvm basic-noise-qvm))
Writer Method: (setf depolarization-ops) ((basic-noise-qvm basic-noise-qvm))

A hash table of qubit to depolarization operators, representing gate application noise. Gate over-rotations and under-rotations average out to the depolarizing channel.

Source

basic-noise-qvm.lisp.

Target Slot

depolarization-ops.

Generic Reader: elapsed-time (object)
Generic Writer: (setf elapsed-time) (object)
Package

qvm.

Methods
Reader Method: elapsed-time ((basic-noise-qvm basic-noise-qvm))
Writer Method: (setf elapsed-time) ((basic-noise-qvm basic-noise-qvm))

A value to keep track of the elpased time of the program. The elapsed time is used for calculating the kraus operators of some noise value at a given point in the program.

Source

basic-noise-qvm.lisp.

Target Slot

elapsed-time.

Generic Reader: elements-vector (object)
Package

qvm.

Methods
Reader Method: elements-vector ((density-matrix-state density-matrix-state))

The contents of a density matrix ρ as a one-dimensional vector. For a state of N qubits, this vector should be of length 2^(2*N).

Source

state-representation.lisp.

Target Slot

elements-vector.

Generic Function: (setf elements-vector) (object)
Package

qvm.

Methods
Writer Method: (setf elements-vector) :after ((state density-matrix-state))
Source

state-representation.lisp.

Target Slot

elements-vector.

Method: (setf elements-vector) ((density-matrix-state density-matrix-state))

The contents of a density matrix ρ as a one-dimensional vector. For a state of N qubits, this vector should be of length 2^(2*N).

Source

state-representation.lisp.

Generic Reader: gate-definitions (object)
Generic Writer: (setf gate-definitions) (object)
Package

qvm.

Methods
Reader Method: gate-definitions ((classical-memory-mixin classical-memory-mixin))
Writer Method: (setf gate-definitions) ((classical-memory-mixin classical-memory-mixin))

A table mapping gate names to their GATE-instance definition.

Source

classical-memory-mixin.lisp.

Target Slot

gate-definitions.

Generic Function: get-excited-state-probability (state qubit)

Get the excited state probability from the wavefunction (if PURE-STATE) or density matrix (if DENSITY-MATRIX-STATE).

Package

qvm.

Source

measurement.lisp.

Methods
Method: get-excited-state-probability ((state pure-state) qubit)
Method: get-excited-state-probability ((state density-matrix-state) qubit)
Generic Reader: matrix-view (object)
Package

qvm.

Methods
Reader Method: matrix-view ((density-matrix-state density-matrix-state))

2D array displaced to ELEMENTS-VECTOR

Source

state-representation.lisp.

Target Slot

matrix-view.

Generic Function: measure-all-state (state qvm)

The protocol for MEASURE-ALL differs by the STATE type of the QVM.

Package

qvm.

Source

measurement.lisp.

Methods
Method: measure-all-state ((state density-matrix-state) (qvm basic-noise-qvm))
Source

basic-noise-qvm.lisp.

Method: measure-all-state ((state pure-state) (qvm basic-noise-qvm))
Source

basic-noise-qvm.lisp.

Method: measure-all-state ((state density-matrix-state) (qvm channel-qvm))
Source

channel-qvm.lisp.

Method: measure-all-state ((state pure-state) (qvm channel-qvm))
Source

channel-qvm.lisp.

Method: measure-all-state ((state density-matrix-state) (qvm base-qvm))
Method: measure-all-state ((state pure-state) (qvm base-qvm))
Generic Reader: measure-all-storage (object)
Package

qvm.

Methods
Reader Method: measure-all-storage ((measure-all measure-all))

A list of qubit-mref pairs to store, in order.

Source

compile-gate.lisp.

Target Slot

storage.

Generic Reader: noisy-gate-definitions (object)
Package

qvm.

Methods
Reader Method: noisy-gate-definitions ((noisy-qvm noisy-qvm))

Noisy gate definitions that, if present, override those stored in GATE-DEFINITIONS.

Source

noisy-qvm.lisp.

Target Slot

noisy-gate-definitions.

Reader Method: noisy-gate-definitions ((density-qvm density-qvm))

automatically generated reader method

Source

density-qvm.lisp.

Target Slot

noisy-gate-definitions.

Generic Writer: (setf noisy-gate-definitions) (object)
Package

qvm.

Methods
Writer Method: (setf noisy-gate-definitions) ((noisy-qvm noisy-qvm))

Noisy gate definitions that, if present, override those stored in GATE-DEFINITIONS.

Source

noisy-qvm.lisp.

Target Slot

noisy-gate-definitions.

Writer Method: (setf noisy-gate-definitions) ((density-qvm density-qvm))

automatically generated writer method

Source

density-qvm.lisp.

Target Slot

noisy-gate-definitions.

Generic Function: num-qubits (state)

Return the number of qubits represented by the STATE.

Package

qvm.

Source

state-representation.lisp.

Methods
Method: num-qubits ((state density-matrix-state))
Method: num-qubits ((state pure-state))
Generic Reader: oob-from (condition)
Package

qvm.

Methods
Reader Method: oob-from ((condition memory-index-out-of-bounds))
Source

classical-memory.lisp.

Target Slot

from.

Generic Reader: oob-index (condition)
Package

qvm.

Methods
Reader Method: oob-index ((condition memory-index-out-of-bounds))
Source

classical-memory.lisp.

Target Slot

index.

Generic Reader: oob-name (condition)
Package

qvm.

Methods
Reader Method: oob-name ((condition memory-index-out-of-bounds))
Source

classical-memory.lisp.

Target Slot

name.

Generic Reader: oob-to (condition)
Package

qvm.

Methods
Reader Method: oob-to ((condition memory-index-out-of-bounds))
Source

classical-memory.lisp.

Target Slot

to.

Generic Reader: operation-elements (object)
Package

qvm.

Methods
Reader Method: operation-elements ((noise-rule noise-rule))

A list of kraus maps to apply when the rule is matched. Each kraus map is a list of kraus operators.

Source

noise-models.lisp.

Target Slot

operation-elements.

Generic Reader: original-amplitudes (object)
Package

qvm.

Methods
Reader Method: original-amplitudes ((pure-state pure-state))

A reference to the original pointer of amplitude memory, so the amplitudes can sit in the right place at the end of a computation.

Source

state-representation.lisp.

Target Slot

original-amplitudes.

Generic Reader: pc (object)
Generic Writer: (setf pc) (object)
Package

qvm.

Methods
Reader Method: pc ((classical-memory-mixin classical-memory-mixin))
Writer Method: (setf pc) ((classical-memory-mixin classical-memory-mixin))

The program counter.

Source

classical-memory-mixin.lisp.

Target Slot

program-counter.

Generic Reader: probability-gate-x (object)
Generic Writer: (setf probability-gate-x) (object)
Package

qvm.

Methods
Reader Method: probability-gate-x ((depolarizing-qvm depolarizing-qvm))
Writer Method: (setf probability-gate-x) ((depolarizing-qvm depolarizing-qvm))

Probability of a Pauli X gate happening after a gate application or reset.

Source

depolarizing-noise.lisp.

Target Slot

probability-gate-x.

Generic Reader: probability-gate-y (object)
Generic Writer: (setf probability-gate-y) (object)
Package

qvm.

Methods
Reader Method: probability-gate-y ((depolarizing-qvm depolarizing-qvm))
Writer Method: (setf probability-gate-y) ((depolarizing-qvm depolarizing-qvm))

Probability of a Pauli Y gate happening after a gate application or reset.

Source

depolarizing-noise.lisp.

Target Slot

probability-gate-y.

Generic Reader: probability-gate-z (object)
Generic Writer: (setf probability-gate-z) (object)
Package

qvm.

Methods
Reader Method: probability-gate-z ((depolarizing-qvm depolarizing-qvm))
Writer Method: (setf probability-gate-z) ((depolarizing-qvm depolarizing-qvm))

Probability of a Pauli Z gate happening after a gate application or reset.

Source

depolarizing-noise.lisp.

Target Slot

probability-gate-z.

Generic Reader: probability-measure-x (object)
Generic Writer: (setf probability-measure-x) (object)
Package

qvm.

Methods
Reader Method: probability-measure-x ((depolarizing-qvm depolarizing-qvm))
Writer Method: (setf probability-measure-x) ((depolarizing-qvm depolarizing-qvm))

Probability of a Pauli X gate happening before a measurement.

Source

depolarizing-noise.lisp.

Target Slot

probability-measure-x.

Generic Reader: probability-measure-y (object)
Generic Writer: (setf probability-measure-y) (object)
Package

qvm.

Methods
Reader Method: probability-measure-y ((depolarizing-qvm depolarizing-qvm))
Writer Method: (setf probability-measure-y) ((depolarizing-qvm depolarizing-qvm))

Probability of a Pauli Y gate happening before a measurement.

Source

depolarizing-noise.lisp.

Target Slot

probability-measure-y.

Generic Reader: probability-measure-z (object)
Generic Writer: (setf probability-measure-z) (object)
Package

qvm.

Methods
Reader Method: probability-measure-z ((depolarizing-qvm depolarizing-qvm))
Writer Method: (setf probability-measure-z) ((depolarizing-qvm depolarizing-qvm))

Probability of a Pauli Z gate happening before a measurement.

Source

depolarizing-noise.lisp.

Target Slot

probability-measure-z.

Generic Reader: program (object)
Generic Writer: (setf program) (object)
Package

qvm.

Methods
Reader Method: program ((classical-memory-mixin classical-memory-mixin))
Writer Method: (setf program) ((classical-memory-mixin classical-memory-mixin))

The program to be executed.

Source

classical-memory-mixin.lisp.

Target Slot

program.

Generic Reader: program-compiled-p (object)
Generic Writer: (setf program-compiled-p) (object)
Package

qvm.

Methods
Reader Method: program-compiled-p ((base-qvm base-qvm))
Writer Method: (setf program-compiled-p) ((base-qvm base-qvm))

Has the loaded program been compiled?

Source

qvm.lisp.

Target Slot

program-compiled-p.

Generic Reader: projector-operator (object)
Package

qvm.

Methods
Reader Method: projector-operator ((compiled-measurement compiled-measurement))

Projection function which takes a WAVEFUNCTION as an argument and returns the measured bit result.

Source

compile-gate.lisp.

Target Slot

projector-operator.

Generic Reader: readout-povms (object)
Package

qvm.

Methods
Reader Method: readout-povms ((noisy-qvm noisy-qvm))

Noisy readout encoded as diagonal single qubit
POVM given as a 4-element list

(p(0|0) p(0|1)
p(1|0) p(1|1))

which for each qubit gives the probability p(j|k) of measuring outcome j given actual state k. Note that we model purely classical readout error, i.e., the post measurement qubit state is always k, but the recorded outcome j may be different.

Source

noisy-qvm.lisp.

Target Slot

readout-povms.

Reader Method: readout-povms ((density-qvm density-qvm))

automatically generated reader method

Source

density-qvm.lisp.

Target Slot

readout-povms.

Reader Method: readout-povms ((basic-noise-qvm basic-noise-qvm))

A hash-table of qubit idx to a list of povms, representing the readout assignment probabilities (p(0|0) p(0|1) p(1|0) p(1|1)).

Source

basic-noise-qvm.lisp.

Target Slot

readout-povms.

Reader Method: readout-povms ((noise-model noise-model))

A hash table of qubit to readout noise assignment probabilities, given as a 4-element list ((p(0|0) p(0|1) p(1|0) p(1|1)).

Source

noise-models.lisp.

Target Slot

readout-povms.

Generic Writer: (setf readout-povms) (object)
Package

qvm.

Methods
Writer Method: (setf readout-povms) ((noisy-qvm noisy-qvm))

Noisy readout encoded as diagonal single qubit
POVM given as a 4-element list

(p(0|0) p(0|1)
p(1|0) p(1|1))

which for each qubit gives the probability p(j|k) of measuring outcome j given actual state k. Note that we model purely classical readout error, i.e., the post measurement qubit state is always k, but the recorded outcome j may be different.

Source

noisy-qvm.lisp.

Target Slot

readout-povms.

Writer Method: (setf readout-povms) ((density-qvm density-qvm))

automatically generated writer method

Source

density-qvm.lisp.

Target Slot

readout-povms.

Writer Method: (setf readout-povms) ((basic-noise-qvm basic-noise-qvm))

A hash-table of qubit idx to a list of povms, representing the readout assignment probabilities (p(0|0) p(0|1) p(1|0) p(1|1)).

Source

basic-noise-qvm.lisp.

Target Slot

readout-povms.

Writer Method: (setf readout-povms) ((noise-model noise-model))

A hash table of qubit to readout noise assignment probabilities, given as a 4-element list ((p(0|0) p(0|1) p(1|0) p(1|1)).

Source

noise-models.lisp.

Target Slot

readout-povms.

Generic Function: requires-swapping-amps-p (state)

Determine whether the state-elements are in the correct QVM slot after doing a computation that requires the additional space. This is only relevant for a PURE-STATE.

Package

qvm.

Source

state-representation.lisp.

Methods
Method: requires-swapping-amps-p ((state density-matrix-state))
Method: requires-swapping-amps-p ((state pure-state))
Generic Function: reset-quantum-state (qam)

Bring all qubits of the quantum abstract machine QAM to the zero state.

Package

qvm.

Source

qam.lisp.

Methods
Method: reset-quantum-state ((qvm density-qvm))
Source

density-qvm.lisp.

Method: reset-quantum-state ((qvm base-qvm))
Source

qvm.lisp.

Generic Function: set-readout-povm (qvm qubit povm)

For a QUBIT belonging to a QVM specify a POVM to encode possible readout errors.

POVM must be a 4-element list of double-floats.

Package

qvm.

Source

density-qvm.lisp.

Methods
Method: set-readout-povm ((qvm noisy-qvm) qubit povm)
Source

noisy-qvm.lisp.

Method: set-readout-povm ((qvm density-qvm) qubit povm)
Generic Function: set-superoperator (qvm gate-name qubits kraus-ops)
Package

qvm.

Methods
Method: set-superoperator ((qvm base-qvm) gate-name qubits kraus-ops)
Source

qvm.lisp.

Generic Reader: source-gate (object)
Package

qvm.

Methods
Reader Method: source-gate ((compiled-gate-application compiled-gate-application))

The gate object being represented by this application.

Source

compile-gate.lisp.

Target Slot

source-gate.

Generic Reader: source-instruction (object)
Generic Writer: (setf source-instruction) (object)
Package

qvm.

Methods
Reader Method: source-instruction ((compiled-instruction compiled-instruction))
Writer Method: (setf source-instruction) ((compiled-instruction compiled-instruction))

The instruction that was compiled to produce this one.

Source

compile-gate.lisp.

Target Slot

source-instruction.

Generic Reader: stabilizer-qvm-tableau (object)
Package

qvm.

Methods
Reader Method: stabilizer-qvm-tableau ((stabilizer-qvm stabilizer-qvm))

automatically generated reader method

Source

stabilizer-qvm.lisp.

Target Slot

tableau.

Generic Reader: state (object)
Package

qvm.

Methods
Reader Method: state ((mixed-state-qvm mixed-state-qvm))

automatically generated reader method

Source

mixed-state-qvm.lisp.

Target Slot

state.

Reader Method: state ((pure-state-qvm pure-state-qvm))

The unpermuted wavefunction in standard order.

Source

qvm.lisp.

Target Slot

state.

Reader Method: state ((base-qvm base-qvm))

The state of the quantum system simulated by the QVM.

Source

qvm.lisp.

Target Slot

state.

Generic Reader: superoperator-definitions (object)
Generic Writer: (setf superoperator-definitions) (object)
Package

qvm.

Methods
Reader Method: superoperator-definitions ((base-qvm base-qvm))
Writer Method: (setf superoperator-definitions) ((base-qvm base-qvm))

A hash table of gate name to SUPEROPERATOR. These superoperator definitions are meant to override the gate name definitions stored in GATE-DEFINITIONS, such that a superoperator will be applied to the state of the QVM if the current gate name matches an entry in the SUPEROPERATOR-DEFINITIONS.

Source

qvm.lisp.

Target Slot

superoperator-definitions.

Generic Function: swap-internal-amplitude-pointers (state)

Only relevant for PURE-STATE – swap AMPLITUDES with TRIAL-AMPLITUDES.

Package

qvm.

Source

state-representation.lisp.

Methods
Method: swap-internal-amplitude-pointers ((state pure-state))
Generic Reader: t1-vals (object)
Generic Writer: (setf t1-vals) (object)
Package

qvm.

Methods
Reader Method: t1-vals ((basic-noise-qvm basic-noise-qvm))
Writer Method: (setf t1-vals) ((basic-noise-qvm basic-noise-qvm))

Hash table of qubit idx to T1 value for each qubit to simulate

Source

basic-noise-qvm.lisp.

Target Slot

t1-vals.

Generic Reader: t2-vals (object)
Generic Writer: (setf t2-vals) (object)
Package

qvm.

Methods
Reader Method: t2-vals ((basic-noise-qvm basic-noise-qvm))
Writer Method: (setf t2-vals) ((basic-noise-qvm basic-noise-qvm))

Hash table of qubit idx to T2 value for each qubit to simulate

Source

basic-noise-qvm.lisp.

Target Slot

t2-vals.

Generic Reader: temporary-state (object)
Generic Writer: (setf temporary-state) (object)
Package

qvm.

Methods
Reader Method: temporary-state ((density-matrix-state density-matrix-state))
Writer Method: (setf temporary-state) ((density-matrix-state density-matrix-state))

A placeholder for computations on the elements-vector of a DENSITY-MATRIX-STATE.

Source

state-representation.lisp.

Target Slot

temporary-state.

Generic Reader: tphi-vals (object)
Generic Writer: (setf tphi-vals) (object)
Package

qvm.

Methods
Reader Method: tphi-vals ((basic-noise-qvm basic-noise-qvm))
Writer Method: (setf tphi-vals) ((basic-noise-qvm basic-noise-qvm))

Hash table of qubit idx to TPHI value for each qubit to simulate.

Source

basic-noise-qvm.lisp.

Target Slot

tphi-vals.

Generic Reader: wait-function (object)
Package

qvm.

Methods
Reader Method: wait-function ((classical-memory-mixin classical-memory-mixin))

A unary function taking a QVM and implementing Quil’s WAIT logic. (The default does nothing and just warns.)

Source

classical-memory-mixin.lisp.

Target Slot

wait-function.


5.2.6 Standalone methods

Method: %max-qubit ((isn measure-all))
Package

cl-quil.

Source

compile-gate.lisp.

Method: print-instruction-generic ((instr measure-all) stream)
Package

cl-quil.

Source

compile-gate.lisp.

Method: print-instruction-generic ((instr compiled-instruction) stream)
Package

cl-quil.

Source

compile-gate.lisp.

Method: print-instruction-generic ((instr clifford-application) stream)
Package

cl-quil.

Source

stabilizer-qvm.lisp.


5.2.7 Structures

Structure: kraus-list
Package

qvm.

Source

linear-algebra.lisp.

Direct superclasses

superoperator.

Direct methods
Direct slots
Slot: %0
Package

cl-algebraic-data-type.

Type

list

Initform

(error "unspecified field.")

Readers

kraus-list%0.

Writers

This slot is read-only.

Structure: memory-view

A "view" into a chunk of (possibly aliased) classical memory. The view constitutes the memory itself along with functions to read and write that memory.

Package

qvm.

Source

classical-memory.lisp.

Direct superclasses

structure-object.

Direct methods

print-object.

Direct slots
Slot: length
Package

common-lisp.

Type

unsigned-byte

Initform

(error "you need to provide the length.")

Readers

memory-view-length.

Writers

This slot is read-only.

Slot: root-classical-memory
Type

qvm:classical-memory

Initform

(error "you need a root classical memory.")

Readers

memory-view-root-classical-memory.

Writers

This slot is read-only.

Slot: aliasing-classical-memory
Type

(or null qvm:classical-memory)

Readers

memory-view-aliasing-classical-memory.

Writers

This slot is read-only.

Slot: reader
Type

function

Readers

memory-view-reader.

Writers

This slot is read-only.

Slot: writer
Type

function

Readers

memory-view-writer.

Writers

This slot is read-only.

Structure: posix-shared-memory

Representation of some POSIX shared memory.

Package

qvm.

Source

shm.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: name
Readers

posix-shared-memory-name.

Writers

(setf posix-shared-memory-name).

Slot: size
Readers

posix-shared-memory-size.

Writers

(setf posix-shared-memory-size).

Slot: pointer
Readers

posix-shared-memory-pointer.

Writers

(setf posix-shared-memory-pointer).

Structure: single-kraus
Package

qvm.

Source

linear-algebra.lisp.

Direct superclasses

superoperator.

Direct methods
Direct slots
Slot: %0
Package

cl-algebraic-data-type.

Type

cl-quil:gate

Initform

(error "unspecified field.")

Readers

single-kraus%0.

Writers

This slot is read-only.

Structure: subsystem

Representation of the state of a subsystem of qubits.

Package

qvm.

Source

subsystem.lisp.

Direct superclasses

structure-object.

Direct methods

print-object.

Direct slots
Slot: state
Type

qvm:quantum-state

Initform

(qvm:wf 1)

Readers

subsystem-state.

Writers

This slot is read-only.

Slot: qubits
Type

unsigned-byte

Initform

0

Readers

subsystem-qubits.

Writers

This slot is read-only.

Structure: superoperator

Representation of a linear operator on density operators.

Package

qvm.

Source

linear-algebra.lisp.

Direct superclasses

algebraic-data-type.

Direct subclasses
Direct methods

5.2.8 Classes

Class: base-qvm
Package

qvm.

Source

qvm.lisp.

Direct superclasses

classical-memory-mixin.

Direct subclasses
Direct methods
Direct slots
Slot: number-of-qubits

Number of qubits being simulated by the QVM.

Type

alexandria:non-negative-fixnum

Initform

(error ":number-of-qubits is a required initarg to base-qvm.")

Initargs

:number-of-qubits

Readers

number-of-qubits.

Writers

This slot is read-only.

Slot: state

The state of the quantum system simulated by the QVM.

Initargs

:state

Readers

state.

Writers

%set-state.

Slot: program-compiled-p

Has the loaded program been compiled?

Readers

program-compiled-p.

Writers

(setf program-compiled-p).

Slot: superoperator-definitions

A hash table of gate name to SUPEROPERATOR. These superoperator definitions are meant to override the gate name definitions stored in GATE-DEFINITIONS, such that a superoperator will be applied to the state of the QVM if the current gate name matches an entry in the SUPEROPERATOR-DEFINITIONS.

Initform

(make-hash-table :test (quote equalp))

Initargs

:superoperator-definitions

Readers

superoperator-definitions.

Writers

(setf superoperator-definitions).

Class: clifford-application

A gate application that’s actually a Clifford.

Package

qvm.

Source

stabilizer-qvm.lisp.

Direct superclasses

application.

Direct methods
Direct slots
Slot: clifford
Initargs

:clifford

Readers

clifford-application-clifford.

Writers

This slot is read-only.

Class: compiled-gate-application

A representation of a compiled gate application.

Package

qvm.

Source

compile-gate.lisp.

Direct superclasses
Direct subclasses
Direct methods
Direct slots
Slot: source-gate

The gate object being represented by this application.

Initargs

:source-gate

Readers

source-gate.

Writers

This slot is read-only.

Slot: apply-operator

The operator (a FUNCTION) which, at least as one of its arguments, modifies the wavefunction.

Initargs

:apply-operator

Readers

compiled-gate-apply-operator.

Writers

This slot is read-only.

Class: compiled-inlined-matrix-gate-application

A compiled GATE-APPLICATION that has the matrix inlined. Note that this is a subclass of GATE-APPLICATION.

Package

qvm.

Source

compile-gate.lisp.

Direct superclasses

compiled-gate-application.

Direct methods
Direct slots
Slot: gate-matrix

The (static) matrix represented by this application.

Initargs

:gate-matrix

Readers

compiled-matrix.

Writers

This slot is read-only.

Class: compiled-instruction
Package

qvm.

Source

compile-gate.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: source-instruction

The instruction that was compiled to produce this one.

Initargs

:source-instruction

Readers

source-instruction.

Writers

(setf source-instruction).

Class: compiled-matrix-gate-application

A compiled GATE-APPLICATION. Note that this is a subclass of GATE-APPLICATION.

Package

qvm.

Source

compile-gate.lisp.

Direct superclasses

compiled-gate-application.

Direct methods
Direct slots
Slot: gate-matrix

The (static) matrix represented by this application.

Initargs

:gate-matrix

Readers

compiled-matrix.

Writers

This slot is read-only.

Class: compiled-measurement

A compiled MEASURE, regardless of its classical effect.

Package

qvm.

Source

compile-gate.lisp.

Direct superclasses
Direct methods
Direct slots
Slot: projector-operator

Projection function which takes a WAVEFUNCTION as an argument and returns the measured bit result.

Initargs

:projector-operator

Readers

projector-operator.

Writers

This slot is read-only.

Class: compiled-permutation-gate-application

A compiled GATE-APPLICATION where the gate happens to be a permutation gate.

Package

qvm.

Source

compile-gate.lisp.

Direct superclasses

compiled-gate-application.

Direct methods

apply-gate-to-state.

Class: mixed-state-qvm

A qvm for simulating mixed-state quantum systems.

Package

qvm.

Source

mixed-state-qvm.lisp.

Direct superclasses

base-qvm.

Direct methods
Direct slots
Slot: state
Type

(or null qvm:density-matrix-state)

Initargs

:state

Readers

state.

Writers

%set-state.

Class: quantum-system-state

A QUANTUM-SYSTEM-STATE contains the quantum mechanical state of the QVM and any additional helper objects used in performing computations on the state.

Package

qvm.

Source

state-representation.lisp.

Direct subclasses
Direct methods

allocation.

Direct slots
Slot: allocation
Initargs

:allocation

Readers

allocation.

Writers

This slot is read-only.

Class: stabilizer-qvm

A QVM that can efficiently simulate Clifford circuits and measurement.

Package

qvm.

Source

stabilizer-qvm.lisp.

Direct superclasses

classical-memory-mixin.

Direct methods
Direct slots
Slot: tableau
Initargs

:tableau

Readers

stabilizer-qvm-tableau.

Writers

This slot is read-only.


5.2.9 Types

Type: cflonum-vector (&optional length)
Package

qvm.

Source

floats.lisp.

Type: density-operator-matrix-view ()

The matrix view of a density operator.

Package

qvm.

Source

density-qvm.lisp.

Type: finalizer ()

A finalizer thunk. Used for the effect of freeing some memory.

Package

qvm.

Source

allocator.lisp.

Type: flonum-vector (&optional length)
Package

qvm.

Source

floats.lisp.

Type: nat-tuple ()

The NAT-TUPLE type. A "nat tuple" represents an ordered list of non-negative integer indexes.

In the context of the QVM, this represents a particular Hilbert space.

Package

qvm.

Source

utilities.lisp.

Type: nat-tuple-cardinality ()

A representation of the set of cardinalities of a nat tuple.

Package

qvm.

Source

utilities.lisp.

Type: nat-tuple-element ()

The set of valid elements in a nat tuple.

Package

qvm.

Source