Benchmark Clifford+T synthesis

Compare synthesis runtime and T counts with fo-synth-benchmarks

This tutorial uses fo-synth-benchmarks to compare Fire Opal's Clifford+T synthesis with gridsynth-based alternatives. You will benchmark individual single-qubit unitaries with fo-synth-core, then benchmark compilation through the fo-synth-qiskit and fo-synth-cudaq integrations. You will inspect the generated summaries and plots, and regenerate reports from without repeating synthesis.

Setup

Use a Python 3.12 Jupyter kernel and install the package from PyPI:

%pip install fo-synth-benchmarks

Restart the kernel after installation if needed. Note that the core synthesizer and Qiskit integration support Linux and macOS; CUDA-Q is only supported on Linux.

Benchmark integrationLinuxmacOS
fo-synth-coreSupportedSupported
fo-synth-qiskitSupportedSupported
fo-synth-cudaqSupportedNot supported
import sys
from collections import Counter
from pathlib import Path

from IPython.display import Image, display

from fo_synth_benchmarks import bench_core, bench_qiskit

epsilons = [1e-5]
results_dir = Path("benchmark-results")

Benchmark individual unitaries

The core suite compares Fire Opal su2, rsgridsynth, and pygridsynth. The latter two synthesize Rz rotations directly and decompose generic SU(2) targets into rotations. The default targets for the benchmark suite are fixed, making the target selection reproducible.

Run all three methods on the 50 targets at the single tolerance:

core_output = results_dir / "tutorial-core"
core_run = bench_core(
    epsilons=epsilons,
    methods=["rsgridsynth", "su2", "pygridsynth"],
    output_dir=core_output,
)
# fo-synth-bench-core

Methods: rsgridsynth, su2, pygridsynth. Baseline: rsgridsynth.

T-counts and synthesis time are summed over one measurement per target.
Incomplete groups and undefined ratios are N/A.

## rz

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 719 | 0.00% | 0.0970277 | 1x |
| 1e-05 | su2 | 676 | 5.98% | 0.0237325 | 4.09x |
| 1e-05 | pygridsynth | 738 | -2.64% | 0.521254 | 0.186x |

## haar

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 2546 | 0.00% | 0.256468 | 1x |
| 1e-05 | su2 | 660 | 74.08% | 0.0753367 | 3.4x |
| 1e-05 | pygridsynth | 2600 | -2.12% | 1.87343 | 0.137x |

## c3

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 857 | 0.00% | 0.0809068 | 1x |
| 1e-05 | su2 | 234 | 72.70% | 0.00534246 | 15.1x |
| 1e-05 | pygridsynth | 866 | -1.05% | 0.626151 | 0.129x |

## c2

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 285 | 0.00% | 0.0479396 | 1x |
| 1e-05 | su2 | 242 | 15.09% | 0.0070645 | 6.79x |
| 1e-05 | pygridsynth | 1042 | -265.61% | 0.6922 | 0.0693x |

## near_axis

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 850 | 0.00% | 0.0762524 | 1x |
| 1e-05 | su2 | 223 | 73.76% | 0.0146951 | 5.19x |
| 1e-05 | pygridsynth | 860 | -1.18% | 0.55772 | 0.137x |

## word

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 846 | 0.00% | 0.0863089 | 1x |
| 1e-05 | su2 | 161 | 80.97% | 0.0090175 | 9.57x |
| 1e-05 | pygridsynth | 868 | -2.60% | 0.621657 | 0.139x |
Completed fo-synth-bench-core live run. Output directory: /evidence/benchmark-results/tutorial-core

The function prints a summary and writes the full records and reports to core_output. Inspect the returned points before interpreting comparisons:

print(f"Core attempts: {len(core_run.points)}")
print("Statuses:", dict(Counter(point.status for point in core_run.points)))
print("Requested tolerances:", sorted({point.epsilon for point in core_run.points}))
Core attempts: 150
Statuses: {'ok': 150}
Requested tolerances: [1e-05]

Timeouts and failed points remain in the saved records but are excluded from plots. Timeouts alone do not fail a run; synthesis or verification errors are saved and then raised. An incomplete target-family total or missing baseline is reported as N/A.

