cirq.PhasedFSimGate

General excitation-preserving two-qubit gate.

Inherits From: InterchangeableQubitsGate, Gate

Used in the notebooks

Used in the tutorials

The unitary matrix of PhasedFSimGate(θ, ζ, χ, γ, φ) is:

\[ \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & e^{-i \gamma - i \zeta} \cos(\theta) & -i e^{-i \gamma + i\chi} \sin(\theta) & 0 \\ 0 & -i e^{-i \gamma - i \chi} \sin(\theta) & e^{-i \gamma + i \zeta} \cos(\theta) & 0 \\ 0 & 0 & 0 & e^{-2i \gamma - i \phi} \end{bmatrix} \]

This parametrization follows eq (18) in https://arxiv.org/abs/2010.07965 See also eq (43) in https://arxiv.org/abs/1910.11333 for an older variant which uses the same θ and φ parameters, but has three phase angles that have different names and opposite sign. Specifically, ∆+ angle corresponds to -γ, ∆- corresponds to -ζ and ∆-,off corresponds to -χ.

Another useful parametrization of PhasedFSimGate is based on the fact that the gate is equivalent up to global phase to the following circuit:

0: ───Rz(α0)───FSim(θ, φ)───Rz(β0)───
               
1: ───Rz(α1)───FSim(θ, φ)───Rz(β1)───

where α0 and α1 are Rz angles to be applied before the core FSimGate, β0 and β1 are Rz angles to be applied after FSimGate and θ and φ specify the core FSimGate. Use the static factory function from_fsim_rz to instantiate the gate using this parametrization.

Note that the θ and φ parameters in the two parametrizations are the same.

The matrix above is block diagonal where the middle block may be any element of U(2) and the bottom right block may be any element of U(1). Consequently, five real parameters are required to specify an instance of PhasedFSimGate. Therefore, the second parametrization is not injective. Indeed, for any angle δ

cirq.PhasedFSimGate.from_fsim_rz(θ, φ, (α0, α1), (β0, β1))

and

cirq.PhasedFSimGate.from_fsim_rz(θ, φ,
                                 (α0 + δ, α1 + δ),
                                 (β0 - δ, β1 - δ))

specify the same gate and therefore the two instances will compare as equal up to numerical error. Another consequence of the non-injective character of the second parametrization is the fact that the properties rz_angles_before and rz_angles_after may return different Rz angles than the ones used in the call to from_fsim_rz.

This gate is generally not symmetric under exchange of qubits. It becomes symmetric if both of the following conditions are satisfied:

  • ζ = kπ or θ = π/2 + lπ for k and l integers,
  • χ = kπ or θ = lπ for k and l integers.

theta Swap angle on the |01⟩ |10⟩ subspace, in radians. See class docstring above for details.
zeta One of the phase angles, in radians. See class docstring above for details.
chi One of the phase angles, in radians. See class docstring above for details.
gamma One of the phase angles, in radians. See class docstring above for details.
phi Controlled phase angle, in radians. See class docstring above for details.

chi

gamma

phi

rz_angles_after Returns 2-tuple of phase angles applied to qubits after FSimGate.
rz_angles_before Returns 2-tuple of phase angles applied to qubits before FSimGate.
theta

zeta

Methods

controlled

View source

Returns a controlled version of this gate. If no arguments are specified, defaults to a single qubit control.

Args
num_controls Total number of control qubits.
control_values Which control computational basis state to apply the sub gate. A sequence of length num_controls where each entry is an integer (or set of integers) corresponding to the computational basis state (or set of possible values) where that control is enabled. When all controls are enabled, the sub gate is applied. If unspecified, control values default to 1.
control_qid_shape The qid shape of the controls. A tuple of the expected dimension of each control qid. Defaults to (2,) * num_controls. Specify this argument when using qudits.

Returns
A cirq.Gate representing self controlled by the given control values and qubits. This is a cirq.ControlledGate in the base implementation, but subclasses may return a different gate type.

from_fsim_rz

View source

Creates PhasedFSimGate using an alternate parametrization.

Args
theta Swap angle on the |01⟩ |10⟩ subspace, in radians. See class docstring above for details.
phi Controlled phase angle, in radians. See class docstring above for details.
rz_angles_before 2-tuple of phase angles to apply to each qubit before the core FSimGate. See class docstring for details.
rz_angles_after 2-tuple of phase angles to apply to each qubit after the core FSimGate. See class docstring for details.

num_qubits

View source

The number of qubits this gate acts on.

on

View source

Returns an application of this gate to the given qubits.

Args
*qubits The collection of qubits to potentially apply the gate to.

Returns: a cirq.Operation which is this gate applied to the given qubits.

on_each

View source

Returns a list of operations applying the gate to all targets.

Args
*targets The qubits to apply this gate to. For single-qubit gates this can be provided as varargs or a combination of nested iterables. For multi-qubit gates this must be provided as an Iterable[Sequence[Qid]], where each sequence has num_qubits qubits.

Returns
Operations applying this gate to the target qubits.

Raises
ValueError If targets are not instances of Qid or Iterable[Qid]. If the gate qubit number is incompatible.
TypeError If a single target is supplied and it is not iterable.

qubit_index_to_equivalence_group_key

View source

Returns a key that differs between non-interchangeable qubits.

validate_args

View source

Checks if this gate can be applied to the given qubits.

By default checks that:

  • inputs are of type Qid
  • len(qubits) == num_qubits()
  • qubit_i.dimension == qid_shape[i] for all qubits

Child classes can override. The child implementation should call super().validate_args(qubits) then do custom checks.

Args
qubits The sequence of qubits to potentially apply the gate to.

Raises
ValueError The gate can't be applied to the qubits.

with_probability

View source

Creates a probabilistic channel with this gate.

Args
probability floating point value between 0 and 1, giving the probability this gate is applied.

Returns
cirq.RandomGateChannel that applies self with probability probability and the identity with probability 1-p.

wrap_in_linear_combination

View source

Returns a LinearCombinationOfGates with this gate.

Args
coefficient number coefficient to use in the resulting cirq.LinearCombinationOfGates object.

Returns
cirq.LinearCombinationOfGates containing self with a coefficient of coefficient.

__add__

View source

__call__

View source

Call self as a function.

__eq__

View source

__mul__

View source

__ne__

View source

__neg__

View source

__pow__

View source

__rmul__

View source

__sub__

View source

__truediv__

View source