# Module: cirq

Cirq is a framework for creating, editing, and invoking quantum circuits.

## Modules

contrib module: Functionality that is not part of core supported Cirq apis.

testing module: Utilities for testing code.

type_workarounds module: Workarounds for deficiencies in python's typing system.

## Classes

class ABCMetaImplementAnyOneOf: A metaclass extending abc.ABCMeta for defining abstract base classes

class AbstractCircuit: The base class for Circuit-like objects.

class ActOnArgs: THIS CLASS IS DEPRECATED.

class ActOnArgsContainer: THIS CLASS IS DEPRECATED.

class ActOnCliffordTableauArgs: THIS CLASS IS DEPRECATED.

class ActOnDensityMatrixArgs: THIS CLASS IS DEPRECATED.

class ActOnStabilizerArgs: THIS CLASS IS DEPRECATED.

class ActOnStabilizerCHFormArgs: THIS CLASS IS DEPRECATED.

class ActOnStateVectorArgs: THIS CLASS IS DEPRECATED.

class AlignLeft: THIS CLASS IS DEPRECATED.

class AlignRight: THIS CLASS IS DEPRECATED.

class Alignment: Alignment option for combining/zipping two circuits together.

class AmplitudeDampingChannel: Dampen qubit amplitudes through dissipation.

class AnyIntegerPowerGateFamily: GateFamily which accepts instances of a given cirq.EigenGate, raised to integer power.

class AnyUnitaryGateFamily: GateFamily which accepts any N-Qubit unitary gate.

class ApplyChannelArgs: Arguments for efficiently performing a channel.

class ApplyMixtureArgs: Arguments for performing a mixture of unitaries.

class ApplyUnitaryArgs: Arguments for performing an efficient left-multiplication by a unitary.

class ArithmeticGate: A helper gate for implementing reversible classical arithmetic.

class ArithmeticOperation: THIS CLASS IS DEPRECATED.

class AsymmetricDepolarizingChannel: A channel that depolarizes asymmetrically along different directions.

class AxisAngleDecomposition: Represents a unitary operation as an axis, angle, and global phase.

class BitFlipChannel: Probabilistically flip a qubit from 1 to 0 state or vice versa.

class BooleanHamiltonianGate: A gate that represents evolution due to a Hamiltonian from a set of Boolean functions.

class CCNotPowGate: A Toffoli (doubly-controlled-NOT) that can be raised to a power.

class CCXPowGate: A Toffoli (doubly-controlled-NOT) that can be raised to a power.

class CCZPowGate: A doubly-controlled-Z that can be raised to a power.

class CNotPowGate: A gate that applies a controlled power of an X gate.

class CSwapGate: A controlled swap gate. The Fredkin gate.

class CXPowGate: A gate that applies a controlled power of an X gate.

class CZPowGate: A gate that applies a phase to the |11⟩ state of two qubits.

class CZTargetGateset: Target gateset accepting CZ + single qubit rotations + measurement gates.

class Circuit: A mutable list of groups of operations to apply to some qubits.

class CircuitDag: THIS CLASS IS DEPRECATED.

class CircuitDiagramInfo: Describes how to draw an operation in a circuit diagram.

class CircuitDiagramInfoArgs: A request for information on drawing an operation in a circuit diagram.

class CircuitOperation: An operation that encapsulates a circuit.

class CircuitSampleJob: Describes a sampling task.

class ClassicalDataDictionaryStore: Classical data representing measurements and metadata.

class ClassicalDataStore: Helper class that provides a standard way to create an ABC using

class ClassicalDataStoreReader: Helper class that provides a standard way to create an ABC using

class ClassicallyControlledOperation: Augments existing operations to be conditionally executed.

class CliffordGate: Clifford rotation for N-qubit.

class CliffordSimulator: An efficient simulator for Clifford circuits.

class CliffordSimulatorStepResult: A StepResult that includes StateVectorMixin methods.

class CliffordState: A state of the Clifford simulation.

class CliffordTableau: Tableau representation of a stabilizer state

class CliffordTableauSimulationState: State and context for an operation acting on a clifford tableau.

class CliffordTrialResult: A base class for trial results.

class Collector: Collects data from a sampler, in parallel, towards some purpose.

class CompilationTargetGateset: Abstract base class to create gatesets that can be used as targets for compilation.

class Condition: A classical control condition that can gate an operation.

class ConstantQubitNoiseModel: Applies noise to each qubit individually at the start of every moment.

class ControlledGate: Augments existing gates to have one or more control qubits.

class ControlledOperation: Augments existing operations to have one or more control qubits.

class ConvertToCzAndSingleGates: THIS CLASS IS DEPRECATED.

class ConvertToIonGates: THIS CLASS IS DEPRECATED.

class ConvertToNeutralAtomGates: THIS CLASS IS DEPRECATED.

class DensePauliString: An immutable string of Paulis, like XIXY, with a coefficient.

class DensityMatrixSimulationState: State and context for an operation acting on a density matrix.

class DensityMatrixSimulator: A simulator for density matrices and noisy quantum circuits.

class DensityMatrixSimulatorState: THIS CLASS IS DEPRECATED.

class DensityMatrixStepResult: A single step in the simulation of the DensityMatrixSimulator.

class DensityMatrixTrialResult: A SimulationTrialResult for DensityMatrixSimulator runs.

class DepolarizingChannel: A channel that depolarizes one or several qubits.

class Device: Hardware constraints for validating circuits.

class DeviceMetadata: Parent type for all device specific metadata classes.

class DiagonalGate: An n qubit gate which acts as phases on computational basis states.

class DropEmptyMoments: THIS CLASS IS DEPRECATED.

class DropNegligible: THIS CLASS IS DEPRECATED.

class Duration: A time delta that supports symbols and picosecond accuracy.

class EigenGate: A gate with a known eigendecomposition.

class EjectPhasedPaulis: THIS CLASS IS DEPRECATED.

