API Reference

Devices and Qubits

Classes for identifying the qubits and hardware you want to operate on.

cirq.UNCONSTRAINED_DEVICE

A device with no constraints on operations or qubits.

cirq.Device()

Hardware constraints for validating circuits.

cirq.GridQid(row, col, *, dimension)

A qid on a 2d square lattice

cirq.GridQubit(row, col)

A qubit on a 2d square lattice.

cirq.LineQid(x, dimension)

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

cirq.LineQubit(x)

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

cirq.NamedQid(name, dimension)

A qid identified by name.

cirq.NamedQubit(name)

A qubit identified by name.

cirq.Qid()

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

Measurement

Methods and classes for performing measurement operations.

cirq.measure(*target[, key, invert_mask])

Returns a single MeasurementGate applied to all the given qubits.

cirq.measure_each(*qubits[, key_func])

Returns a list of operations individually measuring the given qubits.

cirq.MeasurementGate(num_qubits, key, …)

A gate that measures qubits in the computational basis.

Unitary Gates and Operations

Unitary effects that can be applied to one or more qubits.

cirq.H

The Hadamard gate.

cirq.I

The one qubit identity gate.

cirq.S

The Clifford S gate.

cirq.T

The non-Clifford T gate.

cirq.X

The Pauli X gate.

cirq.Y

The Pauli Y gate.

cirq.Z

The Pauli Z gate.

cirq.CX

The controlled NOT gate.

cirq.CZ

The controlled Z gate.

cirq.XX

The tensor product of two X gates.

cirq.YY

The tensor product of two Y gates.

cirq.ZZ

The tensor product of two Z gates.

cirq.rx(rads)

Returns a gate with the matrix e^{-i X rads / 2}.

cirq.ry(rads)

Returns a gate with the matrix e^{-i Y rads / 2}.

cirq.rz(rads)

Returns a gate with the matrix e^{-i Z rads / 2}.

cirq.CCNOT

The TOFFOLI gate.

cirq.CCX

The TOFFOLI gate.

cirq.CCZ

The Controlled-Controlled-Z gate.

cirq.CNOT

The controlled NOT gate.

cirq.CSWAP

The Controlled Swap gate.

cirq.FREDKIN

The Controlled Swap gate.

cirq.ISWAP

The iswap gate.

cirq.SWAP

The swap gate.

cirq.TOFFOLI

The TOFFOLI gate.

cirq.cphase(rads)

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

cirq.givens(angle_rads)

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

cirq.identity_each(*qubits)

Returns a single IdentityGate applied to all the given qubits.

cirq.qft(*qubits[, without_reverse, inverse])

The quantum Fourier transform.

cirq.riswap(rads)

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

cirq.CCXPowGate(*, exponent, …)

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

cirq.CCZPowGate(*, exponent, …)

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

cirq.CSwapGate()

A controlled swap gate.

cirq.CXPowGate(*, exponent, …)

A gate that applies a controlled power of an X gate.

cirq.CZPowGate(*, exponent, …)

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

cirq.ControlledGate(sub_gate, num_controls, …)

Augments existing gates to have one or more control qubits.

cirq.ControlledOperation(controls, …)

Augments existing operations to have one or more control qubits.

cirq.EigenGate(*, exponent, …)

A gate with a known eigendecomposition.

cirq.FSimGate(theta, phi)

Fermionic simulation gate family.

cirq.Gate()

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

cirq.GlobalPhaseOperation(coefficient, atol)

cirq.HPowGate(*, exponent, …)

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

cirq.ISwapPowGate(*, exponent, …)

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

cirq.IdentityGate(num_qubits, qid_shape, …)

A Gate that perform no operation on qubits.

cirq.MatrixGate(matrix, *, qid_shape)

A unitary qubit or qudit gate defined entirely by its matrix.

cirq.Operation()

An effect applied to a collection of qubits.

cirq.PhaseGradientGate(*, num_qubits, …)

Phases each state |k⟩ out of n by e^(2piik/nexponent).

cirq.PhasedISwapPowGate(*, phase_exponent, …)

Fractional ISWAP conjugated by Z rotations.

cirq.PhasedXPowGate(*, phase_exponent, …)

A gate equivalent to the circuit ───Z^-p───X^t───Z^p───.

cirq.PhasedXZGate(*, x_exponent, …)

A single qubit operation expressed as $Z^z Z^a X^x Z^{-a}$.

cirq.QuantumFourierTransformGate(num_qubits, …)

Switches from the computational basis to the frequency basis.

cirq.QubitPermutationGate(permutation)

A qubit permutation gate specified by a permutation list.

cirq.RandomGateChannel(*, sub_gate, …)

Applies a sub gate with some probability.

cirq.SingleQubitGate()

A gate that must be applied to exactly one qubit.

cirq.SwapPowGate(*, exponent, …)

The SWAP gate, possibly raised to a power.

cirq.TaggedOperation(sub_operation, *tags)

A specific operation instance that has been identified with a set

cirq.ThreeQubitDiagonalGate(…)

A gate given by a diagonal 8x8 matrix.

cirq.ThreeQubitGate()

A gate that must be applied to exactly three qubits.

cirq.TwoQubitDiagonalGate(…)

A gate given by a diagonal 4\times 4 matrix.

cirq.TwoQubitGate()

A gate that must be applied to exactly two qubits.

cirq.WaitGate(duration)

A single-qubit idle gate that represents waiting.

cirq.XPowGate(*, exponent, …)

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

cirq.XXPowGate(*, exponent, …)

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

cirq.YPowGate(*, exponent, …)

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

cirq.YYPowGate(*, exponent, …)

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

cirq.ZPowGate(*, exponent, …)

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

cirq.ZZPowGate(*, exponent, …)

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

Noisy Gates and Operations

Non-unitary gates. Mixture gates are those that can be interpreted as applying a unitary for a fixed probability while channel encompasses the more general concept of a noisy open system quantum evolution.

cirq.NOISE_MODEL_LIKE

A cirq.NoiseModel or a value that can be trivially converted into one.

cirq.NO_NOISE

The trivial noise model with no effects.

cirq.amplitude_damp(gamma)

Returns an AmplitudeDampingChannel with the given probability gamma.

cirq.asymmetric_depolarize(p_x, p_y, p_z)

Returns a AsymmetricDepolarizingChannel with given parameter.

cirq.bit_flip([p])

