Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
# Note that we only support automerge on branches that have required checks.
branches:
- master
- main
- feature/*
types:
- labeled
Expand All @@ -19,7 +19,7 @@ on:
pull_request_review:
# Note that we only support automerge on branches that have required checks.
branches:
- master
- main
- feature/*
types:
- submitted
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/qdk-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Sync QDK repos

on:
push:
branches:
- main

jobs:
sync-repos:
runs-on: ubuntu-latest
steps:
- name: Login to Azure
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- id: AzureKeyVault
uses: Azure/get-keyvault-secrets@v1.0
with:
keyvault: 'kv-qdk-build'
secrets: 'qdkBuildPAT'

- name: 'Trigger QDK sync build'
uses: Azure/pipelines@releases/v1
with:
azure-devops-project-url: 'https://dev.azure.com/ms-quantum-public/Microsoft Quantum (public)'
azure-pipeline-name: 'microsoft.qdk.sync'
azure-devops-token: ${{ steps.AzureKeyVault.outputs.qdkBuildPAT }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: no-commit-to-branch
args: [-b, "master"]
args: [-b, "main"]
- id: check-yaml
- repo: local
hooks:
Expand Down
33 changes: 33 additions & 0 deletions Build/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: $(Build.Major).$(Build.Minor).$(date:yyMM).$(BuildId)

parameters:
- name: validation_level
displayName: Validation Level
type: string
default: normal
values:
- minimal
- normal
- full

trigger: none

pr:
- main
- feature/*
- features/*
- release/*

resources:
repositories:
- repository: qdk
type: github
endpoint: github
name: microsoft/qdk
ref: refs/heads/main

extends:
template: build/qdk-module-e2e.yml@qdk
parameters:
module: QuantumLibraries
validation_level: ${{ parameters.validation_level }}
45 changes: 36 additions & 9 deletions Build/manifest.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,50 @@
#!/usr/bin/env pwsh
#Requires -PSEdition Core
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

<#
.SYNOPSIS
Provides the list of artifacts (Packages and Assemblies) generated by this repository.

.PARAMETER OutputFormat
Specifies if the output of this script should be a hashtable with the artifacts
as strings with the absolute path (AbsolutePath) or FileInfo structures.
#>
param(
[ValidateSet('FileInfo','AbsolutePath')]
[string] $OutputFormat = 'FileInfo'
);


& "$PSScriptRoot/set-env.ps1"

@{
$artifacts = @{
Packages = @(
"Microsoft.Quantum.Standard",
"Microsoft.Quantum.Standard.Visualization",
"Microsoft.Quantum.Chemistry",
"Microsoft.Quantum.Chemistry.DataModel",
"Microsoft.Quantum.Chemistry.Jupyter",
"Microsoft.Quantum.Chemistry.Runtime",
"Microsoft.Quantum.Chemistry.Tools",
"Microsoft.Quantum.MachineLearning",
"Microsoft.Quantum.Numerics",
"Microsoft.Quantum.MachineLearning"
);
"Microsoft.Quantum.Standard",
"Microsoft.Quantum.Standard.Visualization"
) | ForEach-Object { Join-Path $Env:NUGET_OUTDIR "$_.$Env:NUGET_VERSION.nupkg" };

Assemblies = @(
".\Standard\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Standard.dll",
".\Visualization\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Standard.Visualization.dll",
".\Numerics\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Numerics.dll",
".\MachineLearning\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.MachineLearning.dll",
".\Chemistry\src\DataModel\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.DataModel.dll",
".\Chemistry\src\Jupyter\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Jupyter.dll",
".\Chemistry\src\Runtime\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Runtime.dll",
".\Chemistry\src\Tools\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\qdk-chem.dll"
) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot ".." $_) };
} | Write-Output;
) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) };
}

if ($OutputFormat -eq 'FileInfo') {
$artifacts.Packages = $artifacts.Packages | ForEach-Object { Get-Item $_ };
$artifacts.Assemblies = $artifacts.Assemblies | ForEach-Object { Get-Item $_ };
}

$artifacts | Write-Output;
3 changes: 1 addition & 2 deletions Build/props/tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.13.201118141-beta" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

</Project>

6 changes: 6 additions & 0 deletions Build/steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ steps:
workingDirectory: $(System.DefaultWorkingDirectory)/Build


- pwsh: .\manifest.ps1
displayName: "List built packages & assemblies"
workingDirectory: '$(System.DefaultWorkingDirectory)/Build'
condition: succeededOrFailed()


- template: step-wrap-up.yml
6 changes: 3 additions & 3 deletions Chemistry/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Microsoft Quantum Chemistry Library #

This folder contains the C# and Q# sources used to implement the [Microsoft Quantum Chemistry library](https://docs.microsoft.com/en-us/quantum/libraries/chemistry/).
Samples of how to use the library can be found in the Chemistry folder of the [Microsoft/Quantum repository](https://github.com/Microsoft/Quantum/tree/master/Chemistry).
Samples of how to use the library can be found in the Chemistry folder of the [Microsoft/Quantum repository](https://github.com/microsoft/Quantum/tree/main/Chemistry).

## Building and testing ##

The quantum chemistry library consists of two cross-platform project built using [.NET Core](https://docs.microsoft.com/en-us/dotnet/core/):

- [**DataModel.csproj**](https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry/src/DataModel/DataModel.csproj): C# sources used to load, parse, and pre-compute Hamiltonians loaded from LIQ𝑈𝑖|〉 or Broombridge files.
- [**Runtime.csproj**](https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry/src/Runtime/Runtime.csproj): Q# sources used to implement quantum chemistry simulation algorithms, given representations produced by the DataModel.
- [**DataModel.csproj**](https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry/src/DataModel/DataModel.csproj): C# sources used to load, parse, and pre-compute Hamiltonians loaded from LIQ𝑈𝑖|〉 or Broombridge files.
- [**Runtime.csproj**](https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry/src/Runtime/Runtime.csproj): Q# sources used to implement quantum chemistry simulation algorithms, given representations produced by the DataModel.

Once .NET Core is installed, you may build and run its tests by executing the following from a command line:

Expand Down
2 changes: 1 addition & 1 deletion Chemistry/src/DataModel/DataModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageId>Microsoft.Quantum.Chemistry.DataModel</PackageId>
<PackageReleaseNotes>See: https://docs.microsoft.com/en-us/quantum/relnotes/</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry</PackageProjectUrl>
<PackageProjectUrl>https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry</PackageProjectUrl>
<PackageIcon>qdk-nuget-icon.png</PackageIcon>
<PackageTags>Quantum Q# Qsharp</PackageTags>
<NoWarn>1591</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ internal static V0_1.IntegralSet ToBroombridgeV0_1(this ElectronicStructureProbl
#region Broombridge v0.1 format
public static class V0_1
{
public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/master/Chemistry/Schema/broombridge-0.1.schema.json";
public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/main/Chemistry/Schema/broombridge-0.1.schema.json";

public struct Data
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ this IEnumerable<V0_2.State> initialStates
#region Broombridge v0.2 format
public static class V0_2
{
public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/master/Chemistry/Schema/broombridge-0.2.schema.json";
public static string SchemaUrl = "https://raw.githubusercontent.com/microsoft/Quantum/main/Chemistry/Schema/broombridge-0.2.schema.json";
internal static class UpdaterStrings
{
public const string SingleConfigurational = "single_configurational";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static class Deserializers
/// </summary>
internal static Dictionary<string, VersionNumber> VersionNumberDict = new Dictionary<string, VersionNumber>()
{
// https://github.com/Microsoft/Quantum/blob/master/Chemistry/Schema/broombridge-0.1.schema.json
// https://github.com/microsoft/Quantum/blob/main/Chemistry/Schema/broombridge-0.1.schema.json
["0.1"] = VersionNumber.v0_1,
["broombridge-0.1.schema"] = VersionNumber.v0_1,
// TODO: URL of 0.2 schema.
Expand Down
2 changes: 1 addition & 1 deletion Chemistry/src/Jupyter/BroombridgeMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BroombridgeMagic : MagicSymbol
public BroombridgeMagic()
{
this.Name = $"%chemistry.broombridge";
this.Documentation = new Documentation() { Summary = "Loads and returns Broombridge electronic structure problem representation from a given .yaml file." };
this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Loads and returns Broombridge electronic structure problem representation from a given .yaml file." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
Expand Down
2 changes: 1 addition & 1 deletion Chemistry/src/Jupyter/ChemistryEncodeMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ChemistryEncodeMagic : MagicSymbol
public ChemistryEncodeMagic()
{
this.Name = $"%chemistry.encode";
this.Documentation = new Documentation() { Summary = "Encodes a fermion Hamiltonian to a format consumable by Q#." };
this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Encodes a fermion Hamiltonian to a format consumable by Q#." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
Expand Down
7 changes: 5 additions & 2 deletions Chemistry/src/Jupyter/FermionHamiltonianMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class FermionHamiltonianLoadMagic : MagicSymbol
public FermionHamiltonianLoadMagic()
{
this.Name = $"%chemistry.fh.load";
this.Documentation = new Documentation() { Summary = "Loads the fermion Hamiltonian for an electronic structure problem. The problem is loaded from a file or passed as an argument." };
this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Loads the fermion Hamiltonian for an electronic structure problem. The problem is loaded from a file or passed as an argument." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
Expand Down Expand Up @@ -113,7 +113,10 @@ public class FermionHamiltonianAddTermsMagic : MagicSymbol
public FermionHamiltonianAddTermsMagic()
{
this.Name = $"%chemistry.fh.add_terms";
this.Documentation = new Documentation() { Summary = "Adds terms to a fermion Hamiltonian." };
this.Documentation = new Microsoft.Jupyter.Core.Documentation
{
Summary = "Adds terms to a fermion Hamiltonian."
};
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
Expand Down
8 changes: 6 additions & 2 deletions Chemistry/src/Jupyter/Jupyter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<Description>Microsoft's Quantum Chemistry Libraries Jupyter integration.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageReleaseNotes>See: https://docs.microsoft.com/en-us/quantum/relnotes/</PackageReleaseNotes>
<PackageLicenseUrl>https://github.com/Microsoft/QuantumLibraries/raw/master/LICENSE.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/microsoft/QuantumLibraries/raw/main/LICENSE.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry</PackageProjectUrl>
<PackageIcon>qdk-nuget-icon.png</PackageIcon>
<PackageTags>Quantum Q# Qsharp Jupyter</PackageTags>
<NoWarn>1591</NoWarn>
Expand All @@ -29,6 +29,10 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\..\Build\assets\qdk-nuget-icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Chemistry/src/Jupyter/WavefunctionMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class WavefunctionMagic : MagicSymbol
public WavefunctionMagic()
{
this.Name = $"%chemistry.inputstate.load";
this.Documentation = new Documentation() { Summary = "Loads Broombridge electronic structure problem and returns selected input state." };
this.Documentation = new Microsoft.Jupyter.Core.Documentation() { Summary = "Loads Broombridge electronic structure problem and returns selected input state." };
this.Kind = SymbolKind.Magic;
this.Execute = this.Run;
}
Expand Down
2 changes: 1 addition & 1 deletion Chemistry/src/Metapackage/Metapackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageId>Microsoft.Quantum.Chemistry</PackageId>
<PackageReleaseNotes>See: https://docs.microsoft.com/en-us/quantum/relnotes/</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Microsoft/QuantumLibraries/tree/master/Chemistry</PackageProjectUrl>
<PackageProjectUrl>https://github.com/microsoft/QuantumLibraries/tree/main/Chemistry</PackageProjectUrl>
<PackageIcon>qdk-nuget-icon.png</PackageIcon>
<PackageTags>Quantum Q# Qsharp</PackageTags>
<NoWarn>1591</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
open Microsoft.Quantum.Arrays;

/// # Summary
/// Computes Z component of JordanWigner string between
/// Computes Z component of JordanWigner string between
/// fermion indices in a fermionic operator with an even
/// number of creation / annihilation operators.
///
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
let ops = [[PauliX, PauliY], [PauliY, PauliX]];
let signs = [+1.0, -1.0];

for ((op, sign) in Zip(ops, signs)) {
for ((op, sign) in Zipped(ops, signs)) {
let pauliString = _ComputeJordanWignerPauliString(Length(qubits), idxFermions, op);
Exp(pauliString, sign * angle, qubits);
}
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
let ops = [[y,y,x,y],[x,x,x,y],[x,y,y,y],[y,x,y,y],[x,y,x,x],[y,x,x,x],[y,y,y,x],[x,x,y,x]];
let (sortedIndices, signs, globalSign) = _JordanWignerClusterOperatorPQRSTermSigns([p,q,r,s]);

for ((op, sign) in Zip(ops, signs)) {
for ((op, sign) in Zipped(ops, signs)) {
let pauliString = _ComputeJordanWignerPauliString(Length(qubits), sortedIndices, op);
Exp(pauliString, globalSign * sign * angle, qubits);
}
Expand Down Expand Up @@ -272,4 +272,3 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {

}


Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {
open Microsoft.Quantum.Chemistry;
open Microsoft.Quantum.Arrays;

// This evolution set runs off data optimized for a JordanWigner encoding.
// This evolution set runs off data optimized for a JordanWigner encoding.
// This collects terms Z, ZZ, PQandPQQR, hpqrs separately.
// This only apples the needed hpqrs XXXX XXYY terms.
// Operations here are expressed in terms of Exp([...])
Expand Down Expand Up @@ -134,7 +134,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {

if (idxFermions[0] < qubitQidx and qubitQidx < idxFermions[3]) {
let termPR1 = GeneratorIndex((idxTermType, [1.0]), [idxFermions[0], idxFermions[3] - 1]);
_ApplyJordanWignerPQTerm_(termPR1, angle, new Qubit[0], Exclude([qubitQidx], qubits));
_ApplyJordanWignerPQTerm_(termPR1, angle, new Qubit[0], Excluding([qubitQidx], qubits));
}
else {
let termPR1 = GeneratorIndex((idxTermType, [1.0]), [0, idxFermions[3] - idxFermions[0]]);
Expand Down Expand Up @@ -280,4 +280,3 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner {

}


4 changes: 2 additions & 2 deletions Chemistry/src/Runtime/JordanWigner/JordanWignerVQE.qs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner.VQE {

mutable jwTermEnergy = 0.;

for ((coeff, op) in Zip(coeffs, ops)) {
for ((coeff, op) in Zipped(coeffs, ops)) {
// Only perform computation if the coefficient is significant enough
if (AbsD(coeff) >= 1e-10) {
// Compute expectation value using the fast frequency estimator, add contribution to Jordan-Wigner term energy
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace Microsoft.Quantum.Chemistry.JordanWigner.VQE {
mutable compactOp = compactOps[iOp];

mutable op = ConstantArray(nQubits, PauliI);
for ((idx, pauli) in Zip(indices, compactOp)) {
for ((idx, pauli) in Zipped(indices, compactOp)) {
set op w/= idx <- pauli;
}
for (i in indices[0]+1..indices[1]-1) {
Expand Down
Loading