qsharp-runtime icon indicating copy to clipboard operation
qsharp-runtime copied to clipboard

Add `MeasureEachZ` operation to runtime implementation

Open swernli opened this issue 2 years ago • 1 comments

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.

swernli avatar May 02 '22 15:05 swernli

This issue has been approved in API review: microsoft/QuantumLibraries#584

msoeken avatar Jun 03 '22 07:06 msoeken

Resolved in https://github.com/microsoft/qsharp-runtime/pull/1019

swernli avatar Nov 28 '22 06:11 swernli