microsoft / qsharp-language

Official repository for design of the quantum programming language Q# and its core libraries
MIT License
233 stars 54 forks source link

Allow operations to declare a budget #64

Closed Strilanc closed 3 years ago

Strilanc commented 3 years ago

One of the values I often find myself adding to the documentation of an operation is how many resources it can consume (e.g. workspace qubits, T gates). It would be nice if there was a formal way to do this, and that the claimed budget was actually verified when executing.

For example:

operation op(qs: Qubit[]) : Unit {
    budget {
        set_max_workspace(Length(qs) * 2);
        set_max_operation(CCNOT, 20);
    }
    ...
}

That being said...

Please add ticks by placing a cross in the box:

Please tick all that apply:

Strilanc commented 3 years ago

Ah, I see this is actually already somewhat possible via AllowAtMostNCallsCA.