QASM Circuits with Qiskit AER
- QASM circuits using Qiskit AER are text-based quantum circuit descriptions in OpenQASM that enable hardware-agnostic simulation and secure obfuscation.
- The method employs advanced techniques such as U3 obfuscation, randomized basis changes, and approximate unitary 3-designs to ensure compiler resistance and performance.
- Empirical results show over 93% semantic fidelity and sub-millisecond simulation overhead, underscoring the practical viability of these techniques on commodity hardware.
A QASM circuit is a text-based description of a quantum circuit written in the OpenQASM (Open Quantum Assembly Language) format, commonly used for representing quantum computations in a hardware-agnostic, portable manner. Qiskit AER is a high-performance quantum circuit simulator that allows for the simulation, transformation, obfuscation, and measurement of QASM circuits using advanced techniques in unitary transformation, randomized basis changes, Markov-chain mixing, and group-theoretic constructions. This article surveys the formalism, algorithmic protocols, statistical properties, hardware mappings, and security implications of QASM circuits within the Qiskit AER ecosystem, emphasizing recent research advances.
1. QASM Circuit Formalism and Representation
A QASM circuit encodes a sequence of quantum gates and measurements on an -qubit register, using standardized instructions and optional classical registers. Each primitive gate, such as Hadamard or CNOT, can be represented as a unitary matrix; arbitrary single-qubit unitaries are typically parameterized as U3 gates:
Qiskit parses QASM source code via qiskit.qasm2.loads() or qiskit.qasm3.loads(), generating a QuantumCircuit object that preserves the gate structure, barriers, measurements, and resets (Parayil et al., 22 Dec 2025).
The structural representation of QASM circuits enables downstream transformations such as obfuscation by conjugation, randomized twirling, or re-basing in alternative group-theoretic decompositions.
2. Randomization, Obfuscation, and Compiler-Resistance
Quantum circuit obfuscation aims to conceal logical structure while preserving semantics and performance. Parayil et al. (Parayil et al., 22 Dec 2025) present a method where every gate in the QASM circuit is conjugated by randomly-selected global or per-gate U3 rotations, effecting the transformation: with sampled uniformly from the Haar distribution over SU(2). This process (the obfuscation sandwich, Editor's term) is applied as a QASM-to-QASM compiler pass:
- Input Parsing: QASM loaded, quantum/classical operations preserved.
- Basis Generation: Uniform random triples, with and at circuit boundaries.
- Gate Transformation: For each , compute , wrap into a Qiskit
UnitaryGate, and replace . - Circuit Reconstruction: Prepend and append global U/U†, then transpile for Qiskit AER backends.
This technique guarantees functional equivalence due to the invariance property , so . All original measurement and reset regions are respected; only unitary gates are obfuscated.
Empirically, the method achieves greater than 93% semantic accuracy (e.g., 93.30% for QAOA circuits) and total variation distance below 0.084 over 1024-shot simulations, with runtime overhead under 1 ms on commodity hardware (Parayil et al., 22 Dec 2025). After merging pre/post U3 layers, the net circuit depth increase is .
Resistance to reverse engineering is achieved via two adversary models:
- Black-box: Continuous random basis makes extraction via I/O queries negligible-probability.
- White-box: If all gates are masked, reconstructing unitaries requires inverting for each gate, which is only possible if adversary guesses the randomization pattern. Partial obfuscation with gates exponentially reduces success probability to .
QASM-level compatibility is retained since the obfuscated gates appear as opaque UnitaryGate blocks, thwarting transpiler pattern-matching and optimization.
3. Markov Chain Sampling and Unitary Designs
Unitary -designs are ensembles that replicate the th statistical moments of the Haar measure on . The protocol of Zhu and Gross (Tan et al., 2020) constructs an approximate unitary 3-design on qubits via a staged Markov process targeting the orbits of the m-qubit Pauli group modulo phases:
- Pauli Graph Construction: Vertices are non-identity Paulis; edges denote commutation, classified into type-1 (intra-group), type-2 (inter-group but commutative), and non-edges (anticommuting).
- Sampling Protocol:
- Random Transvections: Apply random symplectic transvections acting as , implemented via Mølmer–Sørensen gates.
- Random Kerdock 2-design element : Uniformly drawn from the Kerdock subgroup (PSL), mixing within edge types.
- Random Pauli : Ensures uniformity at the Pauli 1-moment. The resulting Clifford,
is provably an -approximate unitary 3-design, where (Tan et al., 2020).
Mixing analysis shows the protocol achieves -distance within to Haar measure with rounds, and the ensemble converges to an exact 3-design in the limit .
4. Quantum Simulation of Haar Random Unitaries and Representation-Theoretic Protocols
Simulating Haar-random unitaries, such as random gates, can be performed via Clebsch–Gordan (CG) transforms, realized as a general compressed-oracle construction (Grinko et al., 30 Sep 2025). For sequential queries:
- The system is decomposed via Schur–Weyl duality into irreducible subspaces, with memory registers recording total spin and multiplicity (cost qubits).
- For each query, the CG process couples new qubit(s) using SU(2) CG coefficients, applies random Wigner -matrices in each irrep block according to the Haar measure (which at spin- corresponds to U3), then undoes the coupling.
- Controlled-rotations and lookup tables realize the CG step. Complexity per query is gates and depth; total ancilla requirements are $1$ (data) plus (memory) qubits.
This formalism allows efficient simulation of forward, inverse, transpose, and conjugate queries by specifying the nature of the inserted block during the CG/dCG process. For , closed-form parameterizations via Euler angles suffice; nontrivial CG network depth arises only for multiple queries (Grinko et al., 30 Sep 2025).
5. Implementation in Qiskit AER: Workflow and Performance
The obfuscation, randomization, and design protocols described above are implemented natively within Qiskit AER:
- Input: QASM circuits loaded via
qiskit.qasm2.loads()/qasm3.loads(). - Transformation: Gate matrices extracted via
qiskit.quantum_info.Operator, conjugated by randomly-sampled U3 or higher-level unitaries as per protocol, then re-embedded asUnitaryGateobjects. - Boundary Correction: Global U3 layers inserted at circuit start/end (or at partition points if handling mid-circuit measurements).
- Simulation: The transformed circuits, once fused, are transpiled for
AerSimulator. Output distributions are compared using semantic accuracy and total variation distance. - Hardware Mapping: For unitary 3-design protocols, native implementation leverages Mølmer–Sørensen XX-type entangling gates on trapped-ion hardware, with gate depth scaling as (Tan et al., 2020).
Table: Complexity and Overhead Summary
| Protocol/Technique | Overhead (Gate Depth) | Native Gate Mapping |
|---|---|---|
| U3 Obfuscation (Parayil et al., 22 Dec 2025) | (per circuit, after fusion) | U3, arbitrary single-qubit |
| 3-Design Markov (Tan et al., 2020) | Two-qubit Mølmer–Sørensen | |
| CG-based Haar (Grinko et al., 30 Sep 2025) | per query | Controlled single-qubit, CG |
For canonical circuits, the measured semantic fidelity is and obfuscated circuits remain efficiently simulable (<1 ms additional time per 1024 shots for QAOA) (Parayil et al., 22 Dec 2025).
6. Statistical Properties and Random Matrix Connections
Randomization protocols invoked in QASM/AER workflows often reduce to classical results on the distributions of unitary and orthogonal transformations. For example, repeated Haar-random orthogonal transformations acting on the "north pole" yields nontrivial statistics for : where are independent first-coordinates of Haar vectors on (Eaton et al., 2008). The variance decays as $1/p$ and for large , becomes approximately Gaussian.
Such detailed statistical characterizations are essential in benchmarking pseudo-randomness, spectral concentration, and deviation from ideal Haar-random sampling in QASM circuit simulation and design protocols.
7. Security, Applications, and Limitations
Compiler-resistant obfuscation via U3 conjugation (Parayil et al., 22 Dec 2025) provides robust defense against both black-box and white-box circuit analysis, reducing the probability of reverse engineering to negligible (continuous basis) or exponentially small (combinatorial, when only a subset of gates is obfuscated). Unlike previous structure-preserving masking, randomized basis transforms render classical transpiler pattern-matching and circuit identification ineffective.
Approximate unitary 3-designs (Tan et al., 2020) facilitate randomized benchmarking, emulation of Haar-random unitaries, and secure cryptographic sampling, with strong hardware mapping to native gates on trapped-ion platforms. CG-based Haar constructions (Grinko et al., 30 Sep 2025) provide efficient algorithms for realizing multiple independent Haar-sampled unitaries, critical for oracle constructions, randomized benchmarking, and design theory.
A plausible implication is that as circuits grow and obfuscation is performed gatewise, transparency for debugging and classical post-processing may be hampered; similarly, highly randomized designs can marginally increase simulation and transpilation cost, although empirical evidence shows these overheads remain pre-asymptotic for practically sized circuits. For multi-partite operations and mid-circuit measurements, circuit partitioning may be necessary to preserve correctness of transformations.
Overall, the integration of unitary design, group-theoretic randomization, and compiler-level obfuscation within the Qiskit AER and QASM circuit paradigm underpins modern approaches to robust, secure, and hardware-aware quantum circuit simulation and deployment.