Testing Optimistic Quantum Fourier Transform Circuits With OQFT and Qiskit
A quantum circuit can get much shallower while keeping almost the same number of controlled-NOT gates. That’s what happened when SoftDevStudio’s OQFT toolkit exported a 256-qubit optimistic quantum Fourier transform to Qiskit. After compilation to the same gate basis, the optimistic circuit had a depth of 624 and the textbook circuit had a depth of 2,044. Their controlled-NOT counts were much closer, at 19,184 and 19,224. If you’re building a circuit viewer or benchmark, it pays to show both numbers. A gate count tells you how much work the circuit contains. Depth tells you how much of it has to happen in sequence.
The quantum Fourier transform changes how information is represented in a quantum state. In Shor’s algorithm it helps extract a period, a repeating pattern that can lead to a factor. The optimistic construction trades uniform accuracy for lower depth and uses the original register without adding auxiliary qubits. The qualifier matters when you test it. Two circuits can produce similar outputs across most inputs and still diverge sharply on a few. That makes circuit generation, numerical checking and compilation three distinct operations, even if an app runs them from a single screen.
The OQFT command-line tool is written in Go and exports textbook, approximate and optimistic circuits as OpenQASM 3. The project’s Python example starts the OQFT executable as a subprocess, captures its standard output and passes it to Qiskit’s QASM 3 loader. It begins with a six-qubit textbook circuit, small enough to compare its complete matrix with Qiskit’s own textbook QFT, with the final swaps enabled. The matrices agree in the recorded run. It’s a small test, and that’s the point. A qubit-ordering mistake or a difference in swap conventions can make the output look wrong before you’ve even tried the optimistic construction. Keeping this case around gives you a quick check on the export and import path when either tool changes.
For accuracy testing, OQFT compares simulated output amplitudes with the textbook transform for selected computational basis inputs. The checker can test all those inputs through 10 qubits and accepts specific inputs or a seeded sample through 20 qubits. The error target controls how the optimistic circuit is built. A separate reporting threshold controls which rows in the output are flagged. If you’re turning a CSV report into a regression test, inspect those rows explicitly. The command can finish successfully while reporting inputs over the threshold because its job is to produce the report. The application consuming it gets to decide what constitutes a failure.
Targeted inputs can also tell you something a sample average misses. In a recorded 12-qubit diagnostic, the project varied one block across eight possible values while holding a neighboring block fixed. The last case had a squared error close to 2. The other seven stayed below the diagnostic threshold of 0.5. A test suite could keep that edge case as a fixture and add a seeded sample to cover other inputs. The fixture checks that the failure still shows up where you expect it. The sample gives you a repeatable view of a wider set of states, and its mean describes the inputs actually sampled.
The 256-qubit Qiskit example asks a different question. It imports and compiles the circuit, then compares gate counts and depth. The recorded run used Qiskit 2.6.2 at optimization level 1 with a gate basis of CX, RZ, SX and X. The script supplied no device coupling map. If you later target a particular machine, the compiler may need extra operations to move quantum information between qubits that can interact. That can change both the gate count and the depth. Keep the tool versions and compilation settings with the numbers so you can tell which conditions produced a result when you revisit it.
There’s a practical way to expose this in an app. Keep the OpenQASM export with the run settings, then label the simulator results and compiler statistics separately. A student using a circuit explorer can find the input behind a large error. A developer looking at a benchmark can find the compiler settings behind the depth figure. Each can reproduce the part they care about without having to reverse-engineer a screenshot or guess which defaults were used. The quick start, downloads and worked comparisons are at oqft.com.