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
25 changes: 25 additions & 0 deletions build/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ function Test-Python {
}
}

function Test-JavaScript {
Param([string] $packageFolder, [string] $options)

Write-Host "##[info]Installing JS packages from $packageFolder"
Push-Location (Join-Path $PSScriptRoot $packageFolder)
npm install
Pop-Location

Write-Host "##[info]Testing JS inside $packageFolder"
Push-Location (Join-Path $PSScriptRoot $packageFolder)
if (!$options) {
npm test
} else {
npm test -- $options
}
Pop-Location

if ($LastExitCode -ne 0) {
Write-Host "##vso[task.logissue type=error;]Failed to test JS inside $packageFolder"
$script:all_ok = $False
}
}

Test-One '../iqsharp.sln' @("AzureClient", "IQSharpEngine", "Workspace")

if ($Env:ENABLE_PYTHON -eq "false") {
Expand All @@ -87,6 +110,8 @@ if ($Env:ENABLE_PYTHON -eq "false") {
Test-Python '../src/Python/qsharp-core' '../src/Python/qsharp-core/qsharp/tests'
}

Test-JavaScript '../src/Kernel'

if (-not $all_ok)
{
throw "At least one project failed to compile. Check the logs."
Expand Down
2 changes: 1 addition & 1 deletion images/iqsharp-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ENV PATH=$PATH:${HOME}/dotnet:${HOME}/.dotnet/tools \
# Install IQ# and the project templates, using the NuGet packages from the
# build context.
ARG IQSHARP_VERSION
RUN dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.12.20072031" && \
RUN dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.12.20073008-beta" && \
dotnet tool install \
--global \
Microsoft.Quantum.IQSharp \
Expand Down
40 changes: 27 additions & 13 deletions iqsharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureClient", "src\AzureCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jupyter", "src\Jupyter\Jupyter.csproj", "{19A9E2AB-8842-47E2-8E6A-6DD292B49E97}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mock.Chemistry", "src\Mock.Chemistry\Mock.Chemistry.csproj", "{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mock.Chemistry", "src\MockLibraries\Mock.Chemistry\Mock.Chemistry.csproj", "{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mock.Standard", "src\MockLibraries\Mock.Standard\Mock.Standard.csproj", "{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -113,18 +115,30 @@ Global
{19A9E2AB-8842-47E2-8E6A-6DD292B49E97}.Release|x64.Build.0 = Release|Any CPU
{19A9E2AB-8842-47E2-8E6A-6DD292B49E97}.Release|x86.ActiveCfg = Release|Any CPU
{19A9E2AB-8842-47E2-8E6A-6DD292B49E97}.Release|x86.Build.0 = Release|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Debug|x64.ActiveCfg = Debug|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Debug|x64.Build.0 = Debug|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Debug|x86.ActiveCfg = Debug|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Debug|x86.Build.0 = Debug|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Release|Any CPU.Build.0 = Release|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Release|x64.ActiveCfg = Release|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Release|x64.Build.0 = Release|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Release|x86.ActiveCfg = Release|Any CPU
{2243DB2D-EFAC-4594-A44B-A25B399CE4DE}.Release|x86.Build.0 = Release|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Debug|x64.ActiveCfg = Debug|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Debug|x64.Build.0 = Debug|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Debug|x86.ActiveCfg = Debug|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Debug|x86.Build.0 = Debug|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Release|Any CPU.Build.0 = Release|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Release|x64.ActiveCfg = Release|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Release|x64.Build.0 = Release|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Release|x86.ActiveCfg = Release|Any CPU
{AAAEA32B-3CFA-40D4-A7A0-D332ACB40BA1}.Release|x86.Build.0 = Release|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Debug|x64.ActiveCfg = Debug|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Debug|x64.Build.0 = Debug|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Debug|x86.ActiveCfg = Debug|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Debug|x86.Build.0 = Debug|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Release|Any CPU.Build.0 = Release|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Release|x64.ActiveCfg = Release|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Release|x64.Build.0 = Release|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Release|x86.ActiveCfg = Release|Any CPU
{854E40D3-64A2-4864-AB79-AB9CC61DA1DE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion src/AzureClient/AzureClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.12.20072031" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.12.20073008-beta" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.21" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
<PackageReference Include="System.Reactive" Version="4.3.2" />
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.20072031" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.12.20072031" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20072031" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.20073008-beta" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.12.20073008-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20073008-beta" />
<PackageReference Include="NuGet.Resolver" Version="5.1.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
Expand Down
156 changes: 156 additions & 0 deletions src/Core/ExecutionPathTracer/ExecutionPath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable

using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Microsoft.Quantum.IQSharp.Core.ExecutionPathTracer
{
/// <summary>
/// Represents the qubit resources and operations traced out in an execution path of a Q# operation.
/// </summary>
public class ExecutionPath
{
/// <summary>
/// Initializes a new instance of the <see cref="ExecutionPathTracer"/> class.
/// </summary>
/// <param name="qubits">
/// A list of <see cref="QubitDeclaration"/> that represents the declared qubits used in the execution path.
/// </param>
/// <param name="operations">
/// A list of <see cref="Operation"/> that represents the operations used in the execution path.
/// </param>
public ExecutionPath(IEnumerable<QubitDeclaration> qubits, IEnumerable<Operation> operations)
{
this.Qubits = qubits;
this.Operations = operations;
}

/// <summary>
/// A list of <see cref="QubitDeclaration"/> that represents the declared qubits used in the execution path.
/// </summary>
[JsonProperty("qubits")]
public IEnumerable<QubitDeclaration> Qubits { get; }

/// <summary>
/// A list of <see cref="Operation"/> that represents the operations used in the execution path.
/// </summary>
[JsonProperty("operations")]
public IEnumerable<Operation> Operations { get; }

/// <summary>
/// Serializes <see cref="ExecutionPath"/> into its JSON representation.
/// </summary>
/// <param name="prettyPrint">
/// Pretty prints the JSON (i.e. with white space and indents) if <c>true</c>.
/// </param>
public string ToJson(bool prettyPrint = false) =>
JsonConvert.SerializeObject(this,
(prettyPrint) ? Formatting.Indented : Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
}
);
}

/// <summary>
/// Represents a qubit resource used in an execution path.
/// </summary>
public class QubitDeclaration
{
/// <summary>
/// Initializes a new instance of the <see cref="QubitDeclaration"/> class.
/// </summary>
/// <param name="id">
/// Id of qubit.
/// </param>
/// <param name="numChildren">
/// Number of associated classical registers.
/// </param>
public QubitDeclaration(int id, int numChildren = 0)
{
this.Id = id;
this.NumChildren = numChildren;
}

/// <summary>
/// Id of qubit.
/// </summary>
[JsonProperty("id")]
public int Id { get; }

/// <summary>
/// Number of associated classical registers.
/// </summary>
[JsonProperty("numChildren")]
public int NumChildren { get; }

/// <summary>
/// Used by <see cref="Newtonsoft" /> to determine if <see cref="NumChildren" />
/// should be included in the JSON serialization.
/// </summary>
public bool ShouldSerializeNumChildren() => NumChildren > 0;
}

/// <summary>
/// Represents an operation used in an execution path.
/// </summary>
public class Operation
{
/// <summary>
/// Label of gate.
/// </summary>
[JsonProperty("gate")]
public string Gate { get; set; } = "";

/// <summary>
/// Arguments (except <see cref="Qubit" /> types) provided to gate that
/// will be displayed by the visualizer.
/// </summary>
[JsonProperty("displayArgs")]
public string? DisplayArgs { get; set; }

/// <summary>
/// Group of operations for each classical branch.
/// </summary>
/// <remarks>
/// Currently not used as this is intended for classically-controlled operations.
/// </remarks>
[JsonProperty("children")]
public IEnumerable<IEnumerable<Operation>>? Children { get; set; }

/// <summary>
/// True if operation is a measurement operations.
/// </summary>
[JsonProperty("isMeasurement")]
public bool IsMeasurement { get; set; }

/// <summary>
/// True if operation is a controlled operations.
/// </summary>
[JsonProperty("isControlled")]
public bool IsControlled { get; set; }

/// <summary>
/// True if operation is an adjoint operations.
/// </summary>
[JsonProperty("isAdjoint")]
public bool IsAdjoint { get; set; }

/// <summary>
/// List of control registers.
/// </summary>
[JsonProperty("controls")]
public IEnumerable<Register> Controls { get; set; } = new List<Register>();

/// <summary>
/// List of target registers.
/// </summary>
[JsonProperty("targets")]
public IEnumerable<Register> Targets { get; set; } = new List<Register>();
}
}
Loading