Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Inserting MultiM Operator into circuit will change the states of the qubits #605

Open
@weucode

Description

@weucode

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 问题链接必须具有此部分。

Metadata

Metadata

Assignees

Labels

Kind-BugSomething isn't workingPkg-StandardIssue relates to the Microsoft.Quantum.Standard package.trackingThis label will trigger gh-sync to create or update a mirror internal ADO issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions