From 57fa62f303dfccbeda718af966f54602a181b982 Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 12:51:21 -0700 Subject: [PATCH 1/8] only crossentropy --- docs/api.rst | 706 --------------------------------------------------- 1 file changed, 706 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index afb9eee8f74..30f272975fb 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2,424 +2,6 @@ API Reference ============= -Devices and Qubits -'''''''''''''''''' - -Classes for identifying the qubits and hardware you want to operate on. - -.. autosummary:: - :toctree: generated/ - - cirq.UNCONSTRAINED_DEVICE - cirq.Device - cirq.GridQid - cirq.GridQubit - cirq.LineQid - cirq.LineQubit - cirq.NamedQubit - cirq.Qid - - -Measurement -''''''''''' - -Methods and classes for performing measurement operations. - -.. autosummary:: - :toctree: generated/ - - cirq.measure - cirq.measure_each - cirq.MeasurementGate - - -Unitary Gates and Operations -'''''''''''''''''''''''''''' - -Unitary effects that can be applied to one or more qubits. - -.. autosummary:: - :toctree: generated/ - - cirq.H - cirq.I - cirq.S - cirq.T - cirq.X - cirq.Y - cirq.Z - cirq.CX - cirq.CZ - cirq.XX - cirq.YY - cirq.ZZ - cirq.rx - cirq.ry - cirq.rz - cirq.CCNOT - cirq.CCX - cirq.CCZ - cirq.CNOT - cirq.CSWAP - cirq.FREDKIN - cirq.ISWAP - cirq.SWAP - cirq.TOFFOLI - cirq.givens - cirq.identity_each - cirq.qft - cirq.riswap - .. autoclass:: cirq.CCNotPowGate - cirq.CCXPowGate - cirq.CCZPowGate - .. autoclass:: cirq.CNotPowGate - cirq.CSwapGate - cirq.CXPowGate - cirq.CZPowGate - cirq.ControlledGate - cirq.ControlledOperation - cirq.EigenGate - cirq.FSimGate - cirq.Gate - cirq.GlobalPhaseOperation - cirq.HPowGate - cirq.ISwapPowGate - cirq.IdentityGate - cirq.MatrixGate - cirq.Operation - cirq.PhaseGradientGate - cirq.PhasedISwapPowGate - cirq.PhasedXPowGate - cirq.PhasedXZGate - cirq.QuantumFourierTransformGate - cirq.RandomGateChannel - cirq.SingleQubitGate - cirq.SwapPowGate - cirq.TaggedOperation - cirq.ThreeQubitDiagonalGate - cirq.ThreeQubitGate - cirq.TwoQubitDiagonalGate - cirq.TwoQubitGate - cirq.WaitGate - cirq.XPowGate - cirq.XXPowGate - cirq.YPowGate - cirq.YYPowGate - cirq.ZPowGate - cirq.ZZPowGate - - -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. - -.. autosummary:: - :toctree: generated/ - - cirq.NOISE_MODEL_LIKE - cirq.NO_NOISE - cirq.amplitude_damp - cirq.asymmetric_depolarize - cirq.bit_flip - cirq.depolarize - cirq.generalized_amplitude_damp - cirq.phase_damp - cirq.phase_flip - cirq.reset - cirq.AmplitudeDampingChannel - cirq.AsymmetricDepolarizingChannel - cirq.BitFlipChannel - cirq.DepolarizingChannel - cirq.GeneralizedAmplitudeDampingChannel - cirq.NoiseModel - cirq.PhaseDampingChannel - cirq.PhaseFlipChannel - cirq.ResetChannel - cirq.VirtualTag - - -Pauli and Clifford Groups -''''''''''''''''''''''''' - -Classes and methods related to representing and operating on states using sums -and products of Pauli operations. - -.. autosummary:: - :toctree: generated/ - - cirq.PAULI_BASIS - cirq.PAULI_GATE_LIKE - cirq.PAULI_STRING_LIKE - cirq.pow_pauli_combination - cirq.BaseDensePauliString - cirq.CliffordState - cirq.CliffordTableau - cirq.DensePauliString - cirq.MutableDensePauliString - cirq.Pauli - cirq.PauliInteractionGate - cirq.PauliString - cirq.PauliStringGateOperation - cirq.PauliStringPhasor - cirq.PauliSum - cirq.PauliSumLike - cirq.PauliTransform - cirq.SingleQubitCliffordGate - cirq.StabilizerStateChForm - - -Circuits -'''''''' - -Utilities for representing and manipulating quantum computations via -Circuits, Operations, and Moments. - -.. autosummary:: - :toctree: generated/ - - cirq.OP_TREE - cirq.flatten_op_tree - cirq.freeze_op_tree - cirq.transform_op_tree - cirq.Circuit - cirq.CircuitDag - cirq.GateOperation - cirq.InsertStrategy - cirq.Moment - cirq.ParallelGateOperation - cirq.QubitOrder - cirq.QubitOrderOrList - cirq.Unique - - -Importing and Exporting -''''''''''''''''''''''' - -Utilities for interoperating with other quantum software libraries and products. - -.. autosummary:: - :toctree: generated/ - - cirq.quirk_json_to_circuit - cirq.quirk_url_to_circuit - - -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. - -.. autosummary:: - :toctree: generated/ - - cirq.CIRCUIT_LIKE - cirq.RANDOM_STATE_OR_SEED_LIKE - cirq.big_endian_bits_to_int - cirq.big_endian_digits_to_int - cirq.big_endian_int_to_bits - cirq.big_endian_int_to_digits - cirq.final_density_matrix - cirq.final_state_vector - cirq.flatten - cirq.flatten_to_ops - cirq.flatten_to_ops_or_moments - cirq.flatten_with_params - cirq.flatten_with_sweep - cirq.hog_score_xeb_fidelity_from_probabilities - cirq.measure_density_matrix - cirq.measure_state_vector - cirq.sample - cirq.sample_density_matrix - cirq.sample_state_vector - cirq.sample_sweep - cirq.to_resolvers - cirq.to_sweep - cirq.to_sweeps - cirq.validate_mixture - cirq.validate_probability - cirq.xeb_fidelity - cirq.ActOnStateVectorArgs - cirq.CircuitSampleJob - cirq.CliffordSimulator - cirq.CliffordSimulatorStepResult - cirq.CliffordTrialResult - cirq.Collector - cirq.DensityMatrixSimulator - cirq.DensityMatrixSimulatorState - cirq.DensityMatrixStepResult - cirq.DensityMatrixTrialResult - cirq.ExpressionMap - cirq.Linspace - cirq.ListSweep - .. autoclass:: cirq.ParamDictType - cirq.ParamResolver - cirq.ParamResolverOrSimilarType - cirq.PauliSumCollector - cirq.Points - cirq.Product - cirq.Sampler - cirq.SimulatesAmplitudes - cirq.SimulatesFinalState - cirq.SimulatesIntermediateState - cirq.SimulatesIntermediateStateVector - cirq.SimulatesSamples - cirq.SimulationTrialResult - cirq.Simulator - cirq.SparseSimulatorStep - cirq.StateVectorMixin - cirq.StateVectorSimulatorState - cirq.StateVectorStepResult - cirq.StateVectorTrialResult - cirq.StepResult - cirq.Sweep - cirq.Sweepable - cirq.TrialResult - cirq.UnitSweep - cirq.Zip - - -Visualization -''''''''''''' - -Classes and methods for visualizing data. - -.. autosummary:: - :toctree: generated/ - - cirq.plot_state_histogram - cirq.scatter_plot_normalized_kak_interaction_coefficients - cirq.Heatmap - cirq.TextDiagramDrawer - - -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. - -.. autosummary:: - :toctree: generated/ - - cirq.DEFAULT_RESOLVERS - cirq.act_on - cirq.apply_channel - cirq.apply_mixture - cirq.apply_unitaries - cirq.apply_unitary - cirq.approx_eq - cirq.channel - cirq.circuit_diagram_info - cirq.compute_cphase_exponents_for_fsim_decomposition - cirq.decompose - cirq.decompose_cphase_into_two_fsim - cirq.decompose_once - cirq.decompose_once_with_qubits - cirq.equal_up_to_global_phase - cirq.has_channel - cirq.has_mixture - cirq.has_mixture_channel - cirq.has_stabilizer_effect - cirq.has_unitary - cirq.inverse - cirq.is_measurement - cirq.is_parameterized - cirq.measurement_key - cirq.measurement_keys - cirq.mixture - cirq.mixture_channel - cirq.mul - cirq.num_qubits - cirq.pauli_expansion - cirq.phase_by - cirq.pow - cirq.qasm - cirq.qid_shape - cirq.quil - cirq.read_json - cirq.resolve_parameters - cirq.to_json - cirq.trace_distance_bound - cirq.trace_distance_from_angle_list - cirq.unitary - cirq.ApplyChannelArgs - cirq.ApplyMixtureArgs - cirq.ApplyUnitaryArgs - cirq.CircuitDiagramInfo - cirq.CircuitDiagramInfoArgs - cirq.QasmArgs - cirq.QasmOutput - cirq.QuilFormatter - cirq.QuilOutput - cirq.SupportsActOn - cirq.SupportsApplyChannel - cirq.SupportsApplyMixture - cirq.SupportsApproximateEquality - cirq.SupportsChannel - cirq.SupportsCircuitDiagramInfo - cirq.SupportsCommutes - cirq.SupportsConsistentApplyUnitary - cirq.SupportsDecompose - cirq.SupportsDecomposeWithQubits - cirq.SupportsEqualUpToGlobalPhase - cirq.SupportsExplicitHasUnitary - cirq.SupportsExplicitNumQubits - cirq.SupportsExplicitQidShape - cirq.SupportsJSON - cirq.SupportsMeasurementKey - cirq.SupportsMixture - cirq.SupportsParameterization - cirq.SupportsPhase - cirq.SupportsQasm - cirq.SupportsQasmWithArgs - cirq.SupportsQasmWithArgsAndQubits - cirq.SupportsTraceDistanceBound - cirq.SupportsUnitary - - -Optimization -'''''''''''' - -Classes and methods for rewriting circuits. - -.. autosummary:: - :toctree: generated/ - - cirq.decompose_multi_controlled_rotation - cirq.decompose_multi_controlled_x - cirq.decompose_two_qubit_interaction_into_four_fsim_gates_via_b - cirq.merge_single_qubit_gates_into_phased_x_z - cirq.merge_single_qubit_gates_into_phxz - cirq.single_qubit_matrix_to_gates - cirq.single_qubit_matrix_to_pauli_rotations - cirq.single_qubit_matrix_to_phased_x_z - cirq.single_qubit_matrix_to_phxz - cirq.single_qubit_op_to_framed_phase_form - cirq.stratified_circuit - cirq.two_qubit_matrix_to_operations - cirq.ConvertToCzAndSingleGates - cirq.DropEmptyMoments - cirq.DropNegligible - cirq.EjectPhasedPaulis - cirq.EjectZ - cirq.ExpandComposite - cirq.MergeInteractions - cirq.MergeSingleQubitGates - cirq.PointOptimizationSummary - cirq.PointOptimizer - cirq.SynchronizeTerminalMeasurements - - Experiments ''''''''''' @@ -429,292 +11,4 @@ run experiments. .. autosummary:: :toctree: generated/ - cirq.estimate_single_qubit_readout_errors - cirq.generate_boixo_2018_supremacy_circuits_v2 - cirq.generate_boixo_2018_supremacy_circuits_v2_bristlecone - cirq.generate_boixo_2018_supremacy_circuits_v2_grid - cirq.linear_xeb_fidelity - cirq.linear_xeb_fidelity_from_probabilities - cirq.log_xeb_fidelity - cirq.log_xeb_fidelity_from_probabilities - cirq.experiments.GRID_ALIGNED_PATTERN - cirq.experiments.GRID_STAGGERED_PATTERN - cirq.experiments.build_entangling_layers cirq.experiments.cross_entropy_benchmarking - cirq.experiments.get_state_tomography_data - cirq.experiments.rabi_oscillations - cirq.experiments.random_rotations_between_grid_interaction_layers_circuit - cirq.experiments.single_qubit_randomized_benchmarking - cirq.experiments.single_qubit_state_tomography - cirq.experiments.state_tomography - cirq.experiments.t1_decay - cirq.experiments.t2_decay - cirq.experiments.two_qubit_randomized_benchmarking - cirq.experiments.two_qubit_state_tomography - cirq.experiments.CrossEntropyResult - cirq.experiments.GridInteractionLayer - cirq.experiments.RabiResult - cirq.experiments.RandomizedBenchMarkResult - cirq.experiments.SingleQubitReadoutCalibrationResult - cirq.experiments.StateTomographyExperiment - cirq.experiments.T1DecayResult - cirq.experiments.T2DecayResult - cirq.experiments.TomographyResult - - -Ion traps and neutral atoms -''''''''''''''''''''''''''' - -Support for ion trap an neutral atom devices. - -.. autosummary:: - :toctree: generated/ - - cirq.ms - cirq.is_native_neutral_atom_gate - cirq.is_native_neutral_atom_op - cirq.two_qubit_matrix_to_ion_operations - cirq.ConvertToIonGates - cirq.ConvertToNeutralAtomGates - cirq.IonDevice - cirq.NeutralAtomDevice - - - -Google -'''''' - -Functionality specific to quantum hardware and services from Google. - -.. autosummary:: - :toctree: generated/ - - cirq.google.FSIM_GATESET - cirq.google.SQRT_ISWAP_GATESET - cirq.google.SYC - cirq.google.SYC_GATESET - cirq.google.XMON - cirq.google.engine_from_environment - cirq.google.is_native_xmon_gate - cirq.google.is_native_xmon_op - cirq.google.line_on_device - cirq.google.optimized_for_sycamore - cirq.google.optimized_for_xmon - cirq.google.pack_results - cirq.google.unpack_results - cirq.google.AnnealSequenceSearchStrategy - cirq.google.Bristlecone - cirq.google.Calibration - cirq.google.ConvertToSqrtIswapGates - cirq.google.ConvertToSycamoreGates - cirq.google.ConvertToXmonGates - cirq.google.DeserializingArg - cirq.google.Engine - cirq.google.EngineJob - cirq.google.EngineProcessor - cirq.google.EngineProgram - cirq.google.EngineTimeSlot - cirq.google.Foxtail - cirq.google.GateOpDeserializer - cirq.google.GateOpSerializer - cirq.google.GateTabulation - cirq.google.GreedySequenceSearchStrategy - cirq.google.LinePlacementStrategy - cirq.google.PhysicalZTag - cirq.google.ProtoVersion - cirq.google.QuantumEngineSampler - cirq.google.SerializableDevice - cirq.google.SerializableGateSet - cirq.google.SerializingArg - cirq.google.Sycamore - cirq.google.Sycamore23 - cirq.google.SycamoreGate - cirq.google.XmonDevice - - -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. - -.. autosummary:: - :toctree: generated/ - - cirq.contrib.acquaintance - cirq.contrib.paulistring - cirq.contrib.qcircuit - cirq.contrib.quirk - - -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. - - -.. autosummary:: - :toctree: generated/ - - cirq.alternative - cirq.json_serializable_dataclass - cirq.obj_to_dict_helper - cirq.value_equality - cirq.ABCMetaImplementAnyOneOf - cirq.ArithmeticOperation - cirq.InterchangeableQubitsGate - cirq.LinearDict - cirq.PeriodicValue - cirq.testing.DEFAULT_GATE_DOMAIN - cirq.testing.assert_allclose_up_to_global_phase - cirq.testing.assert_circuits_with_terminal_measurements_are_equivalent - cirq.testing.assert_commutes_magic_method_consistent_with_unitaries - cirq.testing.assert_decompose_is_consistent_with_unitary - cirq.testing.assert_eigengate_implements_consistent_protocols - cirq.testing.assert_equivalent_repr - cirq.testing.assert_has_consistent_apply_unitary - cirq.testing.assert_has_consistent_apply_unitary_for_various_exponents - cirq.testing.assert_has_consistent_qid_shape - cirq.testing.assert_has_consistent_trace_distance_bound - cirq.testing.assert_has_diagram - cirq.testing.assert_implements_consistent_protocols - cirq.testing.assert_json_roundtrip_works - cirq.testing.assert_logs - cirq.testing.assert_pauli_expansion_is_consistent_with_unitary - cirq.testing.assert_phase_by_is_consistent_with_unitary - cirq.testing.assert_qasm_is_consistent_with_unitary - cirq.testing.assert_same_circuits - cirq.testing.assert_specifies_has_unitary_if_unitary - cirq.testing.asyncio_pending - cirq.testing.highlight_text_differences - cirq.testing.nonoptimal_toffoli_circuit - cirq.testing.random_circuit - cirq.testing.random_density_matrix - cirq.testing.random_orthogonal - cirq.testing.random_special_orthogonal - cirq.testing.random_special_unitary - cirq.testing.random_superposition - cirq.testing.random_unitary - cirq.testing.EqualsTester - cirq.testing.OrderTester - - -Algebra and Representation -'''''''''''''''''''''''''' - -.. autosummary:: - :toctree: generated/ - - cirq.CONTROL_TAG - cirq.DURATION_LIKE - cirq.all_near_zero - cirq.all_near_zero_mod - cirq.allclose_up_to_global_phase - cirq.apply_matrix_to_slices - cirq.axis_angle - cirq.bidiagonalize_real_matrix_pair_with_symmetric_products - cirq.bidiagonalize_unitary_with_special_orthogonals - cirq.block_diag - cirq.canonicalize_half_turns - cirq.chosen_angle_to_canonical_half_turns - cirq.chosen_angle_to_half_turns - cirq.commutes - cirq.deconstruct_single_qubit_matrix_into_angles - cirq.definitely_commutes - cirq.diagonalize_real_symmetric_and_sorted_diagonal_matrices - cirq.diagonalize_real_symmetric_matrix - cirq.dot - cirq.expand_matrix_in_orthogonal_basis - cirq.hilbert_schmidt_inner_product - cirq.is_diagonal - cirq.is_hermitian - cirq.is_negligible_turn - cirq.is_normal - cirq.is_orthogonal - cirq.is_special_orthogonal - cirq.is_special_unitary - cirq.is_unitary - cirq.kak_canonicalize_vector - cirq.kak_decomposition - cirq.kak_vector - cirq.kron - cirq.kron_bases - cirq.kron_factor_4x4_to_2x2s - cirq.kron_with_controls - cirq.map_eigenvalues - cirq.match_global_phase - cirq.matrix_commutes - cirq.matrix_from_basis_coefficients - cirq.partial_trace - cirq.partial_trace_of_state_vector_as_mixture - cirq.reflection_matrix_pow - cirq.slice_for_qubits_equal_to - cirq.so4_to_magic_su2s - cirq.sub_state_vector - cirq.targeted_conjugate_about - cirq.targeted_left_multiply - cirq.unitary_eig - cirq.AxisAngleDecomposition - cirq.Duration - cirq.KakDecomposition - cirq.Timestamp - - -Quantum Information Science -''''''''''''''''''''''''''' - -.. autosummary:: - :toctree: generated/ - - cirq.STATE_VECTOR_LIKE - cirq.bloch_vector_from_state_vector - cirq.density_matrix_from_state_vector - cirq.dirac_notation - cirq.eye_tensor - cirq.fidelity - cirq.one_hot - cirq.to_valid_density_matrix - cirq.to_valid_state_vector - cirq.validate_indices - cirq.validate_normalized_state_vector - cirq.validate_qid_shape - cirq.von_neumann_entropy - - -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. - -.. autosummary:: - :toctree: generated/ - - cirq.ConstantQubitNoiseModel - cirq.LinearCombinationOfGates - cirq.LinearCombinationOfOperations - cirq.SingleQubitPauliStringGateOperation - cirq.TParamVal - - -Deprecated -'''''''''' - -These objects and methods will be removed in a future version of the library. - -.. autosummary:: - :toctree: generated/ - - cirq.QFT - cirq.final_wavefunction - cirq.subwavefunction - cirq.validate_normalized_state - cirq.wavefunction_partial_trace_as_mixture - cirq.SimulatesIntermediateWaveFunction - cirq.WaveFunctionSimulatorState - cirq.WaveFunctionStepResult - cirq.WaveFunctionTrialResult From f59b186fa1d7773b1de9d37c398607011dc3a0dd Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 12:55:53 -0700 Subject: [PATCH 2/8] truncate docstring --- .../experiments/cross_entropy_benchmarking.py | 82 ------------------- 1 file changed, 82 deletions(-) diff --git a/cirq/experiments/cross_entropy_benchmarking.py b/cirq/experiments/cross_entropy_benchmarking.py index 77f29ca4443..8478ede9d40 100644 --- a/cirq/experiments/cross_entropy_benchmarking.py +++ b/cirq/experiments/cross_entropy_benchmarking.py @@ -156,88 +156,6 @@ def cross_entropy_benchmarking( simulator: sim.Simulator = None, ) -> CrossEntropyResult: r"""Cross-entropy benchmarking (XEB) of multiple qubits. - - A total of M random circuits are generated, each of which comprises N - layers where N = max('cycles') or 'cycles' if a single value is specified - for the 'cycles' parameter. Every layer contains randomly generated - single-qubit gates applied to each qubit, followed by a set of - user-defined benchmarking operations (e.g. a set of two-qubit gates). - - Each circuit (circuit_m) from the M random circuits is further used to - generate a set of circuits {circuit_mn}, where circuit_mn is built from the - first n cycles of circuit_m. n spans all the values in 'cycles'. - - For each fixed value n, the experiment performs the following: - - 1) Experimentally collect a number of bit-strings for each circuit_mn via - projective measurements in the z-basis. - - 2) Theoretically compute the expected bit-string probabilities - $P^{th, mn}_|...00>$, $P^{th, mn}_|...01>$, $P^{th, mn}_|...10>$, - $P^{th, mn}_|...11>$ ... at the end of circuit_mn for all m and for all - possible bit-strings in the Hilbert space. - - 3) Compute an experimental XEB function for each circuit_mn: - - $f_{mn}^{meas} = \langle D * P^{th, mn}_q - 1 \rangle$ - - where D is the number of states in the Hilbert space, $P^{th, mn}_q$ is the - theoretical probability of a bit-string q at the end of circuit_mn, and - $\langle \rangle$ corresponds to the ensemble average over all measured - bit-strings. - - Then, take the average of $f_{mn}^{meas}$ over all circuit_mn with fixed - n to obtain: - - $f_{n} ^ {meas} = (\sum_m f_{mn}^{meas}) / M$ - - 4) Compute a theoretical XEB function for each circuit_mn: - - $f_{mn}^{th} = D \sum_q (P^{th, mn}_q) ** 2 - 1$ - - where the summation goes over all possible bit-strings q in the Hilbert - space. - - Similarly, we then average $f_m^{th}$ over all circuit_mn with fixed n to - obtain: - - $f_{n} ^ {th} = (\sum_m f_{mn}^{th}) / M$ - - 5) Calculate the XEB fidelity $\alpha_n$ at fixed n: - - $\alpha_n = f_{n} ^ {meas} / f_{n} ^ {th}$ - - Args: - sampler: The quantum engine or simulator to run the circuits. - qubits: The qubits included in the XEB experiment. - benchmark_ops: A sequence of ops.Moment containing gate operations - between specific qubits which are to be benchmarked for fidelity. - If more than one ops.Moment is specified, the random circuits - will rotate between the ops.Moment's. As an example, - if benchmark_ops = [Moment([ops.CZ(q0, q1), ops.CZ(q2, q3)]), - Moment([ops.CZ(q1, q2)]) where q0, q1, q2 and q3 are instances of - Qid (such as GridQubits), each random circuit will apply CZ gate - between q0 and q1 plus CZ between q2 and q3 for the first cycle, - CZ gate between q1 and q2 for the second cycle, CZ between q0 and - q1 and CZ between q2 and q3 for the third cycle and so on. If - None, the circuits will consist only of single-qubit gates. - num_circuits: The total number of random circuits to be used. - repetitions: The number of measurements for each circuit to estimate - the bit-string probabilities. - cycles: The different numbers of circuit layers in the XEB study. - Could be a single or a collection of values. - scrambling_gates_per_cycle: If None (by default), the single-qubit - gates are chosen from X/2 ($\pi/2$ rotation around the X axis), - Y/2 ($\pi/2$ rotation around the Y axis) and (X + Y)/2 ($\pi/2$ - rotation around an axis $\pi/4$ away from the X on the equator of - the Bloch sphere). Otherwise the single-qubit gates for each layer - are chosen from a list of possible choices (each choice is a list - of one or more single-qubit gates). - simulator: A simulator that calculates the bit-string probabilities - of the ideal circuit. By default, this is set to sim.Simulator(). - - Returns: - A CrossEntropyResult object that stores and plots the result. """ simulator = sim.Simulator() if simulator is None else simulator num_qubits = len(qubits) From 3e2b133c4cc6422943c6a775a42a7536366c178e Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 13:01:32 -0700 Subject: [PATCH 3/8] try explicit autoclass --- docs/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 30f272975fb..a0919b2a88d 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -11,4 +11,4 @@ run experiments. .. autosummary:: :toctree: generated/ - cirq.experiments.cross_entropy_benchmarking + .. autofunction:: cirq.experiments.cross_entropy_benchmarking From 2e925576621bbf6484fcc051660ce310e18760ca Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 13:18:38 -0700 Subject: [PATCH 4/8] add back docstring --- .../experiments/cross_entropy_benchmarking.py | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/cirq/experiments/cross_entropy_benchmarking.py b/cirq/experiments/cross_entropy_benchmarking.py index 8478ede9d40..77f29ca4443 100644 --- a/cirq/experiments/cross_entropy_benchmarking.py +++ b/cirq/experiments/cross_entropy_benchmarking.py @@ -156,6 +156,88 @@ def cross_entropy_benchmarking( simulator: sim.Simulator = None, ) -> CrossEntropyResult: r"""Cross-entropy benchmarking (XEB) of multiple qubits. + + A total of M random circuits are generated, each of which comprises N + layers where N = max('cycles') or 'cycles' if a single value is specified + for the 'cycles' parameter. Every layer contains randomly generated + single-qubit gates applied to each qubit, followed by a set of + user-defined benchmarking operations (e.g. a set of two-qubit gates). + + Each circuit (circuit_m) from the M random circuits is further used to + generate a set of circuits {circuit_mn}, where circuit_mn is built from the + first n cycles of circuit_m. n spans all the values in 'cycles'. + + For each fixed value n, the experiment performs the following: + + 1) Experimentally collect a number of bit-strings for each circuit_mn via + projective measurements in the z-basis. + + 2) Theoretically compute the expected bit-string probabilities + $P^{th, mn}_|...00>$, $P^{th, mn}_|...01>$, $P^{th, mn}_|...10>$, + $P^{th, mn}_|...11>$ ... at the end of circuit_mn for all m and for all + possible bit-strings in the Hilbert space. + + 3) Compute an experimental XEB function for each circuit_mn: + + $f_{mn}^{meas} = \langle D * P^{th, mn}_q - 1 \rangle$ + + where D is the number of states in the Hilbert space, $P^{th, mn}_q$ is the + theoretical probability of a bit-string q at the end of circuit_mn, and + $\langle \rangle$ corresponds to the ensemble average over all measured + bit-strings. + + Then, take the average of $f_{mn}^{meas}$ over all circuit_mn with fixed + n to obtain: + + $f_{n} ^ {meas} = (\sum_m f_{mn}^{meas}) / M$ + + 4) Compute a theoretical XEB function for each circuit_mn: + + $f_{mn}^{th} = D \sum_q (P^{th, mn}_q) ** 2 - 1$ + + where the summation goes over all possible bit-strings q in the Hilbert + space. + + Similarly, we then average $f_m^{th}$ over all circuit_mn with fixed n to + obtain: + + $f_{n} ^ {th} = (\sum_m f_{mn}^{th}) / M$ + + 5) Calculate the XEB fidelity $\alpha_n$ at fixed n: + + $\alpha_n = f_{n} ^ {meas} / f_{n} ^ {th}$ + + Args: + sampler: The quantum engine or simulator to run the circuits. + qubits: The qubits included in the XEB experiment. + benchmark_ops: A sequence of ops.Moment containing gate operations + between specific qubits which are to be benchmarked for fidelity. + If more than one ops.Moment is specified, the random circuits + will rotate between the ops.Moment's. As an example, + if benchmark_ops = [Moment([ops.CZ(q0, q1), ops.CZ(q2, q3)]), + Moment([ops.CZ(q1, q2)]) where q0, q1, q2 and q3 are instances of + Qid (such as GridQubits), each random circuit will apply CZ gate + between q0 and q1 plus CZ between q2 and q3 for the first cycle, + CZ gate between q1 and q2 for the second cycle, CZ between q0 and + q1 and CZ between q2 and q3 for the third cycle and so on. If + None, the circuits will consist only of single-qubit gates. + num_circuits: The total number of random circuits to be used. + repetitions: The number of measurements for each circuit to estimate + the bit-string probabilities. + cycles: The different numbers of circuit layers in the XEB study. + Could be a single or a collection of values. + scrambling_gates_per_cycle: If None (by default), the single-qubit + gates are chosen from X/2 ($\pi/2$ rotation around the X axis), + Y/2 ($\pi/2$ rotation around the Y axis) and (X + Y)/2 ($\pi/2$ + rotation around an axis $\pi/4$ away from the X on the equator of + the Bloch sphere). Otherwise the single-qubit gates for each layer + are chosen from a list of possible choices (each choice is a list + of one or more single-qubit gates). + simulator: A simulator that calculates the bit-string probabilities + of the ideal circuit. By default, this is set to sim.Simulator(). + + Returns: + A CrossEntropyResult object that stores and plots the result. """ simulator = sim.Simulator() if simulator is None else simulator num_qubits = len(qubits) From b34076b22e5602c2cf7be7273e397536969ece30 Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 13:23:31 -0700 Subject: [PATCH 5/8] Add back in api doc --- docs/api.rst | 706 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 706 insertions(+) diff --git a/docs/api.rst b/docs/api.rst index a0919b2a88d..84692c3d7a7 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2,6 +2,424 @@ API Reference ============= +Devices and Qubits +'''''''''''''''''' + +Classes for identifying the qubits and hardware you want to operate on. + +.. autosummary:: + :toctree: generated/ + + cirq.UNCONSTRAINED_DEVICE + cirq.Device + cirq.GridQid + cirq.GridQubit + cirq.LineQid + cirq.LineQubit + cirq.NamedQubit + cirq.Qid + + +Measurement +''''''''''' + +Methods and classes for performing measurement operations. + +.. autosummary:: + :toctree: generated/ + + cirq.measure + cirq.measure_each + cirq.MeasurementGate + + +Unitary Gates and Operations +'''''''''''''''''''''''''''' + +Unitary effects that can be applied to one or more qubits. + +.. autosummary:: + :toctree: generated/ + + cirq.H + cirq.I + cirq.S + cirq.T + cirq.X + cirq.Y + cirq.Z + cirq.CX + cirq.CZ + cirq.XX + cirq.YY + cirq.ZZ + cirq.rx + cirq.ry + cirq.rz + cirq.CCNOT + cirq.CCX + cirq.CCZ + cirq.CNOT + cirq.CSWAP + cirq.FREDKIN + cirq.ISWAP + cirq.SWAP + cirq.TOFFOLI + cirq.givens + cirq.identity_each + cirq.qft + cirq.riswap + .. autoclass:: cirq.CCNotPowGate + cirq.CCXPowGate + cirq.CCZPowGate + .. autoclass:: cirq.CNotPowGate + cirq.CSwapGate + cirq.CXPowGate + cirq.CZPowGate + cirq.ControlledGate + cirq.ControlledOperation + cirq.EigenGate + cirq.FSimGate + cirq.Gate + cirq.GlobalPhaseOperation + cirq.HPowGate + cirq.ISwapPowGate + cirq.IdentityGate + cirq.MatrixGate + cirq.Operation + cirq.PhaseGradientGate + cirq.PhasedISwapPowGate + cirq.PhasedXPowGate + cirq.PhasedXZGate + cirq.QuantumFourierTransformGate + cirq.RandomGateChannel + cirq.SingleQubitGate + cirq.SwapPowGate + cirq.TaggedOperation + cirq.ThreeQubitDiagonalGate + cirq.ThreeQubitGate + cirq.TwoQubitDiagonalGate + cirq.TwoQubitGate + cirq.WaitGate + cirq.XPowGate + cirq.XXPowGate + cirq.YPowGate + cirq.YYPowGate + cirq.ZPowGate + cirq.ZZPowGate + + +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. + +.. autosummary:: + :toctree: generated/ + + cirq.NOISE_MODEL_LIKE + cirq.NO_NOISE + cirq.amplitude_damp + cirq.asymmetric_depolarize + cirq.bit_flip + cirq.depolarize + cirq.generalized_amplitude_damp + cirq.phase_damp + cirq.phase_flip + cirq.reset + cirq.AmplitudeDampingChannel + cirq.AsymmetricDepolarizingChannel + cirq.BitFlipChannel + cirq.DepolarizingChannel + cirq.GeneralizedAmplitudeDampingChannel + cirq.NoiseModel + cirq.PhaseDampingChannel + cirq.PhaseFlipChannel + cirq.ResetChannel + cirq.VirtualTag + + +Pauli and Clifford Groups +''''''''''''''''''''''''' + +Classes and methods related to representing and operating on states using sums +and products of Pauli operations. + +.. autosummary:: + :toctree: generated/ + + cirq.PAULI_BASIS + cirq.PAULI_GATE_LIKE + cirq.PAULI_STRING_LIKE + cirq.pow_pauli_combination + cirq.BaseDensePauliString + cirq.CliffordState + cirq.CliffordTableau + cirq.DensePauliString + cirq.MutableDensePauliString + cirq.Pauli + cirq.PauliInteractionGate + cirq.PauliString + cirq.PauliStringGateOperation + cirq.PauliStringPhasor + cirq.PauliSum + cirq.PauliSumLike + cirq.PauliTransform + cirq.SingleQubitCliffordGate + cirq.StabilizerStateChForm + + +Circuits +'''''''' + +Utilities for representing and manipulating quantum computations via +Circuits, Operations, and Moments. + +.. autosummary:: + :toctree: generated/ + + cirq.OP_TREE + cirq.flatten_op_tree + cirq.freeze_op_tree + cirq.transform_op_tree + cirq.Circuit + cirq.CircuitDag + cirq.GateOperation + cirq.InsertStrategy + cirq.Moment + cirq.ParallelGateOperation + cirq.QubitOrder + cirq.QubitOrderOrList + cirq.Unique + + +Importing and Exporting +''''''''''''''''''''''' + +Utilities for interoperating with other quantum software libraries and products. + +.. autosummary:: + :toctree: generated/ + + cirq.quirk_json_to_circuit + cirq.quirk_url_to_circuit + + +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. + +.. autosummary:: + :toctree: generated/ + + cirq.CIRCUIT_LIKE + cirq.RANDOM_STATE_OR_SEED_LIKE + cirq.big_endian_bits_to_int + cirq.big_endian_digits_to_int + cirq.big_endian_int_to_bits + cirq.big_endian_int_to_digits + cirq.final_density_matrix + cirq.final_state_vector + cirq.flatten + cirq.flatten_to_ops + cirq.flatten_to_ops_or_moments + cirq.flatten_with_params + cirq.flatten_with_sweep + cirq.hog_score_xeb_fidelity_from_probabilities + cirq.measure_density_matrix + cirq.measure_state_vector + cirq.sample + cirq.sample_density_matrix + cirq.sample_state_vector + cirq.sample_sweep + cirq.to_resolvers + cirq.to_sweep + cirq.to_sweeps + cirq.validate_mixture + cirq.validate_probability + cirq.xeb_fidelity + cirq.ActOnStateVectorArgs + cirq.CircuitSampleJob + cirq.CliffordSimulator + cirq.CliffordSimulatorStepResult + cirq.CliffordTrialResult + cirq.Collector + cirq.DensityMatrixSimulator + cirq.DensityMatrixSimulatorState + cirq.DensityMatrixStepResult + cirq.DensityMatrixTrialResult + cirq.ExpressionMap + cirq.Linspace + cirq.ListSweep + .. autoclass:: cirq.ParamDictType + cirq.ParamResolver + cirq.ParamResolverOrSimilarType + cirq.PauliSumCollector + cirq.Points + cirq.Product + cirq.Sampler + cirq.SimulatesAmplitudes + cirq.SimulatesFinalState + cirq.SimulatesIntermediateState + cirq.SimulatesIntermediateStateVector + cirq.SimulatesSamples + cirq.SimulationTrialResult + cirq.Simulator + cirq.SparseSimulatorStep + cirq.StateVectorMixin + cirq.StateVectorSimulatorState + cirq.StateVectorStepResult + cirq.StateVectorTrialResult + cirq.StepResult + cirq.Sweep + cirq.Sweepable + cirq.TrialResult + cirq.UnitSweep + cirq.Zip + + +Visualization +''''''''''''' + +Classes and methods for visualizing data. + +.. autosummary:: + :toctree: generated/ + + cirq.plot_state_histogram + cirq.scatter_plot_normalized_kak_interaction_coefficients + cirq.Heatmap + cirq.TextDiagramDrawer + + +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. + +.. autosummary:: + :toctree: generated/ + + cirq.DEFAULT_RESOLVERS + cirq.act_on + cirq.apply_channel + cirq.apply_mixture + cirq.apply_unitaries + cirq.apply_unitary + cirq.approx_eq + cirq.channel + cirq.circuit_diagram_info + cirq.compute_cphase_exponents_for_fsim_decomposition + cirq.decompose + cirq.decompose_cphase_into_two_fsim + cirq.decompose_once + cirq.decompose_once_with_qubits + cirq.equal_up_to_global_phase + cirq.has_channel + cirq.has_mixture + cirq.has_mixture_channel + cirq.has_stabilizer_effect + cirq.has_unitary + cirq.inverse + cirq.is_measurement + cirq.is_parameterized + cirq.measurement_key + cirq.measurement_keys + cirq.mixture + cirq.mixture_channel + cirq.mul + cirq.num_qubits + cirq.pauli_expansion + cirq.phase_by + cirq.pow + cirq.qasm + cirq.qid_shape + cirq.quil + cirq.read_json + cirq.resolve_parameters + cirq.to_json + cirq.trace_distance_bound + cirq.trace_distance_from_angle_list + cirq.unitary + cirq.ApplyChannelArgs + cirq.ApplyMixtureArgs + cirq.ApplyUnitaryArgs + cirq.CircuitDiagramInfo + cirq.CircuitDiagramInfoArgs + cirq.QasmArgs + cirq.QasmOutput + cirq.QuilFormatter + cirq.QuilOutput + cirq.SupportsActOn + cirq.SupportsApplyChannel + cirq.SupportsApplyMixture + cirq.SupportsApproximateEquality + cirq.SupportsChannel + cirq.SupportsCircuitDiagramInfo + cirq.SupportsCommutes + cirq.SupportsConsistentApplyUnitary + cirq.SupportsDecompose + cirq.SupportsDecomposeWithQubits + cirq.SupportsEqualUpToGlobalPhase + cirq.SupportsExplicitHasUnitary + cirq.SupportsExplicitNumQubits + cirq.SupportsExplicitQidShape + cirq.SupportsJSON + cirq.SupportsMeasurementKey + cirq.SupportsMixture + cirq.SupportsParameterization + cirq.SupportsPhase + cirq.SupportsQasm + cirq.SupportsQasmWithArgs + cirq.SupportsQasmWithArgsAndQubits + cirq.SupportsTraceDistanceBound + cirq.SupportsUnitary + + +Optimization +'''''''''''' + +Classes and methods for rewriting circuits. + +.. autosummary:: + :toctree: generated/ + + cirq.decompose_multi_controlled_rotation + cirq.decompose_multi_controlled_x + cirq.decompose_two_qubit_interaction_into_four_fsim_gates_via_b + cirq.merge_single_qubit_gates_into_phased_x_z + cirq.merge_single_qubit_gates_into_phxz + cirq.single_qubit_matrix_to_gates + cirq.single_qubit_matrix_to_pauli_rotations + cirq.single_qubit_matrix_to_phased_x_z + cirq.single_qubit_matrix_to_phxz + cirq.single_qubit_op_to_framed_phase_form + cirq.stratified_circuit + cirq.two_qubit_matrix_to_operations + cirq.ConvertToCzAndSingleGates + cirq.DropEmptyMoments + cirq.DropNegligible + cirq.EjectPhasedPaulis + cirq.EjectZ + cirq.ExpandComposite + cirq.MergeInteractions + cirq.MergeSingleQubitGates + cirq.PointOptimizationSummary + cirq.PointOptimizer + cirq.SynchronizeTerminalMeasurements + + Experiments ''''''''''' @@ -11,4 +429,292 @@ run experiments. .. autosummary:: :toctree: generated/ + cirq.estimate_single_qubit_readout_errors + cirq.generate_boixo_2018_supremacy_circuits_v2 + cirq.generate_boixo_2018_supremacy_circuits_v2_bristlecone + cirq.generate_boixo_2018_supremacy_circuits_v2_grid + cirq.linear_xeb_fidelity + cirq.linear_xeb_fidelity_from_probabilities + cirq.log_xeb_fidelity + cirq.log_xeb_fidelity_from_probabilities + cirq.experiments.GRID_ALIGNED_PATTERN + cirq.experiments.GRID_STAGGERED_PATTERN + cirq.experiments.build_entangling_layers .. autofunction:: cirq.experiments.cross_entropy_benchmarking + cirq.experiments.get_state_tomography_data + cirq.experiments.rabi_oscillations + cirq.experiments.random_rotations_between_grid_interaction_layers_circuit + cirq.experiments.single_qubit_randomized_benchmarking + cirq.experiments.single_qubit_state_tomography + cirq.experiments.state_tomography + cirq.experiments.t1_decay + cirq.experiments.t2_decay + cirq.experiments.two_qubit_randomized_benchmarking + cirq.experiments.two_qubit_state_tomography + cirq.experiments.CrossEntropyResult + cirq.experiments.GridInteractionLayer + cirq.experiments.RabiResult + cirq.experiments.RandomizedBenchMarkResult + cirq.experiments.SingleQubitReadoutCalibrationResult + cirq.experiments.StateTomographyExperiment + cirq.experiments.T1DecayResult + cirq.experiments.T2DecayResult + cirq.experiments.TomographyResult + + +Ion traps and neutral atoms +''''''''''''''''''''''''''' + +Support for ion trap an neutral atom devices. + +.. autosummary:: + :toctree: generated/ + + cirq.ms + cirq.is_native_neutral_atom_gate + cirq.is_native_neutral_atom_op + cirq.two_qubit_matrix_to_ion_operations + cirq.ConvertToIonGates + cirq.ConvertToNeutralAtomGates + cirq.IonDevice + cirq.NeutralAtomDevice + + + +Google +'''''' + +Functionality specific to quantum hardware and services from Google. + +.. autosummary:: + :toctree: generated/ + + cirq.google.FSIM_GATESET + cirq.google.SQRT_ISWAP_GATESET + cirq.google.SYC + cirq.google.SYC_GATESET + cirq.google.XMON + cirq.google.engine_from_environment + cirq.google.is_native_xmon_gate + cirq.google.is_native_xmon_op + cirq.google.line_on_device + cirq.google.optimized_for_sycamore + cirq.google.optimized_for_xmon + cirq.google.pack_results + cirq.google.unpack_results + cirq.google.AnnealSequenceSearchStrategy + cirq.google.Bristlecone + cirq.google.Calibration + cirq.google.ConvertToSqrtIswapGates + cirq.google.ConvertToSycamoreGates + cirq.google.ConvertToXmonGates + cirq.google.DeserializingArg + cirq.google.Engine + cirq.google.EngineJob + cirq.google.EngineProcessor + cirq.google.EngineProgram + cirq.google.EngineTimeSlot + cirq.google.Foxtail + cirq.google.GateOpDeserializer + cirq.google.GateOpSerializer + cirq.google.GateTabulation + cirq.google.GreedySequenceSearchStrategy + cirq.google.LinePlacementStrategy + cirq.google.PhysicalZTag + cirq.google.ProtoVersion + cirq.google.QuantumEngineSampler + cirq.google.SerializableDevice + cirq.google.SerializableGateSet + cirq.google.SerializingArg + cirq.google.Sycamore + cirq.google.Sycamore23 + cirq.google.SycamoreGate + cirq.google.XmonDevice + + +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. + +.. autosummary:: + :toctree: generated/ + + cirq.contrib.acquaintance + cirq.contrib.paulistring + cirq.contrib.qcircuit + cirq.contrib.quirk + + +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. + + +.. autosummary:: + :toctree: generated/ + + cirq.alternative + cirq.json_serializable_dataclass + cirq.obj_to_dict_helper + cirq.value_equality + cirq.ABCMetaImplementAnyOneOf + cirq.ArithmeticOperation + cirq.InterchangeableQubitsGate + cirq.LinearDict + cirq.PeriodicValue + cirq.testing.DEFAULT_GATE_DOMAIN + cirq.testing.assert_allclose_up_to_global_phase + cirq.testing.assert_circuits_with_terminal_measurements_are_equivalent + cirq.testing.assert_commutes_magic_method_consistent_with_unitaries + cirq.testing.assert_decompose_is_consistent_with_unitary + cirq.testing.assert_eigengate_implements_consistent_protocols + cirq.testing.assert_equivalent_repr + cirq.testing.assert_has_consistent_apply_unitary + cirq.testing.assert_has_consistent_apply_unitary_for_various_exponents + cirq.testing.assert_has_consistent_qid_shape + cirq.testing.assert_has_consistent_trace_distance_bound + cirq.testing.assert_has_diagram + cirq.testing.assert_implements_consistent_protocols + cirq.testing.assert_json_roundtrip_works + cirq.testing.assert_logs + cirq.testing.assert_pauli_expansion_is_consistent_with_unitary + cirq.testing.assert_phase_by_is_consistent_with_unitary + cirq.testing.assert_qasm_is_consistent_with_unitary + cirq.testing.assert_same_circuits + cirq.testing.assert_specifies_has_unitary_if_unitary + cirq.testing.asyncio_pending + cirq.testing.highlight_text_differences + cirq.testing.nonoptimal_toffoli_circuit + cirq.testing.random_circuit + cirq.testing.random_density_matrix + cirq.testing.random_orthogonal + cirq.testing.random_special_orthogonal + cirq.testing.random_special_unitary + cirq.testing.random_superposition + cirq.testing.random_unitary + cirq.testing.EqualsTester + cirq.testing.OrderTester + + +Algebra and Representation +'''''''''''''''''''''''''' + +.. autosummary:: + :toctree: generated/ + + cirq.CONTROL_TAG + cirq.DURATION_LIKE + cirq.all_near_zero + cirq.all_near_zero_mod + cirq.allclose_up_to_global_phase + cirq.apply_matrix_to_slices + cirq.axis_angle + cirq.bidiagonalize_real_matrix_pair_with_symmetric_products + cirq.bidiagonalize_unitary_with_special_orthogonals + cirq.block_diag + cirq.canonicalize_half_turns + cirq.chosen_angle_to_canonical_half_turns + cirq.chosen_angle_to_half_turns + cirq.commutes + cirq.deconstruct_single_qubit_matrix_into_angles + cirq.definitely_commutes + cirq.diagonalize_real_symmetric_and_sorted_diagonal_matrices + cirq.diagonalize_real_symmetric_matrix + cirq.dot + cirq.expand_matrix_in_orthogonal_basis + cirq.hilbert_schmidt_inner_product + cirq.is_diagonal + cirq.is_hermitian + cirq.is_negligible_turn + cirq.is_normal + cirq.is_orthogonal + cirq.is_special_orthogonal + cirq.is_special_unitary + cirq.is_unitary + cirq.kak_canonicalize_vector + cirq.kak_decomposition + cirq.kak_vector + cirq.kron + cirq.kron_bases + cirq.kron_factor_4x4_to_2x2s + cirq.kron_with_controls + cirq.map_eigenvalues + cirq.match_global_phase + cirq.matrix_commutes + cirq.matrix_from_basis_coefficients + cirq.partial_trace + cirq.partial_trace_of_state_vector_as_mixture + cirq.reflection_matrix_pow + cirq.slice_for_qubits_equal_to + cirq.so4_to_magic_su2s + cirq.sub_state_vector + cirq.targeted_conjugate_about + cirq.targeted_left_multiply + cirq.unitary_eig + cirq.AxisAngleDecomposition + cirq.Duration + cirq.KakDecomposition + cirq.Timestamp + + +Quantum Information Science +''''''''''''''''''''''''''' + +.. autosummary:: + :toctree: generated/ + + cirq.STATE_VECTOR_LIKE + cirq.bloch_vector_from_state_vector + cirq.density_matrix_from_state_vector + cirq.dirac_notation + cirq.eye_tensor + cirq.fidelity + cirq.one_hot + cirq.to_valid_density_matrix + cirq.to_valid_state_vector + cirq.validate_indices + cirq.validate_normalized_state_vector + cirq.validate_qid_shape + cirq.von_neumann_entropy + + +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. + +.. autosummary:: + :toctree: generated/ + + cirq.ConstantQubitNoiseModel + cirq.LinearCombinationOfGates + cirq.LinearCombinationOfOperations + cirq.SingleQubitPauliStringGateOperation + cirq.TParamVal + + +Deprecated +'''''''''' + +These objects and methods will be removed in a future version of the library. + +.. autosummary:: + :toctree: generated/ + + cirq.QFT + cirq.final_wavefunction + cirq.subwavefunction + cirq.validate_normalized_state + cirq.wavefunction_partial_trace_as_mixture + cirq.SimulatesIntermediateWaveFunction + cirq.WaveFunctionSimulatorState + cirq.WaveFunctionStepResult + cirq.WaveFunctionTrialResult From 3d932c53cc6abd704ea9a07756a2f3e2733c499d Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 14:39:47 -0700 Subject: [PATCH 6/8] Fix doc coverage test --- docs/docs_coverage_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/docs_coverage_test.py b/docs/docs_coverage_test.py index 9d733c8efd2..c64e665be7f 100644 --- a/docs/docs_coverage_test.py +++ b/docs/docs_coverage_test.py @@ -50,7 +50,8 @@ def _api_rst_fullnames_per_section() -> List[List[str]]: if section: result.append(section) section = [] - elif ' cirq.' in line or ' .. autoclass:: cirq.' in line: + elif (' cirq.' in line or ' .. autoclass:: cirq.' in line + or ' .. autofunction:: cirq.' in line): fullname = line[line.find('cirq'):].strip() if fullname in seen: # coverage: ignore @@ -62,6 +63,7 @@ def _api_rst_fullnames_per_section() -> List[List[str]]: return result + def test_public_values_equals_documented_values(): in_actual_api = _all_public() in_api_reference = { From 57569a550259b2d22f9c6aab295b54eb7d68bb56 Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 14:41:29 -0700 Subject: [PATCH 7/8] format --- docs/docs_coverage_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs_coverage_test.py b/docs/docs_coverage_test.py index c64e665be7f..5065d47c8e3 100644 --- a/docs/docs_coverage_test.py +++ b/docs/docs_coverage_test.py @@ -50,8 +50,8 @@ def _api_rst_fullnames_per_section() -> List[List[str]]: if section: result.append(section) section = [] - elif (' cirq.' in line or ' .. autoclass:: cirq.' in line - or ' .. autofunction:: cirq.' in line): + elif (' cirq.' in line or ' .. autoclass:: cirq.' in line or + ' .. autofunction:: cirq.' in line): fullname = line[line.find('cirq'):].strip() if fullname in seen: # coverage: ignore From 1cfaab4e79bfca2e39d3264a3c3f244f96b11dab Mon Sep 17 00:00:00 2001 From: Dave Bacon Date: Tue, 9 Jun 2020 14:51:30 -0700 Subject: [PATCH 8/8] one more --- docs/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 84692c3d7a7..7dc2861d895 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -592,7 +592,7 @@ operation. cirq.testing.asyncio_pending cirq.testing.highlight_text_differences cirq.testing.nonoptimal_toffoli_circuit - cirq.testing.random_circuit + .. autofunction:: cirq.testing.random_circuit cirq.testing.random_density_matrix cirq.testing.random_orthogonal cirq.testing.random_special_orthogonal