Construct a BitFlipChannel that flips a qubit state with probability

cirq.depolarize(p)

Returns a DepolarizingChannel with given probability of error.

cirq.generalized_amplitude_damp(p, gamma)

Returns a GeneralizedAmplitudeDampingChannel with the given

cirq.phase_damp(gamma)

Creates a PhaseDampingChannel with damping constant gamma.

cirq.phase_flip([p])

Returns a PhaseFlipChannel that flips a qubit’s phase with probability

cirq.reset(qubit)

Returns a ResetChannel on the given qubit.

cirq.AmplitudeDampingChannel(gamma)

Dampen qubit amplitudes through dissipation.

cirq.AsymmetricDepolarizingChannel(p_x, p_y, p_z)

A channel that depolarizes asymmetrically along different directions.

cirq.BitFlipChannel(p)

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

cirq.DepolarizingChannel(p)

A channel that depolarizes a qubit.

cirq.GeneralizedAmplitudeDampingChannel(p, gamma)

Dampen qubit amplitudes through non ideal dissipation.

cirq.NoiseModel()

Replaces operations and moments with noisy counterparts.

cirq.PhaseDampingChannel(gamma)

Dampen qubit phase.

cirq.PhaseFlipChannel(p)

Probabilistically flip the sign of the phase of a qubit.

cirq.ResetChannel(dimension)

Reset a qubit back to its |0⟩ state.

cirq.VirtualTag()

A TaggedOperation tag indicating that the operation is virtual.

Pauli and Clifford Groups

Classes and methods related to representing and operating on states using sums and products of Pauli operations.

cirq.PAULI_BASIS

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

cirq.PAULI_GATE_LIKE

An object that can be interpreted as a Pauli gate.

cirq.PAULI_STRING_LIKE

A cirq.PauliString or a value that can easily be converted into one.

cirq.pow_pauli_combination(ai, ax, ay, az, …)

Computes non-negative integer power of single-qubit Pauli combination.

cirq.BaseDensePauliString(pauli_mask, …)

Parent class for DensePauliString and MutableDensePauliString.

cirq.CliffordState(qubit_map[, initial_state])

A state of the Clifford simulation.

cirq.CliffordTableau(num_qubits, initial_state)

Tableau representation of a stabilizer state

cirq.DensePauliString(pauli_mask, …)

cirq.MutableDensePauliString(pauli_mask, …)

cirq.MutablePauliString(*contents, …)

cirq.Pauli(index, name)

Represents the Pauli gates.

cirq.PauliInteractionGate(pauli0, invert0, …)

A CZ conjugated by arbitrary single qubit Cliffords.

cirq.PauliString(*contents, cirq.OP_TREE, …)

cirq.PauliStringGateOperation(pauli_string)

cirq.PauliStringPhasor(pauli_string, *, …)

An operation that phases the eigenstates of a Pauli string.

cirq.PauliSum(linear_dict, …)

Represents operator defined by linear combination of PauliStrings.

cirq.PauliSumLike

Any value that can be easily translated into a sum of Pauli products.

cirq.PauliTransform(to, flip)

+X, -X, +Y, -Y, +Z, or -Z.

cirq.SingleQubitCliffordGate(*, …)

Any single qubit Clifford rotation.

cirq.StabilizerStateChForm(num_qubits, …)

A representation of stabilizer states using the CH form,

Circuits

Utilities for representing and manipulating quantum computations via Circuits, Operations, and Moments.

cirq.OP_TREE

An operation or nested collections of operations.

cirq.flatten_op_tree(root[, preserve_moments])

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

cirq.freeze_op_tree(root)

Replaces all iterables in the OP_TREE with tuples.

cirq.transform_op_tree(root[, …])

Maps transformation functions onto the nodes of an OP_TREE.

cirq.Circuit(*contents, …)

A mutable list of groups of operations to apply to some qubits.

cirq.CircuitDag(can_reorder, …)

A representation of a Circuit as a directed acyclic graph.

cirq.GateOperation(gate, qubits)

An application of a gate to a sequence of qubits.

cirq.InsertStrategy(name, doc)

Indicates preferences on how to add multiple operations to a circuit.

cirq.Moment(**kwargs)

A time-slice of operations within a circuit.

cirq.ParallelGateOperation(gate, qubits)

An application of several copies of a gate to a group of qubits.

cirq.QubitOrder(explicit_func, …)

Defines the kronecker product order of qubits.

cirq.QubitOrderOrList

Specifies a qubit ordering.

cirq.Unique(*args, **kwds)

A wrapper for a value that doesn’t compare equal to other instances.

Importing and Exporting

Utilities for interoperating with other quantum software libraries and products.

cirq.quirk_json_to_circuit(data, *[, …])

Constructs a Cirq circuit from Quirk’s JSON format.

cirq.quirk_url_to_circuit(quirk_url, *[, …])

Parses a Cirq circuit out of a Quirk URL.

Sampling, Simulations, and Data Collection

Objects for collecting data about a quantum circuit. Includes methods and classes for defining parameter sweeps, performing simulations, and analyzing results.

cirq.CIRCUIT_LIKE

A circuits.Circuit or a value that can be trivially converted into

cirq.RANDOM_STATE_OR_SEED_LIKE

A pseudorandom number generator or object that can be converted to one.

cirq.big_endian_bits_to_int(bits)

Returns the big-endian integer specified by the given bits.

cirq.big_endian_digits_to_int(digits, *, base)

Returns the big-endian integer specified by the given digits and base.

cirq.big_endian_int_to_bits(val, *, bit_count)

Returns the big-endian bits of an integer.

cirq.big_endian_int_to_digits()

Separates an integer into big-endian digits.

cirq.dict_to_product_sweep(factor_dict)

Cartesian product of sweeps from a dictionary.

cirq.dict_to_zip_sweep(factor_dict)

Zip product of sweeps from a dictionary.

cirq.final_density_matrix(program, *[, …])

Returns the density matrix resulting from simulating the circuit.

cirq.final_state_vector(program, *[, …])

Returns the state vector resulting from acting operations on a state.

cirq.flatten(val)

Creates a copy of val with any symbols or expressions replaced

cirq.flatten_to_ops(root)

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

cirq.flatten_to_ops_or_moments(root)

Performs an in-order iteration OP_TREE, yielding ops and moments.

cirq.flatten_with_params(val, params)

Creates a copy of val with any symbols or expressions replaced

