Esempio n. 1
0
def test_distributed_qft_agreement(nqubits):
    """Check ``_DistributedQFT`` agrees with normal ``QFT``."""
    initial_state = utils.random_numpy_state(nqubits)
    exact_state = exact_qft(initial_state)

    c = models._DistributedQFT(nqubits)
    final_state = c(np.copy(initial_state)).numpy()

    np.testing.assert_allclose(final_state, exact_state, atol=_atol)
Esempio n. 2
0
def test_distributed_qft_error():
    """Check that ``_DistributedQFT`` raises error if not sufficient qubits."""
    with pytest.raises(NotImplementedError):
        c = models._DistributedQFT(2, accelerators={"/GPU:0": 4})
    with pytest.raises(NotImplementedError):
        c = models.QFT(10, with_swaps=False, accelerators={"/GPU:0": 2})