-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
based on discussion in #218 I think no matter how we support expectation in the end we need a shot execution interface which basically means
execute the kernel for N times and return whatever the kernel returns as a list
This leads to the following interface
@kernel
def main(a, b, c) -> return_type:
... # quantum program on device
return <an instsance of return_type>
device = bloqade.Device("gemini-some-identifier")
data = device.run(main, shots=1000) # -> list[return_type]Example: returning raw measurement
when the kernel returns measurement
@kernel
def main():
qubits = qubit.new(3)
# do some gates
return measure(qubits[0]) # returns bool
device = bloqade.Device("gemini-some-identifier")
data = device.run(main, shots=1000) # -> list[bool]the data here being returned is a list of 1000 boolean values.
Example: returning all qubit measurement
@kernel
def main():
qubits = qubit.new(3)
# do some gates
def measure_qubit(i: int) -> bool:
return measure(qubits[i])
return ilist.map(measure_qubit, range(3)) # returns IList[bool, 3]
# if we supports list comprehension
return [measure(qubits[i]) for i in range(3)] # returns IList[bool, 3]
device = bloqade.Device("gemini-some-identifier")
data = device.run(main, shots=1000) # -> list[IList[bool, 3]]the data here being returned will be a list of IList[bool, 3]
Example: returning with postprocessing
@kernel
def main():
qubits = qubit.new(3)
# do some gates
# some postprocessing
if measure(qubits[0]) == 0:
return measure(qubits[1]) + 1
else:
return measure(qubits[2]) - 1
device = bloqade.Device("gemini-some-identifier")
data = device.run(main, shots=1000) # -> list[int]here because the postprocessing data is int we return a list of 1000 integers.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request