Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
This notebook shows how to generate data for discrete quantum walk using pennylane 0.39.0 and pennylane-catalyst 0.9.0
# import time
# import pennylane as qml
# from catalyst import qjit

# import time
# import pennylane as qml
# from catalyst import qjit

# # run an example
# SIZE = 6
# start_time = time.time()

# s = SIZE
# wires_x = list(range(s))
# coin = [s]

# def shift_op():
#     for index in range(len(wires_x)-1, 0, -1):
#         control_values = [1] * index
#         qml.ctrl(qml.PauliX, control=wires_x[:index], control_values=control_values)(wires=wires_x[index])
#         qml.PauliX(wires_x[0])


# @qml.qnode(qml.device("lightning.qubit", wires=(wires_x + coin)))
# def circuit():
#     qml.H(coin)
#     qml.ctrl(shift_op, control=coin)()
#     qml.ctrl(qml.adjoint(shift_op), control=coin, control_values=[0])()
#     return qml.probs(wires=wires_x)

# cir = qml.transforms.decompose(circuit, gate_set={qml.CNOT, qml.RZ, qml.RY, qml.RX})
# jitted_cir = qjit(cir)
# transpilation_time = time.time()-start_time
# cx_counts = jitted_cir.mlir.count("CNOT")

# print(f"==== pennylane for {SIZE}==== time: {transpilation_time}")