qsharp-runtime
qsharp-runtime copied to clipboard
Add `MeasureEachZ` operation to runtime implementation
To provide support on hardware for the common operation of "measure a list of qubits and produce a list of Results" that can be supported without need for full array runtime support, we need to define a new version of Microsoft.Quantum.Measurement.MultiM
that is compatible with compilation for hardware targets. By introducing a new operation, Microsoft.Quantum.Measurement.MeasureEachZ
, we can achieve two goals: have a runtime-defined measurement utility that QIR generation can replace with specific patterns supported on hardware, and define an operation with updating naming that follows the style guide that can eventually be used as a replacement when deprecating the libraries-defined MultiM
operation. The signature of MeasureEachZ
should be the same as MultiM
, namely:
operation MeasureEachZ(targets : Qubit[]) : Result[] { ... }
For the hardware compatibility, this function should be loop based and build up the Result array using copy update, instead of using ForEach
, so that it can be compiled into hardware-supported QIR patterns.
This issue has been approved in API review: microsoft/QuantumLibraries#584
Resolved in https://github.com/microsoft/qsharp-runtime/pull/1019