Ejemplo n.º 1
0
def serial_executor(circuit: QPROGRAM, noise: float = BASE_NOISE) -> float:
    """A noisy executor function which executes the input circuit with `noise`
    depolarizing noise and returns the expectation value of the ground state
    projector. Simulation will be slow for "large circuits" (> a few qubits).
    """
    circuit, _ = convert_to_mitiq(circuit)

    # Ground state projector.
    d = 2**len(circuit.all_qubits())
    obs = np.zeros(shape=(d, d), dtype=np.float32)
    obs[0, 0] = 1.0

    return noisy_simulation(circuit, noise, obs)
Ejemplo n.º 2
0
def executor(circuit: Circuit) -> float:
    """A one- or two-qubit noisy executor function.
    It executes the input circuit with BASE_NOISE depolarizing noise and
    returns the expectation value of the ground state projector.
    """
    if len(circuit.all_qubits()) == 1:
        obs = np.array([[1, 0], [0, 0]])
    elif len(circuit.all_qubits()) == 2:
        obs = np.array(
            [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
        )
    else:
        raise ValueError("The input must be a circuit with 1 or 2 qubits.")

    return noisy_simulation(circuit, BASE_NOISE, obs,)
Ejemplo n.º 3
0
 def obs_sim(circ: Circuit) -> float:
     # we only want the expectation value not the variance
     # this is why we return [0]
     return noisy_simulation(circ, noise, obs)
Ejemplo n.º 4
0
 def noisy_backend(circ: Circuit) -> float:
     return noisy_simulation(circ, noise, obs)
 def executor(qc):
     return noisy_simulation(qc, noise=noise, obs=obs)