示例#1
0
    def __init__(self):
        super().__init__()

        # load accounts
        from quantuminspire.qiskit import QI
        QI.set_authentication()
        self.Quantum_Inspire_cloud_providers = [QI]

        print_hl("Quantum Inspire cloud account loaded.")
示例#2
0
def _setup(B):
    if B == 'QI':
        authentication = get_authentication(B)
        QI.set_authentication(authentication, QI_URL)
        sim_backend = QI.get_backend('QX single-node simulator')

    elif B == 'LOCAL':
        sim_backend = Aer.get_backend('qasm_simulator')

    elif B == 'IBMQ':
        provider = get_authentication(B)
        sim_backend = provider.get_backend('ibmq_qasm_simulator')
    return sim_backend
示例#3
0
def QI_backend(qi_backend):
    '''
    Backends:
    'QX single-node simulator', 
    'Spin-2', 
    'Starmon-5'
    '''
    from quantuminspire.qiskit import QI
    from quantuminspire.credentials import save_account
    qi_token = '7ff8243ba6d4643e4ec1774b7079f8086df7e872'
    save_account(qi_token)
    QI.set_authentication()
    return QI.get_backend(
        qi_backend
    )  # Possible options: 'QX single-node simulator', 'Spin-2', 'Starmon-5'
示例#4
0
def QI_backend(qi_backend):
    '''
    Backends:
    'QX single-node simulator', 
    'Spin-2', 
    'Starmon-5'
    '''
    from quantuminspire.qiskit import QI
    from quantuminspire.credentials import save_account
    qi_token = '5697ec173ded946fc884e20d46b523de320a625c'
    save_account(qi_token)
    QI.set_authentication()
    return QI.get_backend(
        qi_backend
    )  # Possible options: 'QX single-node simulator', 'Spin-2', 'Starmon-5'
