Exemple #1
0
def state_transfer_infid(ideal: np.ndarray, actual: tf.constant, index, dims,
                         psi_0):
    """
    Single gate state transfer infidelity. The dimensions of psi_0 and ideal need to be
    compatible and index and dims need to project actual to these same dimensions.

    Parameters
    ----------
    ideal: np.ndarray
        Contains ideal unitary representations of the gate
    actual: tf.Tensor
        Contains actual unitary representations of the gate
    index : int
        Index of the qubit(s) in the Hilbert space to be evaluated
    dims : list
        List of dimensions of qubits
    psi_0: tf.Tensor
        Initial state

    Returns
    -------
    tf.float
        State infidelity for the selected gate

    """
    actual_comp = tf_project_to_comp(actual, dims=dims, index=index)
    psi_ideal = tf.matmul(ideal, psi_0)
    psi_actual = tf.matmul(actual_comp, psi_0)
    overlap = tf_ketket_fid(psi_ideal, psi_actual)
    infid = 1 - overlap
    return infid
Exemple #2
0
def iswap_leakage(U_dict: dict, index, dims, eval, proj=True):
    indeces = np.append(
        np.append(np.arange(2, dims[1]), np.arange(2, dims[1]) + dims[2]),
        np.arange(dims[1] * dims[2], np.prod(dims)),
    )
    psi_init = [0] * np.prod(dims)
    psi_init[1] = 1
    psi_0 = tf.Variable(psi_init, dtype=tf.complex128, shape=[np.prod(dims), 1])
    psi_actual = tf.matmul(U_dict["Id:iSWAP"], psi_0)
    leakage = 0
    for indx in indeces:  # fix indeces
        psi = [0] * np.prod(dims)
        psi[indx] = 1
        psi = tf.Variable(psi, dtype=tf.complex128, shape=[np.prod(dims), 1])
        leakage = leakage + tf_ketket_fid(psi, psi_actual)
    return leakage
Exemple #3
0
def state_transfer_infid(U_dict: dict, gate: str, index, dims, psi_0, proj: bool):
    """
    Single gate state transfer infidelity.

    Parameters
    ----------
    U_dict : dict
        Contains unitary representations of the gates, identified by a key.
    index : int
        Index of the qubit(s) in the Hilbert space to be evaluated
    gate : str
        One of the keys of U_dict, selects the gate to be evaluated
    dims : list
        List of dimensions of qubits
    psi_0 : tf.Tensor
        Initial state of the device
    proj : boolean
        Project to computational subspace

    Returns
    -------
    tf.float
        State infidelity for the selected gate

    """
    U = U_dict[gate]
    projection = 'fulluni'
    if proj:
        projection = 'wzeros'
    U_ideal = tf.constant(
        perfect_gate(gate, index, dims, projection),
        dtype=tf.complex128
    )
    psi_ideal = tf.matmul(U_ideal, psi_0)
    psi_actual = tf.matmul(U, psi_0)
    overlap = tf_ketket_fid(psi_ideal, psi_actual)
    infid = 1 - overlap
    return infid