class EjectZ: THIS CLASS IS DEPRECATED.

class ExpandComposite: THIS CLASS IS DEPRECATED.

class ExpressionMap: A dictionary with sympy expressions and symbols for keys and sympy

class FSimGate: Fermionic simulation gate family.

class FrozenCircuit: An immutable version of the Circuit data structure.

class Gate: An operation type that can be applied to a collection of qubits.

class GateFamily: Wrapper around gate instances/types describing a set of accepted gates.

class GateOperation: An application of a gate to a sequence of qubits.

class Gateset: Gatesets represent a collection of cirq.GateFamily objects.

class GeneralizedAmplitudeDampingChannel: Dampen qubit amplitudes through non ideal dissipation.

class GlobalPhaseGate: An operation type that can be applied to a collection of qubits.

class GlobalPhaseOperation: THIS CLASS IS DEPRECATED.

class GridDeviceMetadata: Hardware metadata for homogenous 2d symmetric grid devices.

class GridQid: A qid on a 2d square lattice

class GridQubit: A qubit on a 2d square lattice.

class HPowGate: A Gate that performs a rotation around the X+Z axis of the Bloch sphere.

class HasJSONNamespace: An object which prepends a namespace to its JSON cirq_type.

class Heatmap: Distribution of a value in 2D qubit lattice as a color map.

class ISwapPowGate: Rotates the |01⟩ vs |10⟩ subspace of two qubits around its Bloch X-axis.

class IdentityGate: A Gate that perform no operation on qubits.

class InsertStrategy: Indicates preferences on how to add multiple operations to a circuit.

class InterchangeableQubitsGate: Indicates operations should be equal under some qubit permutations.

class IonDevice: THIS CLASS IS DEPRECATED.

class JsonResolver: Protocol for json resolver functions passed to read_json.

class KakDecomposition: A convenient description of an arbitrary two-qubit operation.

class KeyCondition: A classical control condition based on a single measurement key.

class KrausChannel: A generic channel that can record the index of its selected operator.

class LineQid: A qid on a 1d lattice with nearest-neighbor connectivity.

class LineQubit: A qubit on a 1d lattice with nearest-neighbor connectivity.

class LineTopology: A 1D linear topology.

class LinearCombinationOfGates: Represents linear operator defined by a linear combination of gates.

class LinearCombinationOfOperations: Represents operator defined by linear combination of gate operations.

class LinearDict: Represents linear combination of things.

class Linspace: A simple sweep over linearly-spaced values.

class ListSweep: A wrapper around a list of ParamResolvers.

class MatrixGate: A unitary qubit or qudit gate defined entirely by its numpy matrix.

class MeasurementGate: A gate that measures qubits in the computational basis.

class MeasurementKey: A class representing a Measurement Key.

class MeasurementType: Type of a measurement, whether a measurement or channel.

class MergeInteractions: THIS CLASS IS DEPRECATED.

class MergeInteractionsToSqrtIswap: THIS CLASS IS DEPRECATED.

class MergeSingleQubitGates: THIS CLASS IS DEPRECATED.

class MixedUnitaryChannel: A generic mixture that can record the index of its selected operator.

class Moment: A time-slice of operations within a circuit.

class MutableDensePauliString: A mutable string of Paulis, like XIXY, with a coefficient.

class MutablePauliString: Mutable version of cirq.PauliString, used mainly for efficiently mutating pauli strings.

class NamedQid: A qid identified by name.

class NamedQubit: A qubit identified by name.

class NamedTopology: A topology (graph) with a name.

class NeutralAtomDevice: THIS CLASS IS DEPRECATED.

class NoiseModel: Replaces operations and moments with noisy counterparts.

class NoiseModelFromNoiseProperties: Replaces operations and moments with noisy counterparts.

class NoiseProperties: Noise-defining properties for a quantum device.

class OpIdentifier: Identifies an operation by gate and (optionally) target qubits.

class Operation: An effect applied to a collection of qubits.

class OperationTarget: THIS CLASS IS DEPRECATED.

class ParallelGate: Augments existing gates to be applied on one or more groups of qubits.

class ParallelGateFamily: GateFamily which accepts instances of cirq.ParallelGate and it's sub_gate.

class ParamResolver: Resolves parameters to actual values.

class Pauli: Represents the Pauli gates.

class PauliInteractionGate: A CZ conjugated by arbitrary single qubit Cliffords.

class PauliMeasurementGate: A gate that measures a Pauli observable.

class PauliString: Represents a multi-qubit pauli operator or pauli observable.

class PauliStringGateOperation: An effect applied to a collection of qubits.

class PauliStringPhasor: An operation that phases the eigenstates of a Pauli string.

class PauliStringPhasorGate: A gate that phases the eigenstates of a Pauli string.

class PauliSum: Represents operator defined by linear combination of PauliStrings.

class PauliSumCollector: Estimates the energy of a linear combination of Pauli observables.

class PauliSumExponential: Represents an operator defined by the exponential of a PauliSum.

class PauliTransform: THIS CLASS IS DEPRECATED.

class PeriodicValue: Wrapper for periodic numerical values.

class PhaseDampingChannel: Dampen qubit phase.

class PhaseFlipChannel: Probabilistically flip the sign of the phase of a qubit.

class PhaseGradientGate: Phases all computational basis states proportional to the integer value of the state.

class PhasedFSimGate: General excitation-preserving two-qubit gate.

class PhasedISwapPowGate: Fractional ISWAP conjugated by Z rotations.

class PhasedXPowGate: A gate equivalent to $$Z^{p} X^t Z^{-p}$$.

class PhasedXZGate: A single qubit gate equivalent to the circuit $$Z^z Z^{a} X^x Z^{-a}$$.

class PointOptimizationSummary: A description of a local optimization to perform.

class PointOptimizer: Makes circuit improvements focused on a specific location.

class Points: A simple sweep with explicitly supplied values.

class Product: Cartesian product of one or more sweeps.

class ProductState: A quantum state that is a tensor product of one qubit states.

class ProjectorString: Mapping of cirq.Qid to measurement values (with a coefficient) representing a projector.

class ProjectorSum: List of mappings representing a sum of projector operators.

class QasmArgs: Formatting Arguments for outputting QASM code.

class QasmOutput: Representation of a circuit in QASM (quantum assembly) format.

class Qid: Identifies a quantum object such as a qubit, qudit, resonator, etc.

class QuantumFourierTransformGate: Switches from the computational basis to the frequency basis.

class QuantumState: A quantum state.

class QuantumStateRepresentation

class QubitOrder: Defines the kronecker product order of qubits.

class QubitPermutationGate: A qubit permutation gate specified by a permutation list.

class QuilFormatter: THIS CLASS IS DEPRECATED.

class QuilOutput: THIS CLASS IS DEPRECATED.

class RandomGateChannel: Applies a sub gate with some probability.

class ResetChannel: Reset a qubit back to its |0⟩ state.

class Result: The results of multiple executions of a circuit with fixed parameters.

class ResultDict: A Result created from a dict mapping measurement keys to measured values.

class Rx: A gate with matrix $$e^{-i X t/2}$$ that rotates around the X axis of the Bloch sphere by $$t$$.

class Ry: A gate with matrix $$e^{-i Y t/2}$$ that rotates around the Y axis of the Bloch sphere by $$t$$.

class Rz: A gate with matrix $$e^{-i Z t/2}$$ that rotates around the Z axis of the Bloch sphere by $$t$$.

class Sampler: Something capable of sampling quantum circuits. Simulator or hardware.

class SerializableByKey: Protocol for objects that can be serialized to a key + context.

class SimulatesAmplitudes: Simulator that computes final amplitudes of given bitstrings.

class SimulatesExpectationValues: Simulator that computes exact expectation values of observables.

class SimulatesFinalState: Simulator that allows access to the simulator's final state.

class SimulatesIntermediateState: A SimulatesFinalState that simulates a circuit by moments.

class SimulatesIntermediateStateVector: A simulator that accesses its state vector as it does its simulation.

class SimulatesSamples: Simulator that mimics running on quantum hardware.

class SimulationProductState: A container for a Qid-to-SimulationState dictionary.

class SimulationState: State and context for an operation acting on a state tensor.

class SimulationStateBase: An interface for quantum states as targets for operations.

class SimulationTrialResult: Results of a simulation by a SimulatesFinalState.

class SimulationTrialResultBase: A base class for trial results.

class Simulator: A sparse matrix state vector simulator that uses numpy.

class SimulatorBase: A base class for the built-in simulators.

class SingleQubitCliffordGate: Any single qubit Clifford rotation.

class SingleQubitGate: THIS CLASS IS DEPRECATED.

class SingleQubitPauliStringGateOperation: An operation to represent single qubit pauli gates applied to a qubit.

class SparseSimulatorStep: A StepResult that includes StateVectorMixin methods.

class SqrtIswapTargetGateset: Target gateset accepting √iSWAP + single qubit rotations + measurement gates.

class StabilizerChFormSimulationState: Wrapper around a stabilizer state in CH form for the act_on protocol.

class StabilizerSampler: An efficient sampler for stabilizer circuits.

class StabilizerSimulationState: Abstract wrapper around a stabilizer state for the act_on protocol.

class StabilizerState: Interface for quantum stabilizer state representations.

class StabilizerStateChForm: A representation of stabilizer states using the CH form,

class StatePreparationChannel: A channel which prepares any state provided as the state vector on it's target qubits.

class StateVectorMixin: A mixin that provide methods for objects that have a state vector.

class StateVectorSimulationState: State and context for an operation acting on a state vector.

class StateVectorSimulatorState: THIS CLASS IS DEPRECATED.

class StateVectorStepResult: A base class for step results.

class StateVectorTrialResult: A SimulationTrialResult that includes the StateVectorMixin methods.

class StepResult: Results of a step of a SimulatesIntermediateState.

class StepResultBase: A base class for step results.

class SuperconductingQubitsNoiseProperties: Noise-defining properties for a superconducting-qubit-based device.

class SupportsActOn: An object that explicitly specifies how to act on simulator states.

class SupportsActOnQubits: An object that explicitly specifies how to act on specific qubits.

class SupportsApplyChannel: An object that can efficiently implement a channel.

class SupportsApplyMixture: An object that can efficiently implement a mixture.

class SupportsApproximateEquality: Object which can be compared approximately.

class SupportsCircuitDiagramInfo: A diagrammable operation on qubits.

class SupportsCommutes: An object that can determine commutation relationships vs others.

class SupportsConsistentApplyUnitary: An object that can be efficiently left-multiplied into tensors.

class SupportsControlKey: An object that is a has a classical control key or keys.

class SupportsDecompose: An object that can be decomposed into simpler operations.

class SupportsDecomposeWithQubits: An object that can be decomposed into operations on given qubits.

class SupportsEqualUpToGlobalPhase: Object which can be compared for equality mod global phase.

class SupportsExplicitHasUnitary: An object that explicitly specifies whether it has a unitary effect.

class SupportsExplicitNumQubits: A unitary, channel, mixture or other object that operates on a known

class SupportsExplicitQidShape: A unitary, channel, mixture or other object that operates on a known

class SupportsJSON: An object that can be turned into JSON dictionaries.

class SupportsKraus: An object that may be describable as a quantum channel.

class SupportsMeasurementKey: An object that is a measurement and has a measurement key or keys.

class SupportsMixture: An object that decomposes into a probability distribution of unitaries.

class SupportsParameterization: An object that can be parameterized by Symbols and resolved

class SupportsPauliExpansion: An object that knows its expansion in the Pauli basis.

class SupportsPhase: An effect that can be phased around the Z axis of target qubits.

class SupportsQasm: An object that can be turned into QASM code.

