Execution

class Configuration.Execution

Options that orchestrate the run() method.

property nthreads

Set the maximum number of threads to use. Defaults to the maximum number of available threads reported by the OS.

property numerical_tolerance

Set the numerical tolerance of the underlying decision diagram package. Defaults to ~2e-13 and should only be changed by users who know what they are doing.

property parallel

Set whether execution should happen in parallel. Defaults to True.

property run_alternating_checker

Set whether the alternating checker should be executed. Defaults to True since staying close to the identity can quickly show the equivalence of circuits in many cases.

property run_construction_checker

Set whether the construction checker should be executed. Defaults to False since the alternating checker is to be preferred in most cases.

property run_simulation_checker

Set whether the simulation checker should be executed. Defaults to True since simulations can quickly show the non-equivalence of circuits in many cases.

property run_zx_checker

Set whether the ZX-calculus checker should be executed. Defaults to True but arbitrary multi-controlled operations are only partially supported.

property timeout

Set a timeout for run() (in seconds). Defaults to 0., which means no timeout.

Timeout Handling

Timeouts in QCEC work by checking an atomic flag in between the application of gates (for DD-based checkers) or rewrite rules (for the ZX-based checkers). Unfortunately, this means that an operation needs to be fully applied before a timeout can set in. If a certain operation during the equivalence check takes a very long time (e.g., because the DD is becoming very large), the timeout will not be triggered until that operation is finished. Thus, it is possible that the timeout is not triggered at the expected time, and it might seem like the timeout is being ignored.

Unfortunately, there is no clean way to kill a thread without letting it finish its computation. That’s something that could be made possible by switching from multi-threading to multi-processing, but the overhead of processes versus threads is huge on certain platforms and that would not be a good trade-off. In addition, more fine-grained abortion checks would significantly decrease the overall performance due to all the branching that would be necessary.

Consequently, timeouts in QCEC are a best-effort feature, and they should not be relied upon to always work as expected. From experience, they tend to work reliably well for the ZX-based checkers, but they are less reliable for the DD-based checkers.