User hint for maximum number of qubits allocated
Suggested syntax
from guppylang.hints import max_qubits
N_QB = 4
@max_qubits(N_QB)
@guppy
def foo() -> None:
a = array(qubit() for _ in range(py(N_QB))
discard_array(a)
Compilation
Attach as standard metadata key to entrypoint op. Key should be specified in tket2.
Usage
n_qubits parameter to emulator can now be optional:
foo.emulator().run() # will raise error if `foo` is not annotated
What would happen if the user is wrong in hinting how many qubits they need? Would Selene crash? Or would this hint just apply to cases where its easy to figure out?
yes crash, same as now though with the n_qubits parameter. This is basically about attaching that same information to the program, so that it can also be used for other purposes (e.g. ancilla budget tracking in synthesis)
Instead of a new decorator, we could also consider a kwarg for the @guppy decorator similar to how we did @guppy(unitary=True)?