API Reference

Circuits

Circuit(moments, device) A mutable list of groups of operations to apply to some qubits.
Moment(operations) A simplified time-slice of operations within a sequenced circuit.
InsertStrategy(name, doc) Indicates preferences on how to add multiple operations to a circuit.
OP_TREE Union type; Union[X, Y] means either X or Y.

Operations

Operation An effect applied to a collection of qubits.
GateOperation(gate, qubits) An application of a gate to a collection of qubits.
CompositeOperation An operation with a known decomposition into simpler operations.
QasmConvertableOperation An operation that knows its representation in QASM.

Schedules

Schedule(device, scheduled_operations) A quantum program with operations happening at specific times.
ScheduledOperation(time, duration, operation) An operation that happens over a specified time interval.
Duration(*, picos, float] = 0, nanos, float] = 0) A time delta that supports picosecond accuracy.
Timestamp(*, picos, float] = 0, nanos, …) A location in time with picosecond accuracy.

Gates

Gate An operation type that can be applied to a collection of qubits.
MeasurementGate(key, invert_mask, …] = ()) Indicates that qubits should be measured plus a key to identify results.

Gate Features and Effects

KnownMatrix An effect that can be described by a matrix.
ParameterizableEffect An effect that can be parameterized by Symbols.
CompositeGate A gate with a known decomposition into simpler gates.
ExtrapolatableEffect A gate whose effect can be continuously scaled up/down/negated.
ReversibleEffect A gate whose effect can be undone in a known way.
InterchangeableQubitsGate Indicates operations should be equal under some qubit permutations.
PhaseableEffect An effect that can be phased around the Z axis of target qubits.
TextDiagrammable A thing which can be printed in a text diagram.
BoundedEffect An effect with known bounds on how easy it is to detect.
SingleQubitGate A gate that must be applied to exactly one qubit.
TwoQubitGate A gate that must be applied to exactly two qubits.
QasmConvertableGate A gate that knows its representation in QASM.
EigenGate(*, exponent, float] = 1.0) A gate with a known eigendecomposition.

Single Qubit Gates

RotXGate(*, half_turns, float, …) Fixed rotation around the X axis of the Bloch sphere.
RotYGate(*, half_turns, float, …) Fixed rotation around the Y axis of the Bloch sphere.
RotZGate(*, half_turns, float, …) Fixed rotation around the Z axis of the Bloch sphere.
HGate 180 degree rotation around the X+Z axis of the Bloch sphere.
X Fixed rotation around the X axis of the Bloch sphere.
Y Fixed rotation around the Y axis of the Bloch sphere.
Z Fixed rotation around the Z axis of the Bloch sphere.
H 180 degree rotation around the X+Z axis of the Bloch sphere.
S Fixed rotation around the Z axis of the Bloch sphere.
T Fixed rotation around the Z axis of the Bloch sphere.

Two Qubit Gates

Rot11Gate(*, half_turns, float, …) Phases the |11> state of two adjacent qubits by a fixed amount.
CNotGate(*, half_turns, float, …) A controlled-NOT.
SwapGate(*, half_turns, float] = 1.0) Swaps two qubits.
ISwapGate(*, exponent, float] = 1.0) Rotates the |01⟩-vs-|10⟩ subspace of two qubits around its Bloch X-axis.
CZ Phases the |11> state of two adjacent qubits by a fixed amount.
CNOT A controlled-NOT.
ISWAP Rotates the |01⟩-vs-|10⟩ subspace of two qubits around its Bloch X-axis.

Three Qubit Gates

CCZ A doubly-controlled-Z.
CCX A doubly-controlled-NOT.
CSWAP A controlled swap gate.
TOFFOLI A doubly-controlled-NOT.
FREDKIN A controlled swap gate.

Qubits

General classes for qubits and related concepts.

QubitId Identifies a qubit.
NamedQubit(name) A qubit identified by name.
LineQubit(x) A qubit on a 1d lattice with nearest-neighbor connectivity.
GridQubit(row, col) A qubit on a 2d square lattice.
QubitOrder(explicit_func, …) Defines the kronecker product order of qubits.
QubitOrderOrList Union type; Union[X, Y] means either X or Y.
QubitOrder.DEFAULT A basis that orders qubits based on their names.

Devices

Classes characterizing constraints of hardware.

Device Hardware constraints for validating circuits and schedules.
UnconstrainedDevice A device that allows everything.

Placement

Classes for placing circuits onto circuits.

LinePlacementStrategy Choice and options for the line placement calculation method.
GreedySequenceSearchStrategy(algorithm) Greedy search method for linear sequence of qubits on a chip.
AnnealSequenceSearchStrategy(trace_func, …) Linearized sequence search using simulated annealing method.
line_on_device(device, length, method) Searches for linear sequence of qubits on device.

Parameterization

Classes for parameterized circuits.

Symbol(name) A constant plus the runtime value of a parameter with a given key.
ParamResolver(param_dict, float]) Resolves Symbols to actual values.
Sweep A sweep is an iterator over ParamResolvers.
Points(key, points) A simple sweep with explicitly supplied values.
Linspace(key, start, stop, length) A simple sweep over linearly-spaced values.
Sweepable Union type; Union[X, Y] means either X or Y.

Optimization

Classes for compiling.

OptimizationPass Rewrites a circuit’s operations in place to make them better.
PointOptimizer Makes circuit improvements focused on a specific location.
PointOptimizationSummary(clear_span, …) A description of a local optimization to perform.
ExpandComposite(composite_gate_extension, …) An optimization pass that expands CompositeOperation instances.
DropEmptyMoments Removes empty moments from a circuit.
DropNegligible(tolerance, extensions) An optimization pass that removes operations with tiny effects.

Implementations

Packages to use specific hardware implementations.

Google

Quantum hardware from Google.

Gates

google.XmonGate A gate with a known mechanism for encoding into google API protos.
google.Exp11Gate(*, half_turns, float, …) A two-qubit interaction that phases the amplitude of the 11 state.
google.ExpWGate(*, axis_half_turns, float, …) A rotation around an axis in the XY plane of the Bloch sphere.
google.ExpZGate(*, half_turns, float, …) A rotation around the Z axis of the Bloch sphere.
google.XmonMeasurementGate(key, invert_mask, …) Indicates that qubits should be measured, and where the result goes.
google.single_qubit_matrix_to_native_gates(…) Implements a single-qubit operation with few native gates.
google.two_qubit_matrix_to_native_gates(q0, …) Decomposes a two-qubit operation into Z/XY/CZ gates.
google.ConvertToXmonGates(extensions[, …]) Attempts to convert strange gates into XmonGates.

Devices

google.Bristlecone A device with qubits placed in a grid.
google.Foxtail A device with qubits placed in a grid.
google.XmonDevice(measurement_duration, …) A device with qubits placed in a grid.

Simulator

google.XmonOptions(num_shards, …) XmonOptions for the XmonSimulator.
google.XmonSimulator(options) XmonSimulator for Xmon class quantum circuits.
google.XmonStepResult(stepper, qubit_map, …) Results of a step of the simulator.
google.XmonSimulateTrialResult(params, …) Results of a simulation of the XmonSimulator.

Optimizers

google.optimized_for_xmon(circuit, …) Optimizes a circuit with XmonDevice in mind.
google.EjectZ(tolerance, ext) Pushes Z gates towards the end of the circuit.
google.EjectFullW(tolerance, ext) Pushes ExpW gates with half_turns=1 towards the end of the circuit.