classiq
import time from classiq import * SIZE = 6 MAX_WIDTH = 40 constraints = Constraints(optimization_parameter="cx", max_width=MAX_WIDTH)
# define increment circuit as an MCX cascade @qfunc def increment(x: QArray): repeat( x.len - 1, lambda i: control(x[0 : x.len - 1 - i], lambda: X(x[x.len - 1 - i])) ) X(x[0]) @qfunc def single_step_walk( coin: QBit, # coin x: QNum, # position ): H(coin) control(coin == 0, lambda: increment(x), lambda: invert(lambda: increment(x))),
from classiq import CustomHardwareSettings, Preferences preferences = Preferences( custom_hardware_settings=CustomHardwareSettings(basis_gates=["cx", "u"]), transpilation_option="custom", debug_mode=False, )
start_time = time.time() @qfunc def main(x: Output[QNum[SIZE, UNSIGNED, 0]], coin: Output[QBit]): allocate(x) allocate(coin) single_step_walk(coin, x) qprog = synthesize(main, constraints=constraints, preferences=preferences) compilation_time = time.time() - start_time width = qprog.data.width depth = qprog.transpiled_circuit.depth cx_counts = qprog.transpiled_circuit.count_ops["cx"] print(f"==== classiq for {SIZE}==== time {compilation_time}")
==== classiq for 6==== time 16.50112295150757