class SupportsQasmWithArgs: An object that can be turned into QASM code.

class SupportsQasmWithArgsAndQubits: An object that can be turned into QASM code if it knows its qubits.

class SupportsTraceDistanceBound: An effect with known bounds on how easy it is to detect.

class SupportsUnitary: An object that may be describable by a unitary matrix.

class SwapPowGate: The SWAP gate, possibly raised to a power. Exchanges qubits.

class Sweep: A sweep is an iterator over ParamResolvers.

class SympyCondition: A classical control condition based on a sympy expression.

class SynchronizeTerminalMeasurements: THIS CLASS IS DEPRECATED.

class TRANSFORMER: Protocol class defining the Transformer API for circuit transformers in Cirq.

class TaggedOperation: Operation annotated with a set of Tags.

class TensoredConfusionMatrices: Store and use confusion matrices for readout error mitigation on sets of qubits.

class TextDiagramDrawer: A utility class for creating simple text diagrams.

class ThreeQubitDiagonalGate: A three qubit gate whose unitary is given by a diagonal $$8 \times 8$$ matrix.

class TiltedSquareLattice: A grid lattice rotated 45-degrees.

class Timestamp: A location in time with picosecond accuracy.

class TransformerContext: Stores common configurable options for transformers.

class TransformerLogger: Base Class for transformer logging infrastructure. Defaults to text-based logging.

class TwoQubitCompilationTargetGateset: Abstract base class to create two-qubit target gatesets.

class TwoQubitDiagonalGate: A two qubit gate whose unitary is a diagonal $$4 \times 4$$ matrix.

class TwoQubitGateTabulation: A 2-qubit gate compiler based on precomputing/tabulating gate products.

class TwoQubitGateTabulationResult: Represents a compilation of a target 2-qubit with respect to a base

class TwoQubitInteractionHeatmap: Visualizing interactions between neighboring qubits on a 2D grid.

class Unique: THIS CLASS IS DEPRECATED.

class VirtualTag: A TaggedOperation tag indicating that the operation is virtual.

class WaitGate: An idle gate that represents waiting.

class XPowGate: A gate that rotates around the X axis of the Bloch sphere.

class XXPowGate: The X-parity gate, possibly raised to a power.

class YPowGate: A gate that rotates around the Y axis of the Bloch sphere.

class YYPowGate: The Y-parity gate, possibly raised to a power.

class ZPowGate: A gate that rotates around the Z axis of the Bloch sphere.

class ZZPowGate: The Z-parity gate, possibly raised to a power.

class ZerosSampler: A dummy sampler for testing. Immediately returns zeroes.

class Zip: Zip product (direct sum) of one or more sweeps.

## Functions

CCNOT(...): The Tofolli gate, also known as the Controlled-Controlled-X gate.

CCX(...): The Tofolli gate, also known as the Controlled-Controlled-X gate.

CCZ(...): The Controlled-Controlled-Z gate.

CNOT(...): The controlled NOT gate.

CSWAP(...): The Controlled Swap gate, also known as the Fredkin gate.

CX(...): The controlled NOT gate.

CZ(...): The controlled Z gate.

FREDKIN(...): The Controlled Swap gate, also known as the Fredkin gate.

H(...): The Hadamard gate.

I(...): The one qubit identity gate.

ISWAP(...): The iswap gate.

ISWAP_INV(...): The inverse of the iswap gate.

KET_IMAG(...): The |i⟩ State

KET_MINUS(...): The |-⟩ State

KET_MINUS_IMAG(...): The |-i⟩ State

KET_ONE(...): The |1⟩ State

KET_PLUS(...): The |+⟩ State

KET_ZERO(...): The |0⟩ State

S(...): The Clifford S gate.

SQRT_ISWAP(...): The square root of iswap gate.

SQRT_ISWAP_INV(...): The inverse square root of iswap gate.

SWAP(...): The swap gate.

T(...): The non-Clifford T gate.

TOFFOLI(...): The Tofolli gate, also known as the Controlled-Controlled-X gate.

X(...): The Pauli X gate.

XX(...): The tensor product of two X gates.

Y(...): The Pauli Y gate.

YY(...): The tensor product of two Y gates.

Z(...): The Pauli Z gate.

ZZ(...): The tensor product of two Z gates.

act_on(...): Applies an action to a state argument.

align_left(...): Align gates to the left of the circuit.

align_right(...): Align gates to the right of the circuit.

all_near_zero(...): Checks if the tensor's elements are all near zero.

all_near_zero_mod(...): Checks if the tensor's elements are all near multiples of the period.

allclose_up_to_global_phase(...): Determines if a ~= b * exp(i t) for some t.

alternative(...): A decorator indicating an abstract method with an alternative default

amplitude_damp(...): Returns an AmplitudeDampingChannel with the given probability gamma.

apply_channel(...): High performance evolution under a channel evolution.

apply_matrix_to_slices(...): Left-multiplies an NxN matrix onto N slices of a numpy array.

apply_mixture(...): High performance evolution under a mixture of unitaries evolution.

apply_unitaries(...): Apply a series of unitaries onto a state tensor.

apply_unitary(...): High performance left-multiplication of a unitary effect onto a tensor.

approx_eq(...): Approximately compares two objects.

asymmetric_depolarize(...): Returns a AsymmetricDepolarizingChannel with given parameter.

axis_angle(...): Decomposes a single-qubit unitary into axis, angle, and global phase.

bidiagonalize_real_matrix_pair_with_symmetric_products(...): Finds orthogonal matrices that diagonalize both mat1 and mat2.

bidiagonalize_unitary_with_special_orthogonals(...): Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.

big_endian_bits_to_int(...): Returns the big-endian integer specified by the given bits.

big_endian_digits_to_int(...): Returns the big-endian integer specified by the given digits and base.

big_endian_int_to_bits(...): Returns the big-endian bits of an integer.