cirq.flatten_with_sweep(val, sweep)

Creates a copy of val with any symbols or expressions replaced

cirq.hog_score_xeb_fidelity_from_probabilities(…)

XEB fidelity estimator based on normalized HOG score.

cirq.measure_density_matrix(density_matrix, …)

Performs a measurement of the density matrix in the computational basis.

cirq.measure_state_vector(state_vector, …)

Performs a measurement of the state in the computational basis.

cirq.sample(program, *[, noise, …])

Simulates sampling from the given circuit.

cirq.sample_density_matrix(density_matrix, …)

Samples repeatedly from measurements in the computational basis.

cirq.sample_state_vector(state_vector, …)

Samples repeatedly from measurements in the computational basis.

cirq.sample_sweep(program, params, *[, …])

Runs the supplied Circuit, mimicking quantum hardware.

cirq.to_resolvers(sweepable)

Convert a Sweepable to a list of ParamResolvers.

cirq.to_sweep(sweep_or_resolver_list)

Converts the argument into a cirq.Sweep.

cirq.to_sweeps(sweepable)

Converts a Sweepable to a list of Sweeps.

cirq.validate_mixture(supports_mixture)

Validates that the mixture’s tuple are valid probabilities.

cirq.validate_probability(p, p_str)

Validates that a probability is between 0 and 1 inclusively.

cirq.xeb_fidelity(circuit, bitstrings[, …])

Estimates XEB fidelity from one circuit using user-supplied estimator.

cirq.ActOnCliffordTableauArgs(tableau, axes, …)

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

cirq.ActOnStabilizerCHFormArgs(state, axes)

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

cirq.ActOnStateVectorArgs(target_tensor, …)

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

cirq.CircuitSampleJob(circuit, *, …)

Describes a sampling task.

cirq.CliffordSimulator(seed)

An efficient simulator for Clifford circuits.

cirq.CliffordSimulatorStepResult(state, …)

A StepResult that includes StateVectorMixin methods.

cirq.CliffordTrialResult(params, …)

cirq.Collector()

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

cirq.DensityMatrixSimulator(*, dtype, noise, …)

A simulator for density matrices and noisy quantum circuits.

cirq.DensityMatrixSimulatorState(…)

The simulator state for DensityMatrixSimulator

cirq.DensityMatrixStepResult(density_matrix, …)

A single step in the simulation of the DensityMatrixSimulator.

cirq.DensityMatrixTrialResult(params, …)

A SimulationTrialResult for DensityMatrixSimulator runs.

cirq.ExpressionMap(*args, **kwargs)

A dictionary with sympy expressions and symbols for keys and sympy

cirq.Linspace(key, start, stop, length)

A simple sweep over linearly-spaced values.

cirq.ListSweep(resolver_list, …)

A wrapper around a list of ParamResolvers.

cirq.ParamResolver(param_dict)

Resolves parameters to actual values.

cirq.ParamResolverOrSimilarType

Something that can be used to turn parameters into values.

cirq.PauliSumCollector(circuit, observable, …)

Estimates the energy of a linear combination of Pauli observables.

cirq.Points(key, points)

A simple sweep with explicitly supplied values.

cirq.Product(*factors)

Cartesian product of one or more sweeps.

cirq.Sampler()

Something capable of sampling quantum circuits.

cirq.SimulatesAmplitudes()

Simulator that computes final amplitudes of given bitstrings.

cirq.SimulatesFinalState()

Simulator that allows access to the simulator’s final state.

cirq.SimulatesIntermediateState()

A SimulatesFinalState that simulates a circuit by moments.

cirq.SimulatesIntermediateStateVector()

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

cirq.SimulatesSamples()

Simulator that mimics running on quantum hardware.

cirq.SimulationTrialResult(params, …)

Results of a simulation by a SimulatesFinalState.

cirq.Simulator(*, dtype, seed)

A sparse matrix state vector simulator that uses numpy.

cirq.SparseSimulatorStep(state_vector, …)

A StepResult that includes StateVectorMixin methods.

cirq.StateVectorMixin(qubit_map, …)

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

cirq.StateVectorSimulatorState(state_vector, …)

cirq.StateVectorStepResult(measurements, …)

cirq.StateVectorTrialResult(params, …)

A SimulationTrialResult that includes the StateVectorMixin methods.

cirq.StepResult(measurements, List[int]]] = None)

Results of a step of a SimulatesIntermediateState.

cirq.Sweep()

A sweep is an iterator over ParamResolvers.

cirq.Sweepable

An object or collection of objects representing a parameter sweep.

cirq.TrialResult(*, params, measurements, …)

The results of multiple executions of a circuit with fixed parameters.

cirq.UnitSweep

The singleton sweep with no parameters.

cirq.ZerosSampler(device)

A dummy sampler for testing.

cirq.Zip(*sweeps)

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

Visualization

Classes and methods for visualizing data.

cirq.plot_state_histogram(result)

Plot the state histogram from a single result with repetitions.

cirq.scatter_plot_normalized_kak_interaction_coefficients(…)

Plots the interaction coefficients of many two-qubit operations.

cirq.Heatmap(value_map, SupportsFloat], …)

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

cirq.TextDiagramDrawer(entries, int], …)

A utility class for creating simple text diagrams.

Magic Method Protocols

A magic method is a special named method, like _unitary_, that a class can implement in order to indicate it supports certain functionality. There will be a corresponding global method, such as cirq.unitary, for easily accessing this functionality.

Classes that being with Supports are templates demonstrating and documenting the magic methods that can be implemented.

cirq.DEFAULT_RESOLVERS

list() -> new empty list

cirq.act_on(action, args, *[, allow_decompose])

Applies an action to a state argument.

cirq.apply_channel(val, args[, default])

High performance evolution under a channel evolution.

cirq.apply_mixture(val, args, *[, default])

High performance evolution under a mixture of unitaries evolution.

cirq.apply_unitaries(unitary_values, qubits)

Apply a series of unitaries onto a state tensor.

cirq.apply_unitary(unitary_value, args[, …])

High performance left-multiplication of a unitary effect onto a tensor.

cirq.approx_eq(val, other, *[, atol])

Approximately compares two objects.

cirq.channel(val[, default])

Returns a list of matrices describing the channel for the given value.

cirq.circuit_diagram_info()

Requests information on drawing an operation in a circuit diagram.

cirq.compute_cphase_exponents_for_fsim_decomposition(…)

Returns intervals of CZPowGate exponents valid for FSim decomposition.

cirq.decompose()

Recursively decomposes a value into cirq.Operations meeting a criteria.

cirq.decompose_cphase_into_two_fsim(…[, …])

Decomposes CZPowGate into two FSimGates.

cirq.decompose_once()

Decomposes a value into operations, if possible.

cirq.decompose_once_with_qubits()

Decomposes a value into operations on the given qubits.

cirq.equal_up_to_global_phase(val, other, *)

Determine whether two objects are equal up to global phase.

cirq.has_channel(val, *[, allow_decompose])

Returns whether the value has a channel representation.

cirq.has_mixture(val, *[, allow_decompose])

Returns whether the value has a mixture representation.

cirq.has_stabilizer_effect(val)

Returns whether the input has a stabilizer effect.

cirq.has_unitary(val, *[, allow_decompose])

Determines whether the value has a unitary effect.

cirq.inverse()

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

cirq.is_measurement(val)

Determines whether or not the given value is a measurement.

cirq.is_parameterized(val)

Returns whether the object is parameterized with any Symbols.

cirq.measurement_key(val[, default])

Get the single measurement key for the given value.

cirq.measurement_keys(val, *[, allow_decompose])

Gets the measurement keys of measurements within the given value.

cirq.mixture(val[, default])

Return a sequence of tuples representing a probabilistic unitary.

cirq.mul(lhs, rhs[, default])

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

cirq.num_qubits(val[, default])

Returns the number of qubits, qudits, or qids val operates on.

cirq.parameter_names(val)

Returns parameter names for this object.

cirq.parameter_symbols(val)

Returns parameter symbols for this object.

cirq.pauli_expansion(val, *[, default, atol])

Returns coefficients of the expansion of val in the Pauli basis.

cirq.phase_by(val, phase_turns, qubit_index)

Returns a phased version of the effect.

cirq.pow()

Returns val**factor of the given value, if defined.

cirq.qasm(val, *[, args, qubits, default])

Returns QASM code for the given value, if possible.

cirq.qid_shape(val[, default])

Returns a tuple describing the number of quantum levels of each

cirq.quil(val, *[, qubits, formatter])

Returns the QUIL code for the given value.

cirq.read_json([file_or_fn, json_text, …])

Read a JSON file that optionally contains cirq objects.

cirq.resolve_parameters(val, param_resolver)

Resolves symbol parameters in the effect using the param resolver.

cirq.to_json()

Write a JSON file containing a representation of obj.

cirq.trace_distance_bound(val)

Returns a maximum on the trace distance between this effect’s input

cirq.trace_distance_from_angle_list(angle_list)

Given a list of arguments of the eigenvalues of a unitary matrix,

cirq.unitary(val[, default])

Returns a unitary matrix describing the given value.

cirq.ApplyChannelArgs(target_tensor, …)

Arguments for efficiently performing a channel.

cirq.ApplyMixtureArgs(target_tensor, …)

Arguments for performing a mixture of unitaries.

cirq.ApplyUnitaryArgs(target_tensor, …)

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

cirq.CircuitDiagramInfo(wire_symbols, …)

Describes how to draw an operation in a circuit diagram.

cirq.CircuitDiagramInfoArgs(known_qubits, …)

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

cirq.QasmArgs(precision, version, …)

cirq.QasmOutput(operations, qubits, …], …)

cirq.QuilFormatter(qubit_id_map, str], …)

A unique formatter to correctly output values to QUIL.

cirq.QuilOutput(operations, …)

An object for passing operations and qubits then outputting them to

cirq.SupportsActOn(*args, **kwds)

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

cirq.SupportsApplyChannel(*args, **kwds)

An object that can efficiently implement a channel.

cirq.SupportsApplyMixture(*args, **kwds)

An object that can efficiently implement a mixture.

cirq.SupportsApproximateEquality(*args, **kwds)

Object which can be compared approximately.

cirq.SupportsChannel(*args, **kwds)

An object that may be describable as a quantum channel.

cirq.SupportsCircuitDiagramInfo(*args, **kwds)

A diagrammable operation on qubits.

cirq.SupportsCommutes(*args, **kwds)

An object that can determine commutation relationships vs others.

cirq.SupportsConsistentApplyUnitary(*args, …)

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

cirq.SupportsDecompose(*args, **kwds)

An object that can be decomposed into simpler operations.

cirq.SupportsDecomposeWithQubits(*args, **kwds)

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

cirq.SupportsEqualUpToGlobalPhase(*args, **kwds)

Object which can be compared for equality mod global phase.

cirq.SupportsExplicitHasUnitary(*args, **kwds)

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

cirq.SupportsExplicitNumQubits(*args, **kwds)

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

cirq.SupportsExplicitQidShape(*args, **kwds)

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

cirq.SupportsJSON(*args, **kwds)

An object that can be turned into JSON dictionaries.

cirq.SupportsMeasurementKey(*args, **kwds)

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

cirq.SupportsMixture(*args, **kwds)

An object that decomposes into a probability distribution of unitaries.

cirq.SupportsParameterization(*args, **kwds)

An object that can be parameterized by Symbols and resolved

cirq.SupportsPauliExpansion(*args, **kwds)

An object that knows its expansion in the Pauli basis.

cirq.SupportsPhase(*args, **kwds)

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

cirq.SupportsQasm(*args, **kwds)

An object that can be turned into QASM code.

cirq.SupportsQasmWithArgs(*args, **kwds)

An object that can be turned into QASM code.

cirq.SupportsQasmWithArgsAndQubits(*args, **kwds)

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

cirq.SupportsTraceDistanceBound(*args, **kwds)

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

cirq.SupportsUnitary(*args, **kwds)

An object that may be describable by a unitary matrix.

Optimization

Classes and methods for rewriting circuits.

cirq.decompose_multi_controlled_rotation(…)

Implements action of multi-controlled unitary gate.

cirq.decompose_multi_controlled_x(controls, …)

Implements action of multi-controlled Pauli X gate.

cirq.decompose_two_qubit_interaction_into_four_fsim_gates_via_b(…)

Decomposes operations into an FSimGate near theta=pi/2, phi=0.

cirq.merge_single_qubit_gates_into_phased_x_z(circuit)

Canonicalizes runs of single-qubit rotations in a circuit.

cirq.merge_single_qubit_gates_into_phxz(circuit)

Canonicalizes runs of single-qubit rotations in a circuit.

cirq.single_qubit_matrix_to_gates(mat[, …])

Implements a single-qubit operation with few gates.

cirq.single_qubit_matrix_to_pauli_rotations(mat)

Implements a single-qubit operation with few rotations.

cirq.single_qubit_matrix_to_phased_x_z(mat)

Implements a single-qubit operation with a PhasedX and Z gate.

cirq.single_qubit_matrix_to_phxz(mat[, atol])

Implements a single-qubit operation with a PhasedXZ gate.

cirq.single_qubit_op_to_framed_phase_form(mat)

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

cirq.stratified_circuit(circuit, *, categories)

Repacks avoiding simultaneous operations with different classes.

cirq.two_qubit_matrix_to_operations(q0, q1, …)

Decomposes a two-qubit operation into Z/XY/CZ gates.

cirq.ConvertToCzAndSingleGates(…)

Attempts to convert strange multi-qubit gates into CZ and single qubit

cirq.DropEmptyMoments()

Removes empty moments from a circuit.

cirq.DropNegligible(tolerance)

An optimization pass that removes operations with tiny effects.

cirq.EjectPhasedPaulis(tolerance, …)

Pushes X, Y, and PhasedX gates towards the end of the circuit.

cirq.EjectZ(tolerance, eject_parameterized)

Pushes Z gates towards the end of the circuit.

cirq.ExpandComposite(no_decomp, bool] = >)

An optimizer that expands composite operations via cirq.decompose.

cirq.MergeInteractions(tolerance, …)

Combines series of adjacent one and two-qubit gates operating on a

cirq.MergeSingleQubitGates(*, rewriter, …)

Optimizes runs of adjacent unitary 1-qubit operations.

cirq.PointOptimizationSummary(clear_span, …)

A description of a local optimization to perform.

cirq.PointOptimizer(post_clean_up, …)

Makes circuit improvements focused on a specific location.

cirq.SynchronizeTerminalMeasurements(…)

Move measurements to the end of the circuit.

Experiments

Utilities for running experiments on hardware, or producing things required to run experiments.

cirq.estimate_single_qubit_readout_errors(…)

Estimate single-qubit readout error.

cirq.generate_boixo_2018_supremacy_circuits_v2(…)

Generates Google Random Circuits v2 as in github.com/sboixo/GRCS

cirq.generate_boixo_2018_supremacy_circuits_v2_bristlecone(…)

Generates Google Random Circuits v2 in Bristlecone.

cirq.generate_boixo_2018_supremacy_circuits_v2_grid(…)

Generates Google Random Circuits v2 as in github.com/sboixo/GRCS

cirq.least_squares_xeb_fidelity_from_expectations(…)

Least squares fidelity estimator.

cirq.least_squares_xeb_fidelity_from_probabilities(…)

Least squares fidelity estimator with observable based on probabilities.

cirq.linear_xeb_fidelity(circuit, bitstrings)

Estimates XEB fidelity from one circuit using linear estimator.

cirq.linear_xeb_fidelity_from_probabilities(…)

Linear XEB fidelity estimator.

cirq.log_xeb_fidelity(circuit, bitstrings[, …])

Estimates XEB fidelity from one circuit using logarithmic estimator.

cirq.log_xeb_fidelity_from_probabilities(…)

Logarithmic XEB fidelity estimator.

cirq.experiments.GRID_ALIGNED_PATTERN

A pattern of two-qubit gates that is easy to simulate.

cirq.experiments.GRID_STAGGERED_PATTERN

A pattern of two-qubit gates that is hard to simulate.

cirq.experiments.build_entangling_layers(…)

Builds a sequence of gates that entangle all pairs of qubits on a grid.

cirq.experiments.collect_grid_parallel_two_qubit_xeb_data(…)

Collect data for a grid parallel two-qubit XEB experiment.

cirq.experiments.compute_grid_parallel_two_qubit_xeb_results(…)

Compute grid parallel two-qubit XEB results from experimental data.

cirq.experiments.get_state_tomography_data(…)

Gets the data for each rotation string added to the circuit.

cirq.experiments.purity_from_probabilities(…)

Purity estimator from speckle purity benchmarking.

cirq.experiments.rabi_oscillations(sampler, …)

Runs a Rabi oscillation experiment.

cirq.experiments.random_rotations_between_grid_interaction_layers_circuit(…)

Generate a random quantum circuit.

cirq.experiments.single_qubit_randomized_benchmarking(…)

Clifford-based randomized benchmarking (RB) of a single qubit.

cirq.experiments.single_qubit_state_tomography(…)

Single-qubit state tomography.

cirq.experiments.state_tomography(sampler, …)

This performs n qubit tomography on a cirq circuit

cirq.experiments.t1_decay(sampler, *, qubit, …)

Runs a t1 decay experiment.

cirq.experiments.t2_decay(sampler, *, qubit)

Runs a t2 transverse relaxation experiment.

cirq.experiments.two_qubit_randomized_benchmarking(…)

Clifford-based randomized benchmarking (RB) of two qubits.

cirq.experiments.two_qubit_state_tomography(…)

Two-qubit state tomography.

cirq.experiments.CrossEntropyResult(data, …)

Results from a cross-entropy benchmarking (XEB) experiment.

cirq.experiments.CrossEntropyResultDict(…)

Per-qubit-tuple results from cross-entropy benchmarking.

cirq.experiments.GridInteractionLayer(*args, …)

A layer of aligned or staggered two-qubit interactions on a grid.

cirq.experiments.RabiResult(rabi_angles, …)

Results from a Rabi oscillation experiment.

cirq.experiments.RandomizedBenchMarkResult(…)

Results from a randomized benchmarking experiment.

cirq.experiments.SingleQubitReadoutCalibrationResult(…)

Result of estimating single qubit readout error.

cirq.experiments.StateTomographyExperiment(…)

Experiment to conduct state tomography.

cirq.experiments.T1DecayResult(data)

Results from a Rabi oscillation experiment.

cirq.experiments.T2DecayResult(x_basis_data, …)

Results from a T2 decay experiment.

cirq.experiments.TomographyResult(density_matrix)

Results from a state tomography experiment.

Ion traps and neutral atoms

Support for ion trap an neutral atom devices.

cirq.ms(rads)

param rads

The rotation angle in radians.

cirq.is_native_neutral_atom_gate(gate)

