Skip to Content
New in v0.1.0 OpenQASM export: run fqkit circuits on real IBM hardware
DocumentationOpenQASM & Hardware

OpenQASM & Hardware

FQkit can export any circuit to OpenQASM 2.0, the open standard that Qiskit reads. From your own Python you can also submit that circuit to a real machine and check the job while it waits in the queue.

💡

The simulator and the OpenQASM export depend only on NumPy. A hardware job uses the vendor’s account. IBM has a free plan with a queue. Machines reached through Amazon Braket bill each task.

Export a circuit

from fqkit import QuantumCircuit, Hadamard, CNOT qc = QuantumCircuit(2) qc.add_gate(Hadamard(), [0]) qc.add_gate(CNOT(), [0, 1]) print(qc.to_qasm())
OPENQASM 2.0; include "qelib1.inc"; qreg q[2]; creg c[2]; h q[0]; cx q[0], q[1]; measure q -> c;

Pass measure=False to export the unitary part only (no measurement):

qc.to_qasm(measure=False)

Gate mapping

FQkitOpenQASM
Hadamardh
CNOTcx
CZcz
SWAPswap
Toffoliccx
RX / RY / RZrx / ry / rz

Parameters must be bound to numbers before exporting.

Run it in Qiskit

Install the free, open-source Qiskit (pip install qiskit), then load the exported program:

from qiskit import QuantumCircuit as QiskitCircuit from qiskit.quantum_info import Statevector qiskit_qc = QiskitCircuit.from_qasm_str(qc.to_qasm(measure=False)) print(Statevector.from_instruction(qiskit_qc).probabilities_dict()) # {'00': 0.5, '11': 0.5}

FQkit’s own simulator and Qiskit produce identical statevectors: the round trip is verified in the test suite.

Send it to a machine

Export is the text. A job is the step that uses your IBM or Amazon Braket account, waits in the vendor’s queue, and returns counts. That walkthrough is the Hardware section: accounts, runtime, job submission, and results.

⚠️

IBM and Braket put qubit 0 on the right of a measured bitstring. FQkit puts qubit 0 on the left. job.counts() flips the strings so they match measure_all.

Last updated on