The plot compares T count with measured runtime for successful points. The benchmark clears Fire Opal's synthesis cache before each call, to avoid conflating synthesizer performance with cache hits.

display(Image(filename=str(core_output / "t-vs-time-1e-05.png")))

png-1

Benchmark the Qiskit integration

The Qiskit suite compiles the corresponding single-qubit source circuits through fo-synth-qiskit. It compares Fire Opal (su2) with the gridsynth route (rsgridsynth).

qiskit_output = results_dir / "tutorial-qiskit"
qiskit_run = bench_qiskit(
    epsilons=epsilons, methods=["su2", "rsgridsynth"], output_dir=qiskit_output
)
# fo-synth-bench-qiskit

Methods: su2, rsgridsynth. Baseline: rsgridsynth.

Counts and compile time are summed over one measurement per circuit.
Incomplete groups and undefined ratios are N/A.

## haar

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | su2 | 660 | 74.08% | 0 | N/A | 1745 | 73.57% | 0.0930642 | 3.33x |
| 1e-05 | rsgridsynth | 2546 | 0.00% | 0 | N/A | 6602 | 0.00% | 0.309638 | 1x |

## rz

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | su2 | 676 | 5.98% | 0 | N/A | 1740 | 5.54% | 0.0801407 | 0.959x |
| 1e-05 | rsgridsynth | 719 | 0.00% | 0 | N/A | 1842 | 0.00% | 0.0768425 | 1x |

## c2

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | su2 | 242 | 15.09% | 0 | N/A | 611 | 19.07% | 0.0247112 | 2.54x |
| 1e-05 | rsgridsynth | 285 | 0.00% | 0 | N/A | 755 | 0.00% | 0.0628713 | 1x |

## c3

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | su2 | 234 | 72.70% | 0 | N/A | 598 | 73.20% | 0.0216631 | 4.46x |
| 1e-05 | rsgridsynth | 857 | 0.00% | 0 | N/A | 2231 | 0.00% | 0.0966022 | 1x |

## word

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | su2 | 161 | 80.97% | 0 | N/A | 421 | 80.85% | 0.0198845 | 5.1x |
| 1e-05 | rsgridsynth | 846 | 0.00% | 0 | N/A | 2198 | 0.00% | 0.101441 | 1x |

## near_axis

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | su2 | 223 | 73.76% | 0 | N/A | 555 | 74.27% | 0.027132 | 4.07x |
| 1e-05 | rsgridsynth | 850 | 0.00% | 0 | N/A | 2157 | 0.00% | 0.110534 | 1x |
Completed fo-synth-bench-qiskit live run. Output directory: /evidence/benchmark-results/tutorial-qiskit
print(f"Qiskit attempts: {len(qiskit_run.points)}")
print("Statuses:", dict(Counter(point.status for point in qiskit_run.points)))
display(Image(filename=str(qiskit_output / "t-vs-time-1e-05.png")))
Qiskit attempts: 100
Statuses: {'ok': 100}



png-2

Benchmark the CUDA-Q integration on Linux

The CUDA-Q suite compares the Fire Opal pass plugin (plugin) with CUDA-Q's stock gridsynth route (stock). Worker startup can make the wall-clock duration noticeably longer than the measured compilation times.

Note that CUDA-Q benchmarks require Linux, as the CUDA-Q Logical library on which the integration depends is only published on that platform.

cudaq_output = results_dir / "tutorial-cudaq"
if sys.platform == "linux":
    from fo_synth_benchmarks import bench_cudaq

    cudaq_run = bench_cudaq(
        epsilons=epsilons, methods=["plugin", "stock"], output_dir=cudaq_output
    )
else:
    print("Skipping CUDA-Q benchmarks: Linux is required; macOS is not supported.")
/workspace/.venv/lib/python3.12/site-packages/cudaq/__init__.py:260: UserWarning: cudaq-logical is in preview. Its APIs, behavior, and documentation may change substantially in upcoming versions.
  from . import logical  # noqa: F401


/workspace/packages/fo-synth-benchmarks/src/fo_synth_benchmarks/_cudaq.py:9: FutureWarning: The CUDA-Q `sample` and `observe` algorithmic primitives will change in a future release. Existing code may require updates. See https://nvidia.github.io/cuda-quantum/latest/using/migration/upcoming_changes.html for details.
  import cudaq


