Qiskit.jl
Documentation for Qiskit.jl.
The documentation of Qiskit's C API may also be useful to reference when using this library.
Building circuits
Operations can be added to a QuantumCircuit in either of two equivalent styles. The first mirrors Qiskit's Python API, using property-style accessors on the circuit:
qc = QuantumCircuit(2, 2)
qc.h(1)
qc.cx(1, 2)
qc.measure(1, 1)
qc.measure(2, 2)The second is the more idiomatic-Julia Qiskit.Operations interface, in which each operation is a !-suffixed function taking the circuit as its first argument:
using Qiskit.Operations
qc = QuantumCircuit(2, 2)
h!(qc, 1)
cx!(qc, 1, 2)
measure!(qc, 1, 1)
measure!(qc, 2, 2)h!(qc, 1) and qc.h(1) append the same instruction; following Julia convention, the ! function returns qc whereas the property-style form returns nothing. The Operations names are not exported from Qiskit itself — you opt in with using Qiskit.Operations — so generic verbs such as measure! and reset! only enter your namespace if you ask for them. They can also be referenced fully-qualified, e.g. Qiskit.h!.
Indexing of qubits and clbits starts at one rather than zero, following Julia convention.
API Reference
Qiskit.OperationsQiskit.CountOpsClosureQiskit.QuantumCircuitQiskit.SparseObservableQiskit.SparseObservableQiskit.TargetQiskit.TargetQiskit.TargetEntryQiskit.TranspileLayoutQiskit.barrier!Qiskit.delay!Qiskit.measure!Qiskit.reset!Qiskit.transpileQiskit.unitary!
Qiskit.CountOpsClosure — Method
count_ops() -> Dict{String, Int}Return operation counts for the circuit.
Each call to this function performs O(n) work to traverse the circuit. If you need to access counts for multiple operations, store the result in a variable.
Qiskit.QuantumCircuit — Type
QuantumCircuitQuantum circuit representation.
Available read-only properties:
num_qubitsnum_clbitsnum_instructionsdata- contains instruction list
The additional properties are methods:
count_ops()- returns aDictof operation countsreset(qubit)measure(qubit, clbit)barrier(qubit1, qubit2, ...)unitary(matrix, [qubit1, qubit2, ...])- many standard gates corresponding to Qiskit's Python API
delay(qubit, duration::Unitful.Time)- insert a time delay onqubitwith specifiedduration
The instruction-appending accessors above (reset, measure, the gates, etc.) return nothing. For an idiomatic-Julia interface whose !-suffixed functions return the circuit, see Qiskit.Operations.
Qiskit.SparseObservable — Type
SparseObservableQiskit observable. This is a wrapper of QkObs, which is similar to SparseObservable in Python.
Qiskit.SparseObservable — Method
SparseObservable(n::Integer)Construct an empty SparseObservable on n qubits.
Qiskit.Target — Type
TargetA mapping of instructions and properties representing the particular constraints of a backend. Its purpose is to provide the compiler with information that allows it to compile an input circuit into another that is optimized taking in consideration the Target's specifications.
Available properties:
num_qubitsnum_instructions
Qiskit.Target — Method
Target(num_qubits)Qiskit.TargetEntry — Type
TargetEntryA mapping of qubit arguments and properties representing gate map of the Target.
Available properties:
num_properties
Qiskit.TranspileLayout — Type
TranspileLayoutThis type stores the permutation introduced by the transpiler. In general Qiskit’s transpiler is unitary-preserving up to the initial layout and output permutations. The initial layout is the mapping from virtual circuit qubits to physical qubits on the target and the output permutation is caused by swap gate insertion or permutation elision prior to the initial layout being set in the transpiler pipeline. This type tracks these details and provide an interface to reason about these permutations.
Qiskit.barrier! — Method
barrier!(qc::QuantumCircuit, qubits...)Append a barrier across qubits (or all qubits if none given). Mutates and returns qc. Same effect as qc.barrier(qubits...).
Qiskit.delay! — Method
delay!(qc::QuantumCircuit, qubit, duration, unit)Append a delay of duration (in unit) on qubit. Mutates and returns qc. Same effect as qc.delay(qubit, duration, unit). With Unitful loaded, delay!(qc, qubit, duration::Unitful.Time) is also available.
Qiskit.measure! — Method
measure!(qc::QuantumCircuit, qubit, clbit)Append a measurement of qubit into clbit. Mutates and returns qc. Same effect as qc.measure(qubit, clbit).
Qiskit.reset! — Method
reset!(qc::QuantumCircuit, qubit)Append a reset of qubit. Mutates and returns qc. Same effect as qc.reset(qubit).
Qiskit.transpile — Method
transpile(circuit, target)Transpile a single circuit.
The Qiskit transpiler is a quantum circuit compiler that rewrites a given input circuit to match the constraints of a QPU and optimizes the circuit for execution.
This function wraps qk_transpile, which is multithreaded internally and will launch a thread pool with threads equal to the number of CPUs reported by the operating system by default. This will include logical cores on CPUs with simultaneous multithreading. You can tune the number of threads with the RAYON_NUM_THREADS environment variable. For example, setting RAYON_NUM_THREADS=4 would limit the thread pool to 4 threads.
Qiskit.unitary! — Method
unitary!(qc::QuantumCircuit, matrix, qubits; check_input=true)Append a unitary matrix acting on qubits. Mutates and returns qc. Same effect as qc.unitary(matrix, qubits).
Qiskit.Operations — Module
Qiskit.OperationsIdiomatic-Julia interface for building circuits. Every operation is a !-suffixed function whose first argument is the QuantumCircuit it mutates:
using Qiskit
using Qiskit.Operations # brings h!, cx!, measure!, reset!, ... into scope
qc = QuantumCircuit(2, 2)
h!(qc, 1)
cx!(qc, 1, 2)
measure!(qc, 1, 1)
measure!(qc, 2, 2)These names are not re-exported from Qiskit itself — generic verbs like measure! and reset! are kept behind this submodule so they only enter your namespace if you ask for them. Each function is the same code path as the corresponding property-style accessor (qc.h(1) ≡ h!(qc, 1)).