cirq.is_native_neutral_atom_op(operation)

cirq.two_qubit_matrix_to_ion_operations(q0, …)

Decomposes a two-qubit operation into MS/single-qubit rotation gates.

cirq.ConvertToIonGates(ignore_failures)

Attempts to convert non-native gates into IonGates.

cirq.ConvertToNeutralAtomGates([ignore_failures])

Attempts to convert gates into native Atom gates.

cirq.IonDevice(measurement_duration, …)

A device with qubits placed on a line.

cirq.NeutralAtomDevice(measurement_duration, …)

A device with qubits placed on a grid.

Google

Functionality specific to quantum hardware and services from Google.

cirq.google.FSIM_GATESET

Gate set that combines sqrt(iswap) and syc as one fsim id.

cirq.google.NAMED_GATESETS

A convenience mapping from gateset names to gatesets

cirq.google.SQRT_ISWAP_GATESET

Gate set with sqrt(iswap) as the core 2 qubit interaction.

cirq.google.SYC

The Sycamore gate is a two-qubit gate equivalent to FSimGate(π/2, π/6).

cirq.google.SYC_GATESET

Gate set with fsim(pi/2, pi/6) as the core 2 qubit interaction.

cirq.google.XMON

Gate set for XMON devices.

cirq.google.get_engine([project_id])

Get an Engine instance assuming some sensible defaults.

cirq.google.get_engine_calibration(processor_id)

Returns calibration metrics for a given processor.

cirq.google.get_engine_device(processor_id)

Returns a Device object for a given processor.

cirq.google.get_engine_sampler(processor_id, …)

Get an EngineSampler assuming some sensible defaults.

cirq.google.line_on_device(device, length[, …])

Searches for linear sequence of qubits on device.

cirq.google.optimized_for_sycamore(circuit, *)

Optimizes a circuit for Google devices.

cirq.google.optimized_for_xmon(circuit[, …])

cirq.google.AnnealSequenceSearchStrategy(…)

Linearized sequence search using simulated annealing method.

cirq.google.Bristlecone

72 xmon qubit device.

cirq.google.Calibration(calibration)

A convenience wrapper for calibrations that acts like a dictionary.

cirq.google.ConvertToSqrtIswapGates([…])

Attempts to convert gates into ISWAP**-0.5 gates.

cirq.google.ConvertToSycamoreGates(tabulation)

Attempts to convert non-native gates into SycamoreGates.

cirq.google.ConvertToXmonGates([ignore_failures])

Attempts to convert strange gates into XmonGates.

cirq.google.DeserializingArg(…)

Specification of the arguments to deserialize an argument to a gate.

cirq.google.Engine(project_id, …)

Runs programs via the Quantum Engine API.

cirq.google.EngineJob(project_id, …)

A job created via the Quantum Engine API.

cirq.google.EngineProcessor(project_id, …)

A processor available via the Quantum Engine API.

cirq.google.EngineProgram(project_id, …)

A program created via the Quantum Engine API.

cirq.google.EngineTimeSlot(processor_id, …)

A python wrapping of a Quantum Engine timeslot.

cirq.google.Foxtail

72 xmon qubit device.

cirq.google.GateOpDeserializer(…)

Describes how to deserialize a proto to a given Gate type.

cirq.google.GateOpSerializer(*, gate_type, …)

Describes how to serialize a GateOperation for a given Gate type.

cirq.google.GateTabulation(base_gate, …)

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

cirq.google.GreedySequenceSearchStrategy(…)

Greedy search method for linear sequence of qubits on a chip.

cirq.google.LinePlacementStrategy()

Choice and options for the line placement calculation method.

cirq.google.PhysicalZTag()

Class to add as a tag onto an Operation to denote a Physical Z operation.

cirq.google.ProtoVersion(value)

Protocol buffer version to use for requests to the quantum engine.

cirq.google.QuantumEngineSampler(*, engine, …)

A sampler that samples from processors managed by the Quantum Engine.

cirq.google.SerializableDevice(qubits, …)

Device object generated from a device specification proto.

cirq.google.SerializableGateSet(…)

A class for serializing and deserializing programs and operations.

cirq.google.SerializingArg(serialized_name, …)

Specification of the arguments for a Gate and its serialization.

cirq.google.Sycamore

Device object generated from a device specification proto.

cirq.google.Sycamore23

Device object generated from a device specification proto.

cirq.google.SycamoreGate()

The Sycamore gate is a two-qubit gate equivalent to FSimGate(π/2, π/6).

cirq.google.XmonDevice(measurement_duration, …)

A device with qubits placed in a grid.

Contrib

Contributed code that is not yet considered stable, may not yet fit well with the main library, and may require extra dependencies to be installed (via python -m pip install cirq[contrib]). A waiting area. All packages within contrib may change without notice.

cirq.contrib.acquaintance

Tools for creating and using acquaintance strategies.

cirq.contrib.paulistring

Methods related to optimizing and transforming PauliStrings.

cirq.contrib.qcircuit

Converts cirq circuits into latex using qcircuit.

cirq.contrib.quil_import

cirq.contrib.quirk

Converts cirq circuits into quirk circuits.

Coding and Testing Tools

These objects are not relevant when simply constructing and sampling circuits, but are useful for customization tasks like defining and validating a custom operation.

cirq.alternative(*, requires, implementation)

A decorator indicating an abstract method with an alternative default

cirq.json_serializable_dataclass([_cls, …])

Create a dataclass that supports JSON serialization

cirq.obj_to_dict_helper(obj, attribute_names)

Construct a dictionary containing attributes from obj

cirq.value_equality()

Implements eq/ne/hash via a value_equality_values method.

cirq.ABCMetaImplementAnyOneOf(name, bases, …)

A metaclass extending abc.ABCMeta for defining abstract base

cirq.ArithmeticOperation()

A helper class for implementing reversible classical arithmetic.

cirq.InterchangeableQubitsGate()

Indicates operations should be equal under some qubit permutations.

cirq.JsonResolver(*args, **kwds)

Protocol for json resolver functions passed to read_json.

cirq.LinearDict(*args, **kwds)

Represents linear combination of things.

cirq.PeriodicValue(value, float], period, float])

Wrapper for periodic numerical values.

cirq.testing.DEFAULT_GATE_DOMAIN

The default gate domain for cirq.testing.random_circuit.

cirq.testing.assert_act_on_clifford_tableau_effect_matches_unitary(val)