big_endian_int_to_digits(...): Separates an integer into big-endian digits.

bit_flip(...): Construct a BitFlipChannel that flips a qubit state with probability p.

bloch_vector_from_state_vector(...): Returns the bloch vector of a qubit.

block_diag(...): Concatenates blocks into a block diagonal matrix.

canonicalize_half_turns(...): Wraps the input into the range (-1, +1].

choi_to_kraus(...): Returns a Kraus representation of a channel with given Choi matrix.

choi_to_superoperator(...): Returns the superoperator matrix of a quantum channel specified via the Choi matrix.

chosen_angle_to_canonical_half_turns(...): Returns a canonicalized half_turns based on the given arguments.

chosen_angle_to_half_turns(...): Returns a half_turns value based on the given arguments.

circuit_diagram_info(...): Requests information on drawing an operation in a circuit diagram.

cirq_type_from_json(...): Returns a type object for JSON deserialization of type_str.

commutes(...): Determines whether two values commute.

compute_cphase_exponents_for_fsim_decomposition(...): Returns intervals of CZPowGate exponents valid for FSim decomposition.

control_keys(...): Gets the keys that the value is classically controlled by.

cphase(...): Returns a gate with the matrix diag(1, 1, 1, e^{i rads}.

create_transformer_with_kwargs(...): Method to capture additional keyword arguments to transformers while preserving mypy type.

dataclass_json_dict(...): Return a dictionary suitable for _jsondict from a dataclass.

decompose(...): Recursively decomposes a value into cirq.Operations meeting a criteria.

decompose_clifford_tableau_to_operations(...): Decompose an n-qubit Clifford Tableau into a list of one/two qubit operations.

decompose_cphase_into_two_fsim(...): Decomposes CZPowGate into two FSimGates.

decompose_multi_controlled_rotation(...): Implements action of multi-controlled unitary gate.

decompose_multi_controlled_x(...): Implements action of multi-controlled Pauli X gate.

decompose_once(...): Decomposes a value into operations, if possible.

decompose_once_with_qubits(...): Decomposes a value into operations on the given qubits.

decompose_two_qubit_interaction_into_four_fsim_gates(...): Decomposes operations into an FSimGate near theta=pi/2, phi=0.

deconstruct_single_qubit_matrix_into_angles(...): Breaks down a 2x2 unitary into more useful ZYZ angle parameters.

defer_measurements(...): Implements the Deferred Measurement Principle.

definitely_commutes(...): Determines whether two values definitely commute.

density_matrix(...): Create a QuantumState object from a density matrix.

density_matrix_from_state_vector(...): Returns the density matrix of the state vector.

density_matrix_kronecker_product(...): Merges two density matrices into a single unified density matrix.

dephase_measurements(...): Changes all measurements to a dephase operation.

depolarize(...): Returns a DepolarizingChannel with given probability of error.

diagonalize_real_symmetric_and_sorted_diagonal_matrices(...): Returns an orthogonal matrix that diagonalizes both given matrices.

diagonalize_real_symmetric_matrix(...): Returns an orthogonal matrix that diagonalizes the given matrix.

dict_to_product_sweep(...): Cartesian product of sweeps from a dictionary.

dict_to_zip_sweep(...): Zip product of sweeps from a dictionary.

dirac_notation(...): Returns the state vector as a string in Dirac notation.

dot(...): Computes the dot/matrix product of a sequence of values.

draw_gridlike(...): Draw a grid-like graph using Matplotlib.

draw_placements(...): Draw a visualization of placements from small_graph onto big_graph using Matplotlib.

drop_empty_moments(...): Removes empty moments from a circuit.

drop_negligible_operations(...): Removes operations with tiny effects.

drop_terminal_measurements(...): Removes terminal measurements from a circuit.

eject_phased_paulis(...): Transformer pass to push X, Y, PhasedX & (certain) PhasedXZ gates to the end of the circuit.

eject_z(...): Pushes Z gates towards the end of the circuit.

entanglement_fidelity(...): Returns entanglement fidelity of a given quantum channel.

equal_up_to_global_phase(...): Determine whether two objects are equal up to global phase.

estimate_parallel_single_qubit_readout_errors(...): Estimate single qubit readout error using parallel operations.

estimate_single_qubit_readout_errors(...): Estimate single-qubit readout error.

expand_composite(...): A transformer that expands composite operations via cirq.decompose.

expand_matrix_in_orthogonal_basis(...): Computes coefficients of expansion of m in basis.

eye_tensor(...): Returns an identity matrix reshaped into a tensor.

fidelity(...): Fidelity of two quantum states.

final_density_matrix(...): Returns the density matrix resulting from simulating the circuit.

final_state_vector(...): Returns the state vector resulting from acting operations on a state.

flatten(...): Creates a copy of val with any symbols or expressions replaced with

flatten_op_tree(...): Performs an in-order iteration of the operations (leaves) in an OP_TREE.

flatten_to_ops(...): Performs an in-order iteration of the operations (leaves) in an OP_TREE.

flatten_to_ops_or_moments(...): Performs an in-order iteration OP_TREE, yielding ops and moments.

flatten_with_params(...): Creates a copy of val with any symbols or expressions replaced with

flatten_with_sweep(...): Creates a copy of val with any symbols or expressions replaced with

freeze_op_tree(...): Replaces all iterables in the OP_TREE with tuples.

generalized_amplitude_damp(...): Returns a GeneralizedAmplitudeDampingChannel with probabilities gamma and p.

generate_boixo_2018_supremacy_circuits_v2(...): THIS FUNCTION IS DEPRECATED.

generate_boixo_2018_supremacy_circuits_v2_bristlecone(...): THIS FUNCTION IS DEPRECATED.

generate_boixo_2018_supremacy_circuits_v2_grid(...): THIS FUNCTION IS DEPRECATED.

get_placements(...): Get 'placements' mapping small_graph nodes onto those of big_graph.

get_state_histogram(...): Computes a state histogram from a single result with repetitions.

givens(...): Returns gate with matrix exp(-i angle_rads (Y⊗X - X⊗Y) / 2).

global_phase_operation(...): Creates an operation that represents a global phase on the state.

has_kraus(...): Returns whether the value has a Kraus representation.

has_mixture(...): Returns whether the value has a mixture representation.

has_stabilizer_effect(...): Returns whether the input has a stabilizer effect.

has_unitary(...): Determines whether the value has a unitary effect.

hilbert_schmidt_inner_product(...): Computes Hilbert-Schmidt inner product of two matrices.

hog_score_xeb_fidelity_from_probabilities(...): XEB fidelity estimator based on normalized HOG score.

identity_each(...): Returns a single IdentityGate applied to all the given qubits.

integrated_histogram(...): Plot the integrated histogram for an array of data.

inverse(...): Returns the inverse val**-1 of the given value, if defined.

is_cptp(...): Determines if a channel is completely positive trace preserving (CPTP).

is_diagonal(...): Determines if a matrix is a approximately diagonal.

is_hermitian(...): Determines if a matrix is approximately Hermitian.

is_measurement(...): Determines whether or not the given value is a measurement (or contains one).

is_native_neutral_atom_gate(...): Returns true if the gate is in the default neutral atom gateset.

is_native_neutral_atom_op(...): Returns true if the operation is in the default neutral atom gateset.

is_negligible_turn(...): Returns True is the number of turns in a gate is close to zero.

is_normal(...): Determines if a matrix is approximately normal.

is_orthogonal(...): Determines if a matrix is approximately orthogonal.

is_parameterized(...): Returns whether the object is parameterized with any Symbols.

is_special_orthogonal(...): Determines if a matrix is approximately special orthogonal.

is_special_unitary(...): Determines if a matrix is approximately unitary with unit determinant.

is_unitary(...): Determines if a matrix is approximately unitary.

is_valid_placement(...): Return whether the given placement is a valid placement of small_graph onto big_graph.

json_cirq_type(...): Returns a string type for JSON serialization of type_obj.

json_namespace(...): Returns a namespace for JSON serialization of type_obj.

kak_canonicalize_vector(...): Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.

kak_decomposition(...): Decomposes a 2-qubit unitary into 1-qubit ops and XX/YY/ZZ interactions.

kak_vector(...): Compute the KAK vectors of one or more two qubit unitaries.

kraus(...): Returns a list of matrices describing the channel for the given value.

kraus_to_choi(...): Returns the unique Choi matrix corresponding to a Kraus representation of a channel.

kraus_to_superoperator(...): Returns the matrix representation of the linear map with given Kraus operators.

kron(...): Computes the kronecker product of a sequence of values.

kron_bases(...): Creates tensor product of bases.

kron_factor_4x4_to_2x2s(...): Splits a 4x4 matrix U = kron(A, B) into A, B, and a global factor.

kron_with_controls(...): Computes the kronecker product of a sequence of values and control tags.

least_squares_xeb_fidelity_from_expectations(...): THIS FUNCTION IS DEPRECATED.

least_squares_xeb_fidelity_from_probabilities(...): THIS FUNCTION IS DEPRECATED.

linear_xeb_fidelity(...): Estimates XEB fidelity from one circuit using linear estimator.

linear_xeb_fidelity_from_probabilities(...): Linear XEB fidelity estimator.

log_xeb_fidelity(...): Estimates XEB fidelity from one circuit using logarithmic estimator.

log_xeb_fidelity_from_probabilities(...): Logarithmic XEB fidelity estimator.

map_eigenvalues(...): Applies a function to the eigenvalues of a matrix.

map_moments(...): Applies local transformation on moments, by calling map_func(moment) for each moment.

map_operations(...): Applies local transformations on operations, by calling map_func(op) for each op.

map_operations_and_unroll(...): Applies local transformations via cirq.map_operations & unrolls intermediate circuit ops.

match_global_phase(...): Phases the given matrices so that they agree on the phase of one entry.

matrix_commutes(...): Determines if two matrices approximately commute.

matrix_from_basis_coefficients(...): Computes linear combination of basis vectors with given coefficients.

measure(...): Returns a single MeasurementGate applied to all the given qubits.

measure_confusion_matrix(...): Prepares TensoredConfusionMatrices for the n qubits in the input.

measure_density_matrix(...): Performs a measurement of the density matrix in the computational basis.

measure_each(...): Returns a list of operations individually measuring the given qubits.

measure_paulistring_terms(...): Returns a list of operations individually measuring qubits in the pauli basis.

measure_single_paulistring(...): Returns a single PauliMeasurementGate which measures the pauli observable

measure_state_vector(...): Performs a measurement of the state in the computational basis.

measurement_key_name(...): Get the single measurement key for the given value.

measurement_key_names(...): Gets the measurement key strings of measurements within the given value.

measurement_key_obj(...): Get the single measurement key object for the given value.

measurement_key_objs(...): Gets the measurement key objects of measurements within the given value.

measurement_keys_touched(...): Returns all the measurement keys used by the value.

merge_k_qubit_unitaries(...): Merges connected components of unitary operations, acting on <= k qubits.

merge_k_qubit_unitaries_to_circuit_op(...): Merges connected components of operations, acting on <= k qubits, into circuit operations.

merge_moments(...): Merges adjacent moments, one by one from left to right, by calling merge_func(m1, m2).

merge_operations(...): Merges operations in a circuit by calling merge_func iteratively on operations.

merge_operations_to_circuit_op(...): Merges connected components of operations and wraps each component into a circuit operation.

merge_single_qubit_gates_into_phased_x_z(...): THIS FUNCTION IS DEPRECATED.

merge_single_qubit_gates_into_phxz(...): THIS FUNCTION IS DEPRECATED.

merge_single_qubit_gates_to_phased_x_and_z(...): Replaces runs of single qubit rotations with cirq.PhasedXPowGate and cirq.ZPowGate.

merge_single_qubit_gates_to_phxz(...): Replaces runs of single qubit rotations with a single optional cirq.PhasedXZGate.

merge_single_qubit_moments_to_phxz(...): Merges adjacent moments with only 1-qubit rotations to a single moment with PhasedXZ gates.

mixture(...): Return a sequence of tuples representing a probabilistic unitary.

ms(...): A helper to construct the cirq.MSGate for the given angle specified in radians.

mul(...): Returns lhs * rhs, or else a default if the operator is not implemented.

num_cnots_required(...): Returns the min number of CNOT/CZ gates required by a two-qubit unitary.

num_qubits(...): Returns the number of qubits, qudits, or qids val operates on.

obj_to_dict_helper(...): Construct a dictionary containing attributes from obj

one_hot(...): Returns a numpy array with all 0s and a single non-zero entry(default 1).

operation_to_choi(...): Returns the unique Choi matrix associated with an operation .

operation_to_superoperator(...): Returns the matrix representation of an operation in standard basis.

optimize_for_target_gateset(...): Transforms the given circuit into an equivalent circuit using gates accepted by gateset.

parallel_gate_op(...): Constructs a ParallelGate using gate and applies to all given qubits

parameter_names(...): Returns parameter names for this object.

parameter_symbols(...): Returns parameter symbols for this object.

parameterized_2q_op_to_sqrt_iswap_operations(...): Tries to decompose a parameterized 2q operation into √iSWAP's + parameterized 1q rotations.

partial_trace(...): Takes the partial trace of a given tensor.

partial_trace_of_state_vector_as_mixture(...): Returns a mixture representing a state vector with only some qubits kept.

pauli_expansion(...): Returns coefficients of the expansion of val in the Pauli basis.

phase_by(...): Returns a phased version of the effect.

phase_damp(...): Creates a PhaseDampingChannel with damping constant gamma.

phase_flip(...): Returns a PhaseFlipChannel that flips a qubit's phase with probability p.

plot_density_matrix(...): Generates a plot for a given density matrix.

plot_state_histogram(...): Plot the state histogram from either a single result with repetitions or

pow(...): Returns val**factor of the given value, if defined.

pow_pauli_combination(...): Computes non-negative integer power of single-qubit Pauli combination.

prepare_two_qubit_state_using_cz(...): Prepares the given 2q state from |00> using at-most 1 CZ gate + single qubit rotations.

prepare_two_qubit_state_using_sqrt_iswap(...): Prepares the given 2q state from |00> using at-most 1 √iSWAP gate + single qubit rotations.

q(...): Constructs a qubit id of the appropriate type based on args.

qasm(...): Returns QASM code for the given value, if possible.

qft(...): The quantum Fourier transform.

qid_shape(...): Returns a tuple describing the number of quantum levels of each

quantum_state(...): Create a QuantumState object from a state-like object.

quil(...): THIS FUNCTION IS DEPRECATED.

quirk_json_to_circuit(...): Constructs a Cirq circuit from Quirk's JSON format.

quirk_url_to_circuit(...): Parses a Cirq circuit out of a Quirk URL.

read_json(...): Read a JSON file that optionally contains cirq objects.

read_json_gzip(...): Read a gzipped JSON file that optionally contains cirq objects.

reflection_matrix_pow(...): Raises a matrix with two opposing eigenvalues to a power.

reset(...): Returns a ResetChannel on the given qubit.

reset_each(...): Returns a list of ResetChannel instances on the given qubits.

resolve_parameters(...): Resolves symbol parameters in the effect using the param resolver.

resolve_parameters_once(...): Performs a single parameter resolution step using the param resolver.

riswap(...): Returns gate with matrix exp(+i angle_rads (X⊗X + Y⊗Y) / 2).

rx(...): Returns a gate with the matrix $$e^{-i X t / 2}$$ where $$t=rads$$.

ry(...): Returns a gate with the matrix $$e^{-i Y t / 2}$$ where $$t=rads$$.

rz(...): Returns a gate with the matrix $$e^{-i Z t / 2}$$ where $$t=rads$$.

sample(...): Simulates sampling from the given circuit.

sample_density_matrix(...): Samples repeatedly from measurements in the computational basis.

sample_state_vector(...): Samples repeatedly from measurements in the computational basis.

sample_sweep(...): Runs the supplied Circuit, mimicking quantum hardware.

scatter_plot_normalized_kak_interaction_coefficients(...): Plots the interaction coefficients of many two-qubit operations.

single_qubit_matrix_to_gates(...): Implements a single-qubit operation with few gates.

single_qubit_matrix_to_pauli_rotations(...): Implements a single-qubit operation with few rotations.

single_qubit_matrix_to_phased_x_z(...): Implements a single-qubit operation with a PhasedX and Z gate.

single_qubit_matrix_to_phxz(...): Implements a single-qubit operation with a PhasedXZ gate.

single_qubit_op_to_framed_phase_form(...): Decomposes a 2x2 unitary M into U^-1 * diag(1, r) * U * diag(g, g).

slice_for_qubits_equal_to(...): Returns an index corresponding to a desired subset of an np.ndarray.

so4_to_magic_su2s(...): Finds 2x2 special-unitaries A, B where mat = Mag.H @ kron(A, B) @ Mag.

state_vector_kronecker_product(...): Merges two state vectors into a single unified state vector.

state_vector_to_probabilities(...): Function to transform a state vector like object into a numpy array of probabilities.

stratified_circuit(...): Repacks avoiding simultaneous operations with different classes.

sub_state_vector(...): Attempts to factor a state vector into two parts and return one of them.

superoperator_to_choi(...): Returns the Choi matrix of a quantum channel specified via the superoperator matrix.

superoperator_to_kraus(...): Returns a Kraus representation of a channel specified via the superoperator matrix.

synchronize_terminal_measurements(...): Move measurements to the end of the circuit.

targeted_conjugate_about(...): Conjugates the given tensor about the target tensor.

targeted_left_multiply(...): Left-multiplies the given axes of the target tensor by the given matrix.

three_qubit_matrix_to_operations(...): Returns operations for a 3 qubit unitary.

to_json(...): Write a JSON file containing a representation of obj.

to_json_gzip(...): Write a gzipped JSON file containing a representation of obj.

to_resolvers(...): Convert a Sweepable to a list of ParamResolvers.

to_special(...): Converts a unitary matrix to a special unitary matrix.

to_sweep(...): Converts the argument into a <a href="./cirq/Sweep"><code>cirq.Sweep</code></a>.

to_sweeps(...): Converts a Sweepable to a list of Sweeps.

to_valid_density_matrix(...): Verifies the density_matrix_rep is valid and converts it to ndarray form.

to_valid_state_vector(...): Verifies the state_rep is valid and converts it to ndarray form.

toggle_tags(...): Toggles tags applied on each operation in the circuit, via op.tags ^= tags

trace_distance_bound(...): Returns a maximum on the trace distance between this effect's input

trace_distance_from_angle_list(...): Given a list of arguments of the eigenvalues of a unitary matrix,

transform_op_tree(...): Maps transformation functions onto the nodes of an OP_TREE.

transformer(...): Decorator to verify API and append logging functionality to transformer functions & classes.

two_qubit_gate_product_tabulation(...): Generate a TwoQubitGateTabulation for a base two qubit unitary.

two_qubit_matrix_to_cz_operations(...): Decomposes a two-qubit operation into Z/XY/CZ gates.

two_qubit_matrix_to_diagonal_and_cz_operations(...): Decomposes a 2-qubit unitary to a diagonal and the remaining operations.

two_qubit_matrix_to_ion_operations(...): Decomposes a two-qubit operation into MS/single-qubit rotation gates.

two_qubit_matrix_to_sqrt_iswap_operations(...): Decomposes a two-qubit operation into ZPow/XPow/YPow/sqrt-iSWAP gates.

unitary(...): Returns a unitary matrix describing the given value.

unitary_eig(...): Gives the guaranteed unitary eigendecomposition of a normal matrix.

unroll_circuit_op(...): Unrolls (tagged) cirq.CircuitOperations while preserving the moment structure.

unroll_circuit_op_greedy_earliest(...): Unrolls (tagged) cirq.CircuitOperations by inserting operations using EARLIEST strategy.

unroll_circuit_op_greedy_frontier(...): Unrolls (tagged) cirq.CircuitOperations by inserting operations inline at qubit frontier.

validate_density_matrix(...): Checks that the given density matrix is valid.

validate_indices(...): Validates that the indices have values within range of num_qubits.

validate_mixture(...): Validates that the mixture's tuple are valid probabilities.

validate_normalized_state_vector(...): Checks that the given state vector is valid.

validate_probability(...): Validates that a probability is between 0 and 1 inclusively.

validate_qid_shape(...): Validates the size of the given state_vector against the given shape.

value_equality(...): Implements eq/ne/hash via a _value_equalityvalues method.

von_neumann_entropy(...): Calculates the von Neumann entropy of a quantum state in bits.

wait(...): Creates a WaitGate applied to all the given qubits.

with_key_path(...): Adds the path to the target's measurement keys.

with_key_path_prefix(...): Prefixes the path to the target's measurement keys.

with_measurement_key_mapping(...): Remaps the target's measurement keys according to the provided key_map.

with_rescoped_keys(...): Rescopes any measurement and control keys to the provided path, given the existing keys.

xeb_fidelity(...): Estimates XEB fidelity from one circuit using user-supplied estimator.

## Type Aliases

CIRCUIT_LIKE

DURATION_LIKE

LabelEntity

NOISE_MODEL_LIKE

OP_TREE

PAULI_GATE_LIKE

PAULI_STRING_LIKE

ParamDictType

ParamMappingType

ParamResolverOrSimilarType

PauliSumLike

QUANTUM_STATE_LIKE

QubitOrderOrList

STATE_VECTOR_LIKE

Sweepable

TParamKey

TParamVal

TParamValComplex

CONTROL_TAG Instance of numpy.ndarray

A special indicator value for cirq.kron_with_controls.

This value is a stand-in for "control operations on the other qubits based
on the value of this qubit", which otherwise doesn't have a proper matrix.


DEFAULT_RESOLVERS [<function _lazy_resolver.<locals>.json_resolver>, <function _lazy_resolver.<locals>.json_resolver>, <function _lazy_resolver.<locals>.json_resolver>, <function _lazy_resolver.<locals>.json_resolver>, <function _lazy_resolver.<locals>.json_resolver>]
MEASUREMENT_KEY_SEPARATOR ':'
NO_NOISE Instance of cirq.devices.noise_model._NoNoiseModel

The trivial noise model with no effects.

This is the noise model used when a NOISE_MODEL_LIKE noise parameter is set to None.

PAULI_BASIS

{
'I': array([[1., 0.],
[0., 1.]]),
'X': array([[0., 1.],
[1., 0.]]),
'Y': array([[ 0.+0.j, -0.-1.j],
[ 0.+1.j,  0.+0.j]]),
'Z': array([[ 1.,  0.],
[ 0., -1.]])
}


The four Pauli matrices (including identity) keyed by character.

PAULI_STATES [cirq.X.basis[+1], cirq.X.basis[-1], cirq.Y.basis[+1], cirq.Y.basis[-1], cirq.Z.basis[+1], cirq.Z.basis[-1]]

All one-qubit states stabalized by the pauli operators.

UNCONSTRAINED_DEVICE Instance of cirq.devices.unconstrained_device._UnconstrainedDevice

A device with no constraints on operations or qubits.

UnitSweep Instance of cirq.study.sweeps._Unit

The singleton sweep with no parameters.

version '0.15.0'

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]