Skip to content

Commit

Permalink
Update to QDK 0.12.20070124 (microsoft#383)
Browse files Browse the repository at this point in the history
* Update QDK for .NET projects. (microsoft#382)

* Use new M.Q.Synthesis namespace in samples (microsoft#373)

* Use synthesis namespace in order-finding.

* Small fixes.

* Refactor reversible logic synthesis.

* Update README of oracle synthesis with pointer to library implementations.

* Update QDK version.

* Apply suggestions from code review

Co-authored-by: Chris Granade <[email protected]>

* Links.

* Simplify code.

* Update QDK in other projects of same solution.

* Update QDK for .NET projects.

* Tests are covered in QuantumLibraries now.

Co-authored-by: Chris Granade <[email protected]>

Co-authored-by: Chris Granade <[email protected]>
  • Loading branch information
msoeken and Chris Granade authored Jul 28, 2020
1 parent b1ec930 commit b111c3d
Show file tree
Hide file tree
Showing 39 changed files with 122 additions and 425 deletions.
15 changes: 11 additions & 4 deletions samples/algorithms/oracle-synthesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ algorithms](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.91.027902)
and A. Aspuru-Guzik [[Efficient quantum circuits for diagonal unitaries without
ancillas](http://iopscience.iop.org/article/10.1088/1367-2630/16/3/033040/meta),
*New J. of Phys.* **16**, 033040, 2014].

## Prerequisites ##

This sample describes in detail the underlying concepts that were used to implement
the following operations from the [Q# Standard library](https://github.com/microsoft/QuantumLibraries/tree/master/Standard):

- [Microsoft.Quantum.Canon.ApplyAnd](https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.canon.applyand)
- [Microsoft.Quantum.Synthesis.ApplyXControlledOnTruthTable](https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.synthesis.applyxcontrolledontruthtable)
- [Microsoft.Quantum.Synthesis.ApplyXControlledOnTruthTableWithCleanTarget](https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.synthesis.applyxcontrolledontruthtablewithcleantarget)

## Prerequisites

- The Microsoft [Quantum Development Kit](https://docs.microsoft.com/quantum/install-guide/).

## Running the Sample ##
## Running the Sample

To run the sample, use the `dotnet run` command from your terminal.
To run the sample, use the `dotnet run` command from your terminal.

## Manifest

Expand Down
4 changes: 0 additions & 4 deletions samples/algorithms/order-finding/OrderFinding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<StartupObject>Microsoft.Quantum.Samples.OrderFinding.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\reversible-logic-synthesis\ReversibleLogicSynthesis.csproj" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions samples/algorithms/order-finding/OrderFinding.qs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Samples.OrderFinding {
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Samples.ReversibleLogicSynthesis;
open Microsoft.Quantum.Synthesis;
open Microsoft.Quantum.Arithmetic;

/// # Summary
Expand Down Expand Up @@ -38,7 +38,7 @@ namespace Microsoft.Quantum.Samples.OrderFinding {
/// of the permutation. The permutation is called n + 1 times for exponents
/// 2⁰, 2¹, ..., 2ⁿ on the lower n qubits. For each exponent, we update the
/// permutation and compute a quantum circuit using reversible logic synthesis
/// from the namespace `Microsoft.Quantum.Samples.ReversibleLogicSynthesis`.
/// from the namespace `Microsoft.Quantum.Synthesis`.
/// Finally, a QFT is applied to the upper qubits.
///
/// # Input
Expand All @@ -56,7 +56,7 @@ namespace Microsoft.Quantum.Samples.OrderFinding {
ApplyToEach(H, topQubits);

for (i in 0..n) {
Controlled (ApplyPermutationOracle(accumulatedPermutation, TBS, _))([topQubits[n - i]], bottomQubits);
Controlled (ApplyPermutationUsingTransformation(accumulatedPermutation, _))([topQubits[n - i]], LittleEndian(bottomQubits));
set accumulatedPermutation = Squared(accumulatedPermutation);
}

Expand Down
2 changes: 1 addition & 1 deletion samples/algorithms/order-finding/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.Quantum.Simulation.Core;
Expand Down
12 changes: 6 additions & 6 deletions samples/algorithms/order-finding/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Order Finding #
# Order Finding

This sample uses a quantum algorithm to find the order of a cycle in a permutation.
It succeeds with a higher probability than the classical best possible strategy.
Expand All @@ -11,21 +11,21 @@ and I.L. Chuang in [Experimental realization of an order-finding algorithm with
The quantum algorithm in the Q# file is implemented for permutations over 2ⁿ elements, however, the classical post-processing
in the C# file is restricted to permutations over 4 elements.

## Running the Sample ##
## Running the Sample

Open the `QsharpSamples.sln` solution in Visual Studio and set *Samples / 1. Algorithms / OrderFinding* as the startup project.
Press Start in Visual Studio to run the sample.
Press Start in Visual Studio to run the sample.

## Manifest ##
## Manifest

- **OrderFinding/**
- [OrderFinding.csproj](./OrderFinding.csproj): Main C# project for the example.
- [Program.cs](./Program.cs): C# code to call the operations defined in Q# and perform classical post-processing.
- [OrderFinding.qs](./OrderFinding.qs): The Q# implementation of the order finding algorithm.

## Example run ##
## Example run

```
```text
Permutation: [1 2 3 0]
Find cycle length at index 0
Expand Down
26 changes: 0 additions & 26 deletions samples/algorithms/reversible-logic-synthesis/Driver.cs

This file was deleted.

19 changes: 19 additions & 0 deletions samples/algorithms/reversible-logic-synthesis/Host.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Samples.ReversibleLogicSynthesis {
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Intrinsic;

@EntryPoint()
operation RunProgram() : Unit {
let perm = [0, 2, 3, 5, 7, 1, 4, 6];
let res = SimulatePermutation(perm);
Message($"Does circuit realize permutation: {res}");

for (shift in IndexRange(perm)) {
let measuredShift = FindHiddenShift(perm, shift);
Message($"Applied shift = {shift} Measured shift: {measuredShift}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<StartupObject>Microsoft.Quantum.Samples.ReversibleLogicSynthesis.Driver</StartupObject>
</PropertyGroup>

</Project>
Loading

0 comments on commit b111c3d

Please sign in to comment.