Copyright 2018-19 QuTech Delft. Licensed under the Apache License, Version 2.0.
"""
import os

from qiskit import execute
from qiskit.circuit import QuantumRegister, ClassicalRegister, QuantumCircuit

from quantuminspire.credentials import get_authentication
from quantuminspire.qiskit import QI

QI_URL = os.getenv('API_URL', 'https://api.quantum-inspire.com/')

project_name = 'Qiskit-entangle'
authentication = get_authentication()
QI.set_authentication(authentication, QI_URL, project_name=project_name)
qi_backend = QI.get_backend('QX single-node simulator')

q = QuantumRegister(2)
b = ClassicalRegister(2)
circuit = QuantumCircuit(q, b)

circuit.h(q[0])
circuit.cx(q[0], q[1])
circuit.measure(q, b)

qi_job = execute(circuit, backend=qi_backend, shots=256)
qi_result = qi_job.result()
histogram = qi_result.get_counts(circuit)
print('\nState\tCounts')
[
示例#6
0
    def setup_tabs(self):
        _translate = QtCore.QCoreApplication.translate
        self.ibm_backends = None
        self.dwave_backends = None
        self.inspire_backends = None
        self.rigetti_backends = None
        self.tab_infos = []

        # backend1 = {'name': '9q-square-noisy-qvm', 'number_of_qubits': 9,
        #             'max_number_of_shots': 65536, 'max_experiments': 'unlimited',
        #             'description': 'v. 1.17', 'accuracy': 'not accurate',
        #             'remaining_jobs': 'unlimited'}
        # backend2 = {'name': '26q-qvm', 'number_of_qubits': 26,
        #             'max_number_of_shots': 65536, 'max_experiments': 'unlimited',
        #             'description': 'v. 1.17', 'accuracy': '0',
        #             'remaining_jobs': 'unlimited'}
        # self.rigetti_backends = [backend1, backend2]

        if self.__qiskit is not None:
            IBMQ.enable_account(self.__qiskit)
            ibm_provider = IBMQ.get_provider('ibm-q')
            self.ibm_backends = ibm_provider.backends()

        if self.__inspire is not None:
            enable_account(self.__inspire)
            QI.set_authentication()
            server_url = r'https://api.quantum-inspire.com'
            auth = get_token_authentication()
            self.qi = QuantumInspireAPI(server_url, auth)
            # backends = []
            # for back in self.qi.get_backend_types():
            #     current_backend = {'name': back.get('name'), 'number_of_qubits': back.get('number_of_qubits'),
            #                        'max_number_of_shots': back.get('max_number_of_shots'),
            #                        'max_experiments': back.get('max_number_of_simultaneous_jobs'),
            #                        'description': back.get('description'), 'accuracy': 'not measured',
            #                        'remaining_jobs': back.get('max_number_of_simultaneous_jobs')}
            #     backends.append(current_backend)
            self.inspire_backends = self.qi.get_backend_types()

        if self.ibm_backends is not None:
            for backend in self.ibm_backends:
                self.tab_infos.append(ComputerInfoTab(backend))

        # if self.inspire_backends is not None:
        #     for backend in self.inspire_backends:
        #         # server = r'https://api.quantum-inspire.com'
        #         # email = '*****@*****.**'
        #         # password = '******'
        #         # auth = HTTPBasicAuth(email, password)
        #         #
        #         # result = requests.get(f'{server}/projects', auth=auth)
        #         #
        #         # print(f'result status: {result.status_code}')
        #         # print(result.json())
        #         # server = r'https://api.quantum-inspire.com'
        #         # auth = coreapi.auth.TokenAuthentication(self.__inspire)
        #         # client = coreapi.Client(auth=auth)
        #         # content = client.get(f'{server}/backendtypes/1/calibration')
        #         # print(content)
        #         # action = ['projects', 'list']
        #         # result = client.action(schema, action)
        #         # print(result)
        #         # server = r'https://api.quantum-inspire.com'
        #         # email = '*****@*****.**'
        #         # password = '******'
        #         # auth = HTTPBasicAuth(email, password)
        #         # contents = urllib.request.urlopen(r'https://api.quantum-inspire.com/backendtypes/1/calibration/',).read()
        #         self.tab_infos.append(ComputerInfoTab(backend._QuantumInspireBackend__backend))

        if self.inspire_backends is not None:
            for backend in self.inspire_backends:
                self.tab_infos.append(ComputerInfoTab(backend))

        if self.rigetti_backends is not None:
            for backend in self.rigetti_backends:
                self.tab_infos.append(ComputerInfoTab(backend))

        self.tab_widget = QtWidgets.QTabWidget(self.central_widget)
        self.tab_widget.setObjectName("tabWidget")

        self.tab_widget.addTab(self.test_info_tab.tab, "")
        self.tab_widget.setTabText(
            self.tab_widget.indexOf(self.test_info_tab.tab),
            _translate('main_window', self.test_info_tab.name))

        self.tab_widget.addTab(self.results_info_tab.tab, "")
        self.tab_widget.setTabText(
            self.tab_widget.indexOf(self.results_info_tab.tab),
            _translate('main_window', self.results_info_tab.name))

        for tab_info in self.tab_infos:
            self.tab_widget.addTab(tab_info.tab, "")
            self.tab_widget.setTabText(
                self.tab_widget.indexOf(tab_info.tab),
                _translate("main_window", tab_info.tab.objectName()))

        self.gridLayout_2.addWidget(self.tab_widget, 0, 0, 1, 1)
        self.tab_widget.setCurrentIndex(0)
示例#7
0
from DistributedFunctions import *
from AdderFunctionsDistr import *

# If you use token leave it as it is
QI_EMAIL = os.getenv('QI_EMAIL')
QI_PASSWORD = os.getenv('QI_PASSWORD')
QI_URL = os.getenv('API_URL', 'https://api.quantum-inspire.com/')

# Enter your token if needed and de-comment line below
# save_account('')


# Authenication procedure. Plug it in all your expermiments to establish connection between you and QI
authentication = get_authentication()
QI.set_authentication(authentication, QI_URL)
qi_backend = QI.get_backend('QX single-node simulator')


SetCounters()


# Specify the numbers you want to multiply
a_number = 1
x_number = 2

# Specify the mod value
N_number = 65535

# max n bits per register
n_max = 16
示例#8
0
        return get_token_authentication(token)
    else:
        if QI_EMAIL is None or QI_PASSWORD is None:
            print('Enter email:')
            email = input()
            print('Enter password')
            password = getpass()
        else:
            email, password = QI_EMAIL, QI_PASSWORD
        return get_basic_authentication(email, password)


if __name__ == '__main__':

    authentication = get_authentication()
    QI.set_authentication(authentication)
    qi_backend = QI.get_backend('QX single-node simulator')

    q = QuantumRegister(2)
    b = ClassicalRegister(2)
    circuit = QuantumCircuit(q, b)

    circuit.h(q[0])
    circuit.cx(q[0], q[1])
    circuit.measure(q, b)

    qi_job = execute(circuit, backend=qi_backend, shots=256)
    qi_result = qi_job.result()
    histogram = qi_result.get_counts(circuit)
    print('\nState\tCounts')
    [