Open
Description
A utility function that encapsulates some kernel that operates on qubits.
For example, if you have some kernel with a signature
def kernel(*qubits:Qubit, **kwargs) -> None
aka acting on some list of qubits as a unitary or other operation, make a utility function that "wraps" that for ease of simulation so that one does not need to write the following code snippet every time
def main():
qbts = bloqade.squin.qubit.new( ## )
kernel( *qbts, **kwargs )
bits = bloqade.squin.measure(*qbts)
return bits
main2 = bloqade.circuit.utils.wrap(kernel,**kwargs)
# main == main2
where ##, the number of qubits, is computed by evaluating the required number of input qubits in kernel
or is set as a variable in the wrapper (nqubits = ###
).