Inspiration

Anyone who has simulated quantum circuits knows the feeling: you press run and have no idea whether you'll wait one second or four hours. A circuit file describes the work, but not how long that work will take. We wanted to answer that question before running a single gate, so researchers can plan compute budgets, compare circuit variants, and avoid runs that were never going to finish.

What it does

Given an OpenQASM circuit and a Quantum Rings simulator threshold (16, 64 or 512), our model predicts the wall-clock simulation time in seconds, from the circuit file alone.

Predictions are scored with the challenge metric, which only cares how many times off you are:

$$\text{score} = \max\left(0,\ 1 - \frac{\left|\log_{10}(\text{predicted}/\text{actual})\right|}{2}\right)$$

An exact prediction scores 100%, 10× off scores 50%, and 100× off scores 0.

Results (5-fold cross-validation, grouped so no circuit is predicted by a model that saw it, scored with the organizers' score.py):

Approach Features Accuracy
Guess the median runtime per threshold 0 57.4%
Our model + organizers' starter parser 4 82.4%
Our model + all 6 SupermarQ features 7 86.3%
Our final model 7 90.5%

78% of runs are predicted within 2× of the true runtime, and 96.5% within 10×.

How we built it

1. A parser. We wrote a single-pass OpenQASM 2/3 parser that expands custom gates into primitives and tracks, for every gate, the qubits it touches, circuit depth, qubit interactions, and whether the gate actually creates entanglement (gates acting only on 0/1 basis states don't).

2. Features grounded in how the simulator works. Our working hypothesis is that the threshold caps the bond dimension $$\chi$$ of a matrix-product-state simulator, where each two-qubit gate costs roughly $$\chi^3$$. That gives our key feature, the entanglement cost:

$$\text{cost} = \log_{10}\left(N_{\text{ent}} \cdot \chi_{\text{eff}}^{3}\right), \qquad \chi_{\text{eff}} = \min(\text{threshold},\ \chi_{\text{needed}})$$

where $$N_{\text{ent}}$$ is the number of entangling gates and $$\chi_{\text{needed}}$$ is estimated from how many gates cross each cut between qubits.

3. The model. Gradient-boosted trees (scikit-learn HistGradientBoostingRegressor, 600 trees) predict $$\log_{10}(\text{seconds})$$ with an absolute-error loss, which matches the competition metric exactly. One hand-written rule covers circuits with 30 or more mid-circuit resets: 6 of the 7 such circuits hit the 4-hour cap, so we predict the cap.

4. Cutting features. We started with 42 features and removed them by backward elimination: 42 → 17 → 10 → 7, with accuracy staying at about 91% throughout, while training time fell from 6.1 s to 3.4 s. The final 7 are four SupermarQ benchmark features (entanglement ratio, measurement, program communication, critical depth), the threshold, circuit size (log of one-qubit gates), and our entanglement cost.

Challenges we ran into

  • The 15-second parsing limit. Our slowest circuit took 133 s to parse, and it was one of the smallest files: 3.5 KB compressed. It defines a 25-qubit mcphase gate and calls it repeatedly, which expands to about 65 million operations. Our time check only ran between lines, and a single line could take minutes. We moved the check inside gate expansion (every 20,000 operations), added a 9-second cap, and scaled partial counts by operations rather than characters. The capped 9.1 s parse gave exactly the same features as the full 148 s parse. Every circuit now parses in 0.46 s on average and 9.5 s at most.
  • Huge files. Some circuits are over 150 MB. Scanning the whole file for declarations took about 13 s before the first gate; scanning only the header brought that under a second.
  • Silent parser bugs. QASM 3 if (...) { } blocks were skipped, so one 256-qubit circuit looked like a 1-qubit circuit. reset statements were ignored, so reset-heavy circuits scored 7% while the rest scored 91%. Both were found by studying our worst predictions.
  • Messy labels. 146 of 532 circuits run at least 2× faster at a higher threshold, some runs finish in 0.16 s (essentially startup time) while the same circuit takes seconds at other thresholds, and 33 runs time out. We kept timeouts in training at the 14,400 s cap: dropping them cut accuracy on those runs from 75% to 49%.

What we learned

  • File size says little about cost. What matters is the number of gates after expanding custom gates, and how much entanglement they create.
  • Ratios aren't enough. SupermarQ features describe a circuit's shape (0 to 1), not its size: a 1,000-gate and a 1,000,000-gate circuit can look identical. Adding size and entanglement cost lifted accuracy from 86.3% to 90.5% with the same number of features.
  • Physics makes better features. The $$\chi^3$$ cost term turned out to be the most valuable feature group: removing the entanglement features cost 4.3 points.
  • Measure honestly. Grouped cross-validation, the official scorer, and no feature caching (a stale cache once gave us fake parse times) kept our numbers trustworthy.

What's next

  • Better entanglement estimates for circuits whose runtime explodes at threshold 512.
  • Features for circuits with millions of mostly diagonal gates, currently our largest misses.
  • Flagging suspicious labels, such as 0.16 s runs, instead of training on them.
  • Confirming the threshold-as-bond-dimension hypothesis with Quantum Rings.

Built with

Python, scikit-learn, NumPy, pandas, OpenQASM 2/3, SupermarQ (Tomesh et al., HPCA 2022, arXiv:2202.11045).

Built With

Share this project:

Updates

Submission history