IBMQClient

Build Status Coverage

Julia Wrapper for the IBM Quantum Experience REST API. This API wrapper is based on IBM Q official implementation but is not an IBM official package.

Usage

  1. create an AccountInfo
using IBMQClient
using IBMQClient.Schema
account = AccountInfo(token)
  1. create an Qobj based on the Qobj schema specification, e.g
qobj = Qobj(;
    qobj_id="bell_Qobj_07272018",
    type="QASM",
    schema_version=v"1",
    header=Dict("description"=>"Bell states"),
    config=ExpConfig(shots=1000, memory_slots=2),
    experiments=[
        Experiment(;
            header=Dict("description"=>"|11>+|00> Bell"),
            instructions=[
                Gate(name="u2", qubits=[0], params=[0.0, π]),
                Gate(name="cx", qubits=[0, 1]),
                Measure(qubits=[0, 1], memory=[0, 1]),
            ]
        ),
        Experiment(;
            header=Dict("description"=>"|01>+|10> Bell"),
            instructions=[
                Gate(name="u2", qubits=[0], params=[0.0, π]),
                Gate(name="cx", qubits=[0, 1]),
                Gate(name="u3", qubits=[0], params=[π, 0.0, π]),
                Measure(qubits=[0, 1], memory=[0, 1]),
            ]
        )
    ]
)
  1. find an available device
devices = IBMQClient.devices(account)
  1. submit the job
job_info = IBMQClient.submit(account, RemoteJob(dev=devices[1]), qobj)
  1. query the job status
job_info = IBMQClient.status(account, job_info)
  1. download the results when job_info has status COMPLETED
IBMQClient.results(account, job_info)

REPL Terminal Menu

We have a Terminal Menu for easy-reading IBM device information in terminal. You can start it by

julia> using REPL.TerminalMenus
julia> menu = IBMQClient.DeviceMenu(devices)
julia> choice = request("choose a device:", menu)
choose a device:
   ibmq_qasm_simulator            nqubits: 1
   ibmqx2                         max_shots: 8192
   ibmq_16_melbourne              credits_required:: true
 → ibmq_armonk
v  ibmq_athens

API References

IBMQClient.AccountInfoType
struct AccountInfo

AccountInfo([token=read_token()])

Create an AccountInfo object from given IBMQ API token. You can create your own token at https://quantum-computing.ibm.com/ after login. It will look at ~/.qiskit/qiskitrc for the API token by default. See read_token for more information.

source
IBMQClient.ProjectAPIMethod
ProjectAPI(base, hub::String, group::String, project::String)

Create IBM Q Project REST API from given base uri, hub, group and project name project.

source
IBMQClient.ServiceAPIMethod
ServiceAPI(::AuthAPI, access_token::String)

Create IBM Q service REST API by querying authentication server.

source
IBMQClient.ServiceAPIMethod
ServiceAPI([uri="https://api.quantum-computing.ibm.com/api"])

Create IBM Q service REST API object.

source
IBMQClient.create_remote_jobMethod
create_remote_job(api::ProjectAPI, device::IBMQDevice, access_token::String; job_name=nothing, job_share_level=nothing, job_tags=nothing)

Create a job instance on the remote server.

Args

  • device_name: A IBM Q device name.
  • job_name: Custom name to be assigned to the job.
  • job_share_level: Level the job should be shared at.
  • job_tags: Tags to be assigned to the job.
source
IBMQClient.jobsMethod
jobs(api::ProjectAPI, access_token::String; descending::Bool=true, limit::Int=10, skip::Int=0, extra_filter=nothing)

Query available jobs.

Args

  • limit: Maximum number of items to return.
  • skip: Offset for the items to return.
  • descending: Whether the jobs should be in descending order.
  • extra_filter: Additional filtering passed to the query.
source
IBMQClient.read_tokenFunction
read_token(qiskitrc::String[=expanduser("~/.qiskit/qiskitrc")])

Read IBMQ API token from .qiskit/qiskitrc file. Default location is ~/.qiskit/qiskitrc.

source
IBMQClient.resultsMethod
results(account::AccountInfo, job::JobInfo; use_object_storage::Bool = true)

Download the results of given job, return nothing if the job status is not COMPLETED.

source
IBMQClient.submitMethod
submit(account::AccountInfo, remote_job::RemoteJob, qobj::Schema.Qobj)

Submit a Qobj to remote device as a remote_job.

source