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 samplesThe 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.BackendQiskitIBMRuntime.BackendSearchResultsQiskitIBMRuntime.JobQiskitIBMRuntime.JobStatusQiskitIBMRuntime.SamplesQiskitIBMRuntime.ServiceQiskitIBMRuntime.ServiceQiskitIBMRuntime.backend_searchQiskitIBMRuntime.get_job_resultsQiskitIBMRuntime.get_job_statusQiskitIBMRuntime.least_busyQiskitIBMRuntime.run_sampler_jobQiskitIBMRuntime.target_from_backend
QiskitIBMRuntime.Backend — Type
BackendThis type represents a quantum hardware backend.
QiskitIBMRuntime.BackendSearchResults — Type
BackendSearchResults <: AbstractVector{Backend}This type contains the results of a backend search.
QiskitIBMRuntime.Job — Type
JobQiskit IBM Runtime job.
QiskitIBMRuntime.JobStatus — Type
JobStatusEnum which represents the status of a job.
QiskitIBMRuntime.Samples — Type
Samples <: AbstractVector{String}Data type which stores samples returned from the quantum computer.
QiskitIBMRuntime.Service — Type
ServiceThis type represents an instance of the Qiskit IBM Runtime service.
QiskitIBMRuntime.Service — Method
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.
QiskitIBMRuntime.backend_search — Method
backend_search(service)Obtain knowledge of the backends available for the given service, in the form of a BackendSearchResults object.
QiskitIBMRuntime.get_job_results — Method
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.
QiskitIBMRuntime.get_job_status — Method
get_job_status(job, service)Return status of job as a JobStatus enum.
QiskitIBMRuntime.least_busy — Method
least_busy(::BackendSearchResults)Return the Backend which is least busy at the time of the backend search.
Available properties:
nameinstance_nameinstance_crn
QiskitIBMRuntime.run_sampler_job — Method
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.
QiskitIBMRuntime.target_from_backend — Method
target_from_backend(backend, service)Construct a Qiskit.Target which is appropriate for the provided Backend.