Inserting MultiM
Operator into circuit will change the states of the qubits #605
Description
Description
When running the following Q# program, the result of each shots is different for two qubit arrays. But the measure operation used here should not have changed the state of qubits. Here are just one situation, it may be quite different in each time.
mid:
[Zero,Zero,Zero,Zero,Zero,Zero]
[One,Zero,Zero,Zero]
final:
[Zero,Zero,Zero,Zero,Zero,Zero]
[Zero,Zero,Zero,One]
mid:
[Zero,Zero,Zero,Zero,Zero,Zero]
[One,Zero,Zero,Zero]
final:
[Zero,Zero,Zero,Zero,Zero,Zero]
[One,Zero,Zero,Zero]
But if we comment the lines which tag with "// Codes that have an impact", the final state will be zero all the time.
final:
[Zero,Zero,Zero,Zero,Zero,Zero]
[Zero,Zero,Zero,Zero]
It is supposed that QsCompiler will execute some passes when get code block like op
and adjoint op
, but if there are some other operations between op
and adjoint op
, it will not work even when these operations do nothing.
Another probability is that MultiM
operation does change the state here.
Testcase
namespace NISLNameSpace {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.ErrorCorrection;
operation NISLMeasure (q : Qubit[]) : Unit {
mutable result = MultiM (q);
Message($"{result}");
}
operation NISLOperation () : Unit {
use NISLVariable1 = Qubit[6];
use NISLVariable2 = Qubit[4];
FiveQubitCodeEncoderImpl(NISLVariable1,NISLVariable2);
Message("mid:"); // Codes that have an impact
NISLMeasure(NISLVariable1); // Codes that have an impact
NISLMeasure(NISLVariable2); // Codes that have an impact
Adjoint FiveQubitCodeEncoderImpl(NISLVariable1,NISLVariable2);
Message("final:");
NISLMeasure(NISLVariable1);
NISLMeasure(NISLVariable2);
ResetAll(NISLVariable1);
ResetAll(NISLVariable2);
}
@EntryPoint()
operation main() : Unit {
for i in 0..5{
mutable result = NISLOperation();
}
}
}
Environment
operating system : Windows 10
dotnet version : 6.0.301
QDK : 0.25.218240
文档详细信息
⚠ 请勿编辑此部分。 docs.microsoft.com ➟ GitHub 问题链接必须具有此部分。
- ID: 989db460-76ea-4ae0-b8f0-24c970558a0a
- Version Independent ID: 952b31cd-a9e8-7031-d1c8-0c87897ed9a2
- Content: MultiM operation - Q# reference - Microsoft Quantum
- Content Source: api/qsharp/microsoft.quantum.measurement.multim.md
- Product: qsharp
- GitHub Login: @ricardo-espinoza