QiskitIBMRuntime

Documentation for QiskitIBMRuntime.jl.

In order to use this package, the credentials currently must first be saved to $HOME/.qiskit/qiskit-ibm.json following the procedure in the qiskit-ibm-runtime README.

Example

This example constructs a circuit that generates a Bell state. It transpiles and submits that circuit to the least busy quantum backend. When the job is done, it displays the results.

using Qiskit
using QiskitIBMRuntime

function generate_bell_circuit()
    qc = QuantumCircuit(2, 2) # 2 qubits, 2 clbits
    qc.h(1)
    qc.cx(1, 2)
    qc.measure(1, 1)
    qc.measure(2, 2)
    qc
end

service = Service()
search_results = backend_search(service)
backend = least_busy(search_results)
@show backend.name
target = target_from_backend(backend, service)

qc = generate_bell_circuit()

transpiled_circuit, layout = transpile(qc, target)
@show transpiled_circuit.num_instructions

shots = 1024
job = run_sampler_job(service, backend, transpiled_circuit, shots)
samples = get_job_results(job, service)
@show samples

The above code is expected to generate output similar to the following:

backend.name = "ibm_fez"
transpiled_circuit.num_instructions = 10
samples = ["0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x1", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x2", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x1", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x1", "0x0", "0x0", "0x3", "0x2", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x2", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x2", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x1", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x2", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x1", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x2", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x2", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x1", "0x0", "0x3", "0x3", "0x3", "0x0", "0x1", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x1", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x1", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x2", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x3", "0x0", "0x2", "0x3", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x2", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x0", "0x0", "0x3", "0x2", "0x1", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x1", "0x0", "0x3", "0x2", "0x3", "0x3", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x0", "0x3", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x0", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0", "0x3", "0x3", "0x0", "0x3", "0x3", "0x3", "0x0", "0x0", "0x0", "0x3", "0x3", "0x3", "0x0", "0x3", "0x0", "0x3", "0x2", "0x3", "0x0", "0x3", "0x0", "0x0", "0x3", "0x0"]

API Reference

QiskitIBMRuntime.ServiceMethod
Service()

This constructor reads credentials from the file $HOME/.qiskit/qiskit-ibm.json.

In the future, this constructor may also support passing credentials via environment variables, but at the time of writing, this is not yet supported by qiskit-ibm-runtime-c.

source
QiskitIBMRuntime.get_job_resultsMethod
get_job_results(job, service; poll_interval=1)

Return job results as a Samples object. The poll_interval argument can be any type accepted by sleep(). By default, it will poll every second while in the Queued or Running state. To disable polling entirely and error if the job is not Completed, pass poll_interval=nothing.

source
QiskitIBMRuntime.least_busyMethod
least_busy(::BackendSearchResults)

Return the Backend which is least busy at the time of the backend search.

Available properties:

  • name
  • instance_name
  • instance_crn
source
QiskitIBMRuntime.run_sampler_jobMethod
run_sampler_job(service, backend, circuit, shots::Integer)

Submit a job to the sampler primitive.

The provided circuit must have "measure" instructions in order for its result to be useful.

source