Documentation Index
Fetch the complete documentation index at: https://prod-mint.classiq.io/llms.txt
Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
This notebook shows how to generate data for discrete quantum walk using 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,
)
Example for getting a data point
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}")
Output:==== classiq for 6==== time 16.50112295150757