Checks that act_on with CliffordTableau generates stabilizers that

cirq.testing.assert_allclose_up_to_global_phase(…)

Checks if a ~= b * exp(i t) for some t.

cirq.testing.assert_circuits_with_terminal_measurements_are_equivalent(…)

Determines if two circuits have equivalent effects.

cirq.testing.assert_commutes_magic_method_consistent_with_unitaries(*vals)

cirq.testing.assert_consistent_resolve_parameters(val)

cirq.testing.assert_decompose_is_consistent_with_unitary(val)

Uses val._unitary_ to check val._phase_by_’s behavior.

cirq.testing.assert_eigengate_implements_consistent_protocols(…)

Checks that an EigenGate subclass is internally consistent and has a

cirq.testing.assert_equivalent_computational_basis_map(…)

Ensure equivalence of basis state mapping.

cirq.testing.assert_equivalent_repr(value, *)

Checks that eval(repr(v)) == v.

cirq.testing.assert_has_consistent_apply_unitary(val, *)

Tests whether a value’s apply_unitary is correct.

cirq.testing.assert_has_consistent_apply_unitary_for_various_exponents(val, *)

Tests whether a value’s apply_unitary is correct.

cirq.testing.assert_has_consistent_qid_shape(val)

Tests whether a value’s _qid_shape_ and _num_qubits_ are

cirq.testing.assert_has_consistent_trace_distance_bound(val)

cirq.testing.assert_has_diagram(actual, …)

Determines if a given circuit has the desired text diagram.

cirq.testing.assert_implements_consistent_protocols(val, *)

Checks that a value is internally consistent and has a good repr.

cirq.testing.assert_json_roundtrip_works(obj)

Tests that the given object can serialized and de-serialized

cirq.testing.assert_logs(*matches[, count, …])

A context manager for testing logging and warning events.

cirq.testing.assert_pauli_expansion_is_consistent_with_unitary(val)

Checks Pauli expansion against unitary matrix.

cirq.testing.assert_phase_by_is_consistent_with_unitary(val)

Uses val._unitary_ to check val._phase_by_’s behavior.

cirq.testing.assert_qasm_is_consistent_with_unitary(val)

Uses val._unitary_ to check val._qasm_’s behavior.

cirq.testing.assert_same_circuits(actual, …)

Asserts that two circuits are identical, with a descriptive error.

cirq.testing.assert_specifies_has_unitary_if_unitary(val)

Checks that unitary values can be cheaply identifies as unitary.

cirq.testing.asyncio_pending(future[, timeout])

Gives the given future a chance to complete, and determines if it didn’t.

cirq.testing.highlight_text_differences(…)

cirq.testing.nonoptimal_toffoli_circuit(q0, …)

cirq.testing.random_density_matrix(dim, *[, …])

Returns a random density matrix distributed with Hilbert-Schmidt measure.

cirq.testing.random_orthogonal(dim, *[, …])

Returns a random orthogonal matrix distributed with Haar measure.

cirq.testing.random_special_orthogonal(dim, *)

Returns a random special orthogonal matrix distributed with Haar measure.

cirq.testing.random_special_unitary(dim, *)

Returns a random special unitary distributed with Haar measure.

cirq.testing.random_superposition(dim, *[, …])

Returns a random unit-length vector from the uniform distribution.

cirq.testing.random_unitary(dim, *[, …])

Returns a random unitary matrix distributed with Haar measure.

cirq.testing.EqualsTester()

Tests equality against user-provided disjoint equivalence groups.

cirq.testing.NoIdentifierQubit()

A singleton qubit type that does not have a qudit variant.

cirq.testing.OrderTester()

Tests ordering against user-provided disjoint ordered groups or items.

Algebra and Representation

cirq.CONTROL_TAG

A special indicator value for cirq.kron_with_controls.

cirq.DURATION_LIKE

A cirq.Duration or value that can trivially converted to one.

cirq.all_near_zero(a, *[, atol])

Checks if the tensor’s elements are all near zero.

cirq.all_near_zero_mod(a, period, *[, atol])

Checks if the tensor’s elements are all near multiples of the period.

cirq.allclose_up_to_global_phase(a, b, *[, …])

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

cirq.apply_matrix_to_slices(target, matrix, …)

Left-multiplies an NxN matrix onto N slices of a numpy array.

cirq.axis_angle(single_qubit_unitary)

Decomposes a single-qubit unitary into axis, angle, and global phase.

cirq.bidiagonalize_real_matrix_pair_with_symmetric_products(…)

Finds orthogonal matrices that diagonalize both mat1 and mat2.

cirq.bidiagonalize_unitary_with_special_orthogonals(mat, *)

Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.

cirq.block_diag(*blocks)

Concatenates blocks into a block diagonal matrix.

cirq.canonicalize_half_turns()

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

cirq.chosen_angle_to_canonical_half_turns([…])

Returns a canonicalized half_turns based on the given arguments.

cirq.chosen_angle_to_half_turns([…])

Returns a half_turns value based on the given arguments.

cirq.commutes(v1, v2, *[, atol, default])

Determines whether two values commute.

cirq.deconstruct_single_qubit_matrix_into_angles(mat)

Breaks down a 2x2 unitary into more useful ZYZ angle parameters.

cirq.definitely_commutes(v1, v2, *[, atol])

Determines whether two values definitely commute.

cirq.diagonalize_real_symmetric_and_sorted_diagonal_matrices(…)

Returns an orthogonal matrix that diagonalizes both given matrices.

cirq.diagonalize_real_symmetric_matrix(matrix, *)

Returns an orthogonal matrix that diagonalizes the given matrix.

cirq.dot(*values)

Computes the dot/matrix product of a sequence of values.

cirq.expand_matrix_in_orthogonal_basis(m, basis)

Computes coefficients of expansion of m in basis.

cirq.hilbert_schmidt_inner_product(m1, m2)

Computes Hilbert-Schmidt inner product of two matrices.

cirq.is_diagonal(matrix, *[, atol])

Determines if a matrix is a approximately diagonal.

cirq.is_hermitian(matrix, *[, rtol, atol])

Determines if a matrix is approximately Hermitian.

cirq.is_negligible_turn(turns, tolerance)

cirq.is_normal(matrix, *[, rtol, atol])

Determines if a matrix is approximately normal.

cirq.is_orthogonal(matrix, *[, rtol, atol])

Determines if a matrix is approximately orthogonal.

cirq.is_special_orthogonal(matrix, *[, …])

Determines if a matrix is approximately special orthogonal.

cirq.is_special_unitary(matrix, *[, rtol, atol])

Determines if a matrix is approximately unitary with unit determinant.

cirq.is_unitary(matrix, *[, rtol, atol])

Determines if a matrix is approximately unitary.

cirq.kak_canonicalize_vector(x, y, z[, atol])

Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.

cirq.kak_decomposition(unitary_object, *[, …])

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

cirq.kak_vector(unitary, *[, rtol, atol, …])

Compute the KAK vectors of one or more two qubit unitaries.

cirq.kron(*factors[, shape_len])

Computes the kronecker product of a sequence of values.

cirq.kron_bases(*bases[, repeat])

Creates tensor product of bases.

cirq.kron_factor_4x4_to_2x2s(matrix)

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

cirq.kron_with_controls(*factors)

Computes the kronecker product of a sequence of values and control tags.

cirq.map_eigenvalues(matrix, func, *[, atol])

Applies a function to the eigenvalues of a matrix.

cirq.match_global_phase(a, b)

Phases the given matrices so that they agree on the phase of one entry.

cirq.matrix_commutes(m1, m2, *[, rtol, atol])

Determines if two matrices approximately commute.

cirq.matrix_from_basis_coefficients(…)

Computes linear combination of basis vectors with given coefficients.

cirq.partial_trace(tensor, keep_indices)

Takes the partial trace of a given tensor.

cirq.partial_trace_of_state_vector_as_mixture(…)

Returns a mixture representing a state vector with only some qubits kept.

cirq.reflection_matrix_pow(…)

Raises a matrix with two opposing eigenvalues to a power.

cirq.slice_for_qubits_equal_to(target_qubit_axes)

Returns an index corresponding to a desired subset of an np.ndarray.

cirq.so4_to_magic_su2s(mat, *[, rtol, atol, …])

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

cirq.sub_state_vector(state_vector, …[, …])

Attempts to factor a state vector into two parts and return one of them.

cirq.targeted_conjugate_about(tensor, …[, …])

Conjugates the given tensor about the target tensor.

cirq.targeted_left_multiply(left_matrix, …)

Left-multiplies the given axes of the target tensor by the given matrix.

cirq.unitary_eig(matrix[, …])

Gives the guaranteed unitary eigendecomposition of a normal matrix.

cirq.AxisAngleDecomposition(*, angle, axis, …)

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

cirq.Duration(value, datetime.timedelta, …)

A time delta that supports symbols and picosecond accuracy.

cirq.KakDecomposition(*, global_phase, …)

A convenient description of an arbitrary two-qubit operation.

cirq.Timestamp(*, picos, float] = 0, nanos, …)

A location in time with picosecond accuracy.

Quantum Information Science

cirq.KET_IMAG

The |i⟩ State

cirq.KET_MINUS

The |-⟩ State

cirq.KET_MINUS_IMAG

The |-i⟩ State

cirq.KET_ONE

The |1⟩ State

cirq.KET_PLUS

The |+⟩ State

cirq.KET_ZERO

The |0⟩ State

cirq.PAULI_STATES

All one-qubit states stabalized by the pauli operators.

cirq.STATE_VECTOR_LIKE

Union type; Union[X, Y] means either X or Y.

cirq.bloch_vector_from_state_vector(…[, …])

Returns the bloch vector of a qubit.

cirq.density_matrix_from_state_vector(…[, …])

Returns the density matrix of the state vector.

cirq.dirac_notation(state_vector[, …])

Returns the state vector as a string in Dirac notation.

cirq.eye_tensor(half_shape, *, dtype)

Returns an identity matrix reshaped into a tensor.

cirq.fidelity(state1, state2)

Fidelity of two quantum states.

cirq.one_hot(*[, index, value])

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

cirq.to_valid_density_matrix(density_matrix_rep)

Verifies the density_matrix_rep is valid and converts it to ndarray form.

cirq.to_valid_state_vector(state_rep[, …])

Verifies the state_rep is valid and converts it to ndarray form.

cirq.validate_indices(num_qubits, indices)

Validates that the indices have values within range of num_qubits.

cirq.validate_normalized_state_vector(…[, …])

Validates that the given state vector is a valid.

cirq.validate_qid_shape(state_vector, qid_shape)

Validates the size of the given state_vector against the given shape.

cirq.von_neumann_entropy(density_matrix)

Calculates von Neumann entropy of density matrix in bits.

cirq.ProductState([states])

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

Internal Implementation Details

Neither users nor developers will commonly refer to these objects, but they play important roles in the internal machinery of the library.

cirq.ConstantQubitNoiseModel(qubit_noise_gate)

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

cirq.LinearCombinationOfGates(*args, **kwds)

Represents linear operator defined by a linear combination of gates.

cirq.LinearCombinationOfOperations(*args, **kwds)

Represents operator defined by linear combination of gate operations.

cirq.SingleQubitPauliStringGateOperation(…)

A Pauli operation applied to a qubit.

cirq.TParamKey

A parameter that a parameter resolver may map to a value.

cirq.TParamVal

A value that a parameter resolver may return for a parameter.

Deprecated

These objects and methods will be removed in a future version of the library.

cirq.QFT(*args, **kwargs)

THIS FUNCTION IS DEPRECATED.

cirq.final_wavefunction(*args, **kwargs)

THIS FUNCTION IS DEPRECATED.

cirq.has_mixture_channel(val, *[, …])

THIS FUNCTION IS DEPRECATED.

cirq.mixture_channel(val[, default])

THIS FUNCTION IS DEPRECATED.

cirq.subwavefunction(*args, **kwargs)

THIS FUNCTION IS DEPRECATED.

cirq.validate_normalized_state(state_vector, …)

THIS FUNCTION IS DEPRECATED.

cirq.wavefunction_partial_trace_as_mixture(…)

THIS FUNCTION IS DEPRECATED.

cirq.SimulatesIntermediateWaveFunction(**kwargs)

Deprecated.

cirq.WaveFunctionSimulatorState(**kwargs)

Deprecated.

cirq.WaveFunctionStepResult(**kwargs)

Deprecated.

cirq.WaveFunctionTrialResult(**kwargs)

Deprecated.

cirq.google.engine_from_environment()

THIS FUNCTION IS DEPRECATED.