View source on GitHub
|
Compile a two-qubit unitary onto hardware base gate(s) via numerical optimization.
cirq.two_qubit_gate_numerical_compilation(
target_unitary: np.ndarray,
base_gates: (np.ndarray | Sequence[np.ndarray]),
*,
target_fidelity: (float | None) = None,
max_layers: int = 3,
base_gate_error_rates: (Sequence[float] | None) = None,
single_qubit_error_rates: (float | tuple[float, float] | None) = None,
num_restarts: int = 5,
maxiter: int = 1000,
random_state: cirq.RANDOM_STATE_OR_SEED_LIKE = None
) -> TwoQubitNumericalCompilationResult
Implements the NuOp compilation technique of
arXiv:2106.15490.
The target unitary is decomposed into i layers of a base two-qubit gate
sandwiched between parameterized single-qubit gates,
\(k_i \cdot G \cdot k_{i-1} \cdot \ldots \cdot G \cdot k_0 \approx U_t\),
where the angles of the 1-local unitaries \(k_j\) are found by a BFGS numerical optimizer maximizing the decomposition fidelity \(F_d = |\mathrm{Tr}(U_d^\dagger U_t)| / 4\).
The number of layers is grown from 1 upward, optimizing each template in
turn, and the first decomposition whose fidelity meets target_fidelity
is returned. With several base gates, all of them are tried at each layer
count, so the returned decomposition is the one with the fewest layers
across all gate types. If no template with at most max_layers layers
meets target_fidelity, the highest-fidelity decomposition found is
returned with success set to False.
If error rates are given (base_gate_error_rates and/or
single_qubit_error_rates), the compiler additionally accounts
for hardware noise: instead of stopping at the first decomposition meeting
target_fidelity, all (base gate, layer count) combinations up to
max_layers are optimized, and the decomposition maximizing the overall
fidelity \(F_u = F_d \cdot F_h\) is returned, where the hardware fidelity
\(F_h\) is the product of (1 - error_rate) over all gates in the
decomposition. This can deliberately select an approximate decomposition
with fewer base gates when hardware noise dominates the decomposition
error, and selects the best base gate type for each target unitary. In
this mode success reports whether the selected decomposition meets
target_fidelity in terms of \(F_u\).
Returns | |
|---|---|
| A TwoQubitNumericalCompilationResult with the best decomposition found. |
View source on GitHub