QSeqSim: A Symbolic Simulator for Qiskit While Loops Using Sequential Quantum Circuits

This paper introduces QSeqSim, a Qiskit-integrated symbolic simulator that enables the efficient simulation of quantum programs with while-loops by translating them into sequential circuits and utilizing BDD-based weighted model counting to compute measurement probabilities for large-scale, multi-iteration benchmarks.

Original authors: Zihao Li, Ji Guan, Mingsheng Ying

Published 2026-05-15
📖 5 min read🧠 Deep dive

Original authors: Zihao Li, Ji Guan, Mingsheng Ying

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a very sophisticated recipe for a quantum dish (a quantum program). Most modern recipe books, like Qiskit, allow you to write instructions that say, "Keep cooking this step over and over again until the sauce turns a specific color." This is called a while loop.

However, until now, the kitchen appliances (simulators) that actually cook these recipes couldn't understand that instruction. If you tried to run a recipe with a "keep cooking until..." instruction, the appliance would just crash or say, "I don't know how to do this."

QSeqSim is a new, smart kitchen assistant designed specifically to handle these "keep cooking until" instructions. Here is how it works, using simple analogies:

1. The Problem: The "Loop" Gap

Think of a standard quantum circuit as a straight line of dominoes falling one after another. You push the first one, and they all fall in a fixed order. This is easy to simulate.

But a while loop is like a sliding door in a hallway. You walk through the door, do a task, check a sensor, and if the sensor says "not done yet," you slide back through the door to do it again. The state of the room (the quantum state) changes every time you go through, and the door might close at any moment.

Current tools (like Qiskit-Aer) can only handle the straight line of dominoes. They don't know how to handle the sliding door that loops back on itself. QSeqSim is the first tool built to understand and simulate this "sliding door" behavior natively.

2. The Solution: Turning Loops into a "Memory Machine"

To make sense of these loops, QSeqSim translates the quantum program into a special kind of machine called a Sequential Quantum Circuit.

  • The Analogy: Imagine a factory assembly line.
    • External Qubits: These are like raw materials brought in fresh for every single pass through the loop. They are measured (checked) and then thrown away.
    • Internal Qubits: These are like the work-in-progress on the conveyor belt. They stay in the machine, get updated, and are carried over to the next loop iteration.
    • The Loop: The machine checks a gauge (a measurement). If the gauge says "keep going," the conveyor belt loops back, carrying the updated work-in-progress to the start of the next cycle.

QSeqSim treats the loop not as a magical repeat button, but as a physical machine with a feedback wire that carries the "memory" of the previous step into the next one.

3. The Engine: The "Smart Filing System" (BDDs)

Simulating quantum computers is hard because the number of possibilities grows explosively (like trying to track every possible path a traveler could take in a giant maze).

QSeqSim uses a technique called Binary Decision Diagrams (BDDs).

  • The Analogy: Imagine you have a massive library of every possible outcome of your quantum loop. A normal computer tries to read every single book in the library one by one.
  • QSeqSim's Trick: Instead of reading every book, QSeqSim uses a smart filing system. It notices that many paths in the maze are identical. It groups them together into a single folder.
    • If 1,000 paths all lead to the same result, QSeqSim doesn't calculate them 1,000 times; it calculates them once and says, "This folder represents all 1,000 paths."
    • This allows it to handle loops with over 1,000 qubits and more than 10 iterations without getting overwhelmed, something previous tools couldn't do.

4. What It Can Do (The Results)

The authors tested QSeqSim on three types of "recipes" (benchmarks) to see how well it handles the "sliding door" loops:

  • Repeat-Until-Success (RUS): A recipe that says, "Keep trying this trick until it works." QSeqSim simulated this perfectly, even when the loop had to run 100 times.
  • Quantum Random Walks: Imagine a drunk person walking on a grid, flipping a coin at every step to decide which way to go, and checking if they hit a wall. QSeqSim simulated a walk with over 1,000 steps (qubits) and 10+ loops.
  • Grover's Search: A famous search algorithm that uses loops to find a needle in a haystack. QSeqSim could simulate this with hundreds of qubits.

5. Why This Matters (For Now)

The paper claims that QSeqSim fills a specific gap: it is the first tool that can actually run Qiskit programs containing while loops.

Before this, if a programmer wrote a loop, they had to manually unroll it (write out every single step) or couldn't run it at all. Now, they can write the loop naturally, and QSeqSim translates it into a "memory machine," uses its smart filing system to calculate the odds of different outcomes, and tells you exactly what happens.

In short: QSeqSim is a translator and a calculator that finally lets quantum computers understand and execute instructions that say, "Do this again and again until the result is right."

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →