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

Latest commit

 

History

History
39 lines (28 loc) · 1.44 KB

File metadata and controls

39 lines (28 loc) · 1.44 KB
page_type languages products description
sample
qsharp
qdk
This sample uses the `Microsoft.Quantum.AutoSubstitution` NuGet package to provide alternative operations based on the simulator that is used.

Using the AutoSubstitution rewrite step

The Microsoft.Quantum.AutoSubstitution NuGet package offers an attribute @SubstitutableOnTarget that lets you replace one operation with another when using a particular simulator. For instance, decorating the operation Op with @SubstitutableOnTarget("AltOp", "Sim") lets the compiler perform a rewrite step that can link an operation Op to a set of pairs of an alternative operations AltOp and a simulator Sim, such that AltOp is executed as a replacement for Op when being invoked in Sim.

This auto substitution blog post in the Q# blog describes this sample in more detail.

Running the program

First, run

dotnet run

and you should see Quantum version as output, but when running

dotnet run -- -s ToffoliSimulator

the program prints Classical version instead, since the alternative operation is executed.

Manifest