IBMQClient
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
- create an
AccountInfo
using IBMQClient
using IBMQClient.Schema
account = AccountInfo(token)- create an
Qobjbased 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]),
]
)
]
)- find an available device
devices = IBMQClient.devices(account)- submit the job
job_info = IBMQClient.submit(account, RemoteJob(dev=devices[1]), qobj)- query the job status
job_info = IBMQClient.status(account, job_info)- download the results when
job_infohas statusCOMPLETED
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_athensAPI References
IBMQClient.AccountInfo — Typestruct 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.
IBMQClient.AuthAPI — TypeAuthAPI <: IBMQAPIIBM Q Authentication REST API.
IBMQClient.IBMQAPI — Typeabstract REST API type for IBM Q
IBMQClient.ProjectAPI — TypeProjectAPI <: IBMQAPIIBM Q Project REST API.
IBMQClient.ProjectAPI — MethodProjectAPI(base, hub::String, group::String, project::String)Create IBM Q Project REST API from given base uri, hub, group and project name project.
IBMQClient.ServiceAPI — TypeServiceAPI <: IBMQAPIIBM Q service REST API.
IBMQClient.ServiceAPI — MethodServiceAPI(::AuthAPI, access_token::String)Create IBM Q service REST API by querying authentication server.
IBMQClient.ServiceAPI — MethodServiceAPI([uri="https://api.quantum-computing.ibm.com/api"])Create IBM Q service REST API object.
IBMQClient.create_headers — Functioncreate_headers(api::IBMQAPI[, headers=HTTP.Header[]; kw...])Create headers for a IBMQ REST API object.
IBMQClient.create_remote_job — Methodcreate_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.
IBMQClient.devices — Methoddevices(x::AccountInfo)Query available devices using given AccountInfo.
IBMQClient.devices — Methoddevices(api::ProjectAPI, access_token::String; timeout = 0)Query available devices.
IBMQClient.hubs — Methodhubs(api::ServiceAPI, access_token::String)Get alll IBM hubs.
IBMQClient.jobs — Methodjobs(x::AccountInfo; kw...)Query jobs submitted using given AccountInfo.
IBMQClient.jobs — Methodjobs(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.
IBMQClient.login — Methodlogin(::AuthAPI, token::String)Login with user token.
IBMQClient.read_token — Functionread_token(qiskitrc::String[=expanduser("~/.qiskit/qiskitrc")])Read IBMQ API token from .qiskit/qiskitrc file. Default location is ~/.qiskit/qiskitrc.
IBMQClient.results — Methodresults(account::AccountInfo, job::JobInfo; use_object_storage::Bool = true)Download the results of given job, return nothing if the job status is not COMPLETED.
IBMQClient.status — Methodstatus(account::AccountInfo, job::JobInfo)Query the current status of job.
IBMQClient.submit — Methodsubmit(account::AccountInfo, remote_job::RemoteJob, qobj::Schema.Qobj)Submit a Qobj to remote device as a remote_job.
IBMQClient.user_hubs — Methoduser_hubs(api::ServiceAPI, access_token::String)Get given users' hubs.
IBMQClient.user_info — Methoduser_info(::AuthAPI, access_token::String)Get user info of given IBM Q account access token.
IBMQClient.user_urls — Methoduser_urls(::AuthAPI, access_token::String)Get user urls to create services etc.