0
$\begingroup$

I have the code below:

def load_IBMQ(channel,token):
    service = QiskitRuntimeService(channel=channel, token=token)
    #if len(IBMQ.stored_account()) == 0:
      #  IBMQ.save_account(token)
       # IBMQ.load_account()
    #elif IBMQ.active_account() == None:
     #   IBMQ.load_account()
    provider = service.backends(simulator=False, operational=True)#least_busy(operational=True, simulator=False)#IBMQ.get_provider(hub=hub, group=group, project=project)
    print("provider", provider)
    return provider
def get_device_info(channel,token,device_name,fields,datetime):
    dirname = './devices/%s'%datetime.date()
    filename = '%s/%s.pckl'%(dirname,device_name)
    _device_info = read_dict(filename=filename)
    if len(_device_info)==0:
        if not os.path.exists(dirname):
            os.makedirs(dirname)
        else:
            subprocess.run(['rm','-r',dirname])
            os.makedirs(dirname)
        provider = load_IBMQ(channel=channel,token=token)
        for x in provider:

            if 'qasm' not in str(x):
                device =x#get_backend(str(x))
                properties = device.properties(datetime=datetime)
                print("....properties....", properties)


                num_qubits = device.configuration().n_qubits#len(properties.qubits)
                print('Download device_info for %d-qubit %s'%(num_qubits,x))
                coupling_map = CouplingMap(device.configuration().coupling_map)
                noise_model = NoiseModel.from_backend(device)
                basis_gates = noise_model.basis_gates
                _device_info = {'properties':properties,#device.configuration(),
                'coupling_map':coupling_map,
                'noise_model':noise_model,
                'basis_gates':basis_gates}
                pickle.dump(_device_info, open('%s/%s.pckl'%(dirname,str(x)),'wb'))
            print('-'*50)
        _device_info = read_dict(filename=filename)
    device_info = {}
    for field in fields:


        if field=='device':
            provider = load_IBMQ(channel=channel,token=token)
            #print(device_name)

            device = device_name#provider.get_backend(device_name)
            device_info[field] = device
        else:
            device_info[field] = _device_info[field]
    print("get_device_info end")
    return device_info

I get error

device_info[field] = _device_info[field]
                     ~~~~~~~~~~~~^^^^^^^
KeyError: 'properties'

How I get properties of real IBM quantum computer like ibm_osaka or others quantum computer in Qiskit SDK 1.0

$\endgroup$

1 Answer 1

0
$\begingroup$

Once you have got the list of backends from a service as in your load_IBMQ function above (also see get-backend-information in qiskit docs), you can access the properties of each backend through its attributes (see IBMBackend in qiskit docs) i.e.,

print(backend.coupling_map)

output:

[[0, 1], [0, 14], [1, 2], [2, 3], [4, 3], [4, 15], ...

or through the backend configuration as follows

configuration = backend.configuration()
print(configuration.coupling_map)

output:

[[0, 1], [0, 14], [1, 2], [2, 3], [4, 3], [4, 15], ...
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.