Beispiel #1
0
class NWQSimBackendTestCase(QiskitTestCase):
    """Tests for the NWQSim backend."""
    def setUp(self):
        super().setUp()
        self.backend = NWQSimProvider('DMSimSimulator')['dmsim']

    def test_configuration(self):
        """Test backend.configuration()."""
        configuration = self.backend.configuration()
        return configuration

    def test_properties(self):
        """Test backend.properties()."""
        properties = self.backend.properties()
        self.assertEqual(properties, None)

    def test_status(self):
        """Test backend.status()."""
        status = self.backend.status()
        return status

    def test_run_circuit(self):
        """Test running a single circuit."""
        result = execute(bell(), self.backend, seed_transpiler=34342).result()
        self.assertEqual(result.success, True)
        return result
Beispiel #2
0
class NWQSimProviderTestCase(QiskitTestCase):
    """Tests for the NWQSim Provider."""
    def setUp(self):
        self.provider = NWQSimProvider()
        self.backend_name = 'dmsim'

    def test_backends(self):
        """Test the provider has backends."""
        backends = self.provider.backends()
        self.assertTrue(len(backends) > 0)

    def test_get_backend(self):
        """Test getting a backend from the provider."""
        backend = self.provider.get_backend(name=self.backend_name)
        self.assertEqual(backend.name(), self.backend_name)
Beispiel #3
0
 def setUp(self):
     self.seed = 88
     self.backend = NWQSimProvider('DMSimSimulator').backends['dmsim']
     qasm_filename = os.path.join(os.path.dirname(__file__), 'qasms',
                                  'example.qasm')
     compiled_circuit = QuantumCircuit.from_qasm_file(qasm_filename)
     transpiled_circuit = transpile(compiled_circuit, self.backend)
     compiled_circuit.name = 'test'
     self.circuit = transpiled_circuit
Beispiel #4
0
    def test_circuit_multi(self):
        """Test circuit multi regs declared at start.
        """
        qreg0 = QuantumRegister(2, 'q0')
        creg0 = ClassicalRegister(2, 'c0')
        qreg1 = QuantumRegister(2, 'q1')
        creg1 = ClassicalRegister(2, 'c1')
        circ = QuantumCircuit(qreg0, qreg1)
        circ.x(qreg0[1])
        circ.x(qreg1[0])

        meas = QuantumCircuit(qreg0, qreg1, creg0, creg1)
        meas.measure(qreg0, creg0)
        meas.measure(qreg1, creg1)

        qc = circ + meas

        backend_sim = NWQSimProvider('DMSimSimulator')['dmsim']

        result = execute(qc, backend_sim, seed_transpiler=34342).result()
        counts = result.get_counts(qc)

        target = {'01 10': 1024}
        self.assertEqual(counts, target)
Beispiel #5
0
import numpy as np
from math import pi
from qiskit import QuantumCircuit, transpile, execute
from qiskit import ClassicalRegister, QuantumRegister
from qiskit_nwqsim_provider import NWQSimProvider

nwqsim = NWQSimProvider('NWQSim')
print(nwqsim.backends)
backend = nwqsim.backends['svsim_cpu']
backend.set_n_cpus(4)

#q_a = QuantumRegister(3, name='qa')
#q_b = QuantumRegister(13, name='qb')
#c_a = ClassicalRegister(3)
#c_b = ClassicalRegister(13)

q_a = QuantumRegister(3, name='qa')
q_b = QuantumRegister(5, name='qb')
c_a = ClassicalRegister(3)
c_b = ClassicalRegister(5)

circuit = QuantumCircuit(q_a, q_b, c_a, c_b)

circuit.x(q_a[1])
circuit.x(q_b[1])
circuit.x(q_b[2])
circuit.x(q_b[4])
circuit.barrier()
circuit.h(q_a)
circuit.barrier(q_a)
circuit.h(q_b)
Beispiel #6
0
 def setUp(self):
     self.provider = NWQSimProvider()
     self.backend_name = 'dmsim'
Beispiel #7
0
 def setUp(self):
     super().setUp()
     self.backend = NWQSimProvider('DMSimSimulator')['dmsim']
Beispiel #8
0
import random
import unittest

import numpy
from scipy.stats import chi2_contingency

from qiskit import execute
from qiskit import QuantumCircuit
from qiskit import QuantumRegister
from qiskit import ClassicalRegister
from qiskit import BasicAer
from qiskit_nwqsim_provider import NWQSimProvider

try:
    global_pq_simulator = NWQSimProvider('DMSimSimulator')['dmsim']
except ImportError:
    _skip_class = True
else:
    _skip_class = False

from ._random_circuit_generator import RandomCircuitGenerator
from .common import QiskitTestCase


@unittest.skipIf(_skip_class, 'NWQSim simulator unavailable')
class TestNWQSimSimulator(QiskitTestCase):
    """
    Test NWQSim simulator.
    """