# fo-synth-bench-cudaq

Methods: plugin, stock. Baseline: stock.

Counts and compile time are summed over one measurement per circuit.
Incomplete groups and undefined ratios are N/A.

## haar

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | plugin | 660 | 70.59% | 0 | N/A | 1673 | 70.88% | 5.96209 | 0.971x |
| 1e-05 | stock | 2244 | 0.00% | 0 | N/A | 5745 | 0.00% | 5.79178 | 1x |

## rz

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | plugin | 676 | 2.31% | 0 | N/A | 1746 | 1.63% | 5.34388 | 0.932x |
| 1e-05 | stock | 692 | 0.00% | 0 | N/A | 1775 | 0.00% | 4.98205 | 1x |

## c2

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | plugin | 242 | 6.20% | 0 | N/A | 600 | 7.83% | 1.883 | 0.934x |
| 1e-05 | stock | 258 | 0.00% | 0 | N/A | 651 | 0.00% | 1.75949 | 1x |

## c3

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | plugin | 234 | 67.50% | 0 | N/A | 594 | 67.61% | 1.93498 | 1.01x |
| 1e-05 | stock | 720 | 0.00% | 0 | N/A | 1834 | 0.00% | 1.95551 | 1x |

## word

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | plugin | 161 | 78.01% | 0 | N/A | 418 | 77.36% | 1.73222 | 1.1x |
| 1e-05 | stock | 732 | 0.00% | 0 | N/A | 1846 | 0.00% | 1.90463 | 1x |

## near_axis

| Epsilon | Method | T | T reduction | CX | CX reduction | Gates | Gate reduction | Compile seconds | Speedup |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1e-05 | plugin | 223 | 69.37% | 0 | N/A | 550 | 70.54% | 1.86339 | 0.987x |
| 1e-05 | stock | 728 | 0.00% | 0 | N/A | 1867 | 0.00% | 1.83883 | 1x |
Completed fo-synth-bench-cudaq live run. Output directory: /evidence/benchmark-results/tutorial-cudaq


200 repeated copies of the two SDK warnings above were omitted from this saved output.
if sys.platform == "linux":
    print(f"CUDA-Q attempts: {len(cudaq_run.points)}")
    print("Statuses:", dict(Counter(point.status for point in cudaq_run.points)))
    display(Image(filename=str(cudaq_output / "t-vs-time-1e-05.png")))
CUDA-Q attempts: 100
Statuses: {'ok': 100}



png-3

Reuse the saved results

Each run writes the following files in its output directory:

FileContents
results.jsonPer-point records, including statuses and measured values
provenance.jsonExecution provenance for interpreting and reproducing the run
summary.mdMethod and target-family comparisons
t-vs-time-1e-05.pngT count versus runtime at the requested tolerance
t_count-vs-precision.pngT count versus achieved error
elapsed_seconds-vs-precision.pngRuntime versus achieved error

Regenerate the core figures and summary from the saved records without running synthesis again:

replot_output = results_dir / "tutorial-core-replot"
reloaded_run = bench_core(replot=core_output / "results.json", output_dir=replot_output)
print(f"Loaded {len(reloaded_run.points)} recorded attempts without synthesis.")
# fo-synth-bench-core

Methods: rsgridsynth, su2, pygridsynth. Baseline: rsgridsynth.

T-counts and synthesis time are summed over one measurement per target.
Incomplete groups and undefined ratios are N/A.

## rz

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 719 | 0.00% | 0.0970277 | 1x |
| 1e-05 | su2 | 676 | 5.98% | 0.0237325 | 4.09x |
| 1e-05 | pygridsynth | 738 | -2.64% | 0.521254 | 0.186x |

## haar

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 2546 | 0.00% | 0.256468 | 1x |
| 1e-05 | su2 | 660 | 74.08% | 0.0753367 | 3.4x |
| 1e-05 | pygridsynth | 2600 | -2.12% | 1.87343 | 0.137x |

## c3

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 857 | 0.00% | 0.0809068 | 1x |
| 1e-05 | su2 | 234 | 72.70% | 0.00534246 | 15.1x |
| 1e-05 | pygridsynth | 866 | -1.05% | 0.626151 | 0.129x |

## c2

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 285 | 0.00% | 0.0479396 | 1x |
| 1e-05 | su2 | 242 | 15.09% | 0.0070645 | 6.79x |
| 1e-05 | pygridsynth | 1042 | -265.61% | 0.6922 | 0.0693x |

## near_axis

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 850 | 0.00% | 0.0762524 | 1x |
| 1e-05 | su2 | 223 | 73.76% | 0.0146951 | 5.19x |
| 1e-05 | pygridsynth | 860 | -1.18% | 0.55772 | 0.137x |

## word

| Epsilon | Method | T | T reduction | Synthesis seconds | Speedup |
| --- | --- | --- | --- | --- | --- |
| 1e-05 | rsgridsynth | 846 | 0.00% | 0.0863089 | 1x |
| 1e-05 | su2 | 161 | 80.97% | 0.0090175 | 9.57x |
| 1e-05 | pygridsynth | 868 | -2.60% | 0.621657 | 0.139x |
Completed fo-synth-bench-core replot. Output directory: /evidence/benchmark-results/tutorial-core-replot
Loaded 150 recorded attempts without synthesis.

Replotting writes PNGs and summary.md, but does not copy or create results.json or provenance.json in the new directory. It uses the original recorded selections: epsilons, methods, and core seeds do not filter saved data when replotting. Use saved records with the same benchmark function that created them.

Customize your benchmarks

The following options let you customize your own runs. All three functions accept keyword-only arguments and return a run containing per-point records.

Python optionAvailable functionsBehavior
epsilonsAll threeUnique finite tolerances in (0, 1]; defaults to 1e-3, 1e-4, 1e-5, 1e-6, and 1e-7. This tutorial deliberately overrides that default with [1e-5]. Note tolerances of 1e-8 or smaller will emit a warning. Such tolerances may significantly extend synthesis time and/or fail to find a solution. Also, only devices with a QEC error per cycle ~1e-20 could take advantage of such accurate synthesis, whereas current long-term projections for achievable error per cycle are larger.
methodsAll threeA nonempty unique subset of the suite's method names shown above; None selects all. Omitting its baseline produces N/A comparisons.
seedsbench_core onlyReplaces the default 15 Haar seeds with unique nonnegative Python integers; the other 35 targets remain. An empty sequence omits Haar targets. Qiskit and CUDA-Q always use their fixed 50 sources.
output_dirAll threeA pathlib.Path. Defaults to None, creating a timestamped command directory under ./benchmark-results; for replotting, it writes beside the input records.
replotAll threeFalse runs benchmarks, a Path loads explicit records, and True selects the matching command's latest timestamped run. Custom-named directories such as those in this tutorial require an explicit results path. Replotting for CUDA-Q still requires Linux.

Use the command-line tools

The package exposes equivalent CLI entrypoints with the same arguments, platform restrictions, and default selections as the Python functions.

fo-synth-bench-core --epsilons 1e-5 --methods rsgridsynth su2 pygridsynth --output-dir benchmark-results/tutorial-core
fo-synth-bench-qiskit --epsilons 1e-5 --methods su2 rsgridsynth --output-dir benchmark-results/tutorial-qiskit
fo-synth-bench-cudaq --epsilons 1e-5 --methods plugin stock --output-dir benchmark-results/tutorial-cudaq

Use --epsilons, --methods, and core-only --seeds with whitespace-separated values, not comma-separated lists. Unlike Python's seeds=[], CLI --seeds requires at least one integer. Qiskit and CUDA-Q do not accept --seeds. Use --output-dir to choose where reports are written.

Saved-data replotting is also available from the CLI:

fo-synth-bench-core --replot benchmark-results/tutorial-core/results.json --output-dir benchmark-results/core-replot

Bare --replot selects the latest matching timestamped default-directory run. As with Python, live-selection flags do not filter saved data during replotting. Inspect all supported flags without running benchmarks:

fo-synth-bench-core --help
fo-synth-bench-qiskit --help
fo-synth-bench-cudaq --help

You have now compared individual-unitary synthesis and SDK compilation, inspected statuses and performance reports, and regenerated reports from saved records.

Was this useful?

cta background

New to Fire Opal?

Get access to everything you need to automate and optimize quantum hardware performance at scale.