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
Binary file modified AdvantageBenchmark/privateBuild/advantage.sln
Binary file not shown.
2 changes: 1 addition & 1 deletion AdvantageBenchmark/privateBuild/host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Simulation\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\..\src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Simulation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulatio
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.Common", "src\Simulation\Common\Microsoft.Quantum.Simulation.Common.csproj", "{8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulators", "src\Simulation\Simulators.Core\Microsoft.Quantum.Simulators.csproj", "{72B7E75C-D305-45BD-929E-C86298AAA8DE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulators", "src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj", "{72B7E75C-D305-45BD-929E-C86298AAA8DE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime", "src\Simulation\QCTraceSimulator.Tests\Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj", "{DD50D2D9-2765-449B-8C4B-835A428E160D}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Push-Location (Join-Path $PSScriptRoot "src/Simulation/CsharpGeneration")
.\FindNuspecReferences.ps1
Pop-Location

Push-Location (Join-Path $PSScriptRoot "src/Simulation/Simulators.Core")
Push-Location (Join-Path $PSScriptRoot "src/Simulation/Simulators")
.\FindNuspecReferences.ps1
Pop-Location

Expand Down
6 changes: 3 additions & 3 deletions build/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
".\src\Simulation\Type1Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Type1.Core.dll",
".\src\Simulation\Type2Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Type2.Core.dll",
".\src\Simulation\QsharpFoundation\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Foundation.dll",
".\src\Simulation\Simulators.Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll",
".\src\Simulation\Simulators.Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll",
".\src\Simulation\Simulators.Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll",
".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll",
".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll",
".\src\Simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll",
".\src\Simulation\Simulators.Type1\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.Type1.dll",
".\src\Simulation\Simulators.Type2\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.Type2.dll",
".\src\Xunit\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Xunit.dll"
Expand Down
2 changes: 1 addition & 1 deletion build/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Pack-Dotnet '../src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundat
Pack-Dotnet '../src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj'
Pack-Dotnet '../src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj'
Pack-Dotnet '../src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj'
Pack-One '../src/Simulation/Simulators.Core/Microsoft.Quantum.Simulators.nuspec'
Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec'
Pack-One '../src/Simulation/Simulators.Type1/Microsoft.Quantum.Simulators.Type1.nuspec'
Pack-One '../src/Simulation/Simulators.Type2/Microsoft.Quantum.Simulators.Type2.nuspec'
Pack-One '../src/Quantum.Development.Kit/Microsoft.Quantum.Development.Kit.nuspec'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Azure.Quantum.Client.Models;
using System;

namespace Microsoft.Azure.Quantum.Exceptions
Expand Down Expand Up @@ -67,9 +68,41 @@ public WorkspaceClientException(
$"WorkspaceName: {workspaceName}{Environment.NewLine}" +
$"BaseUri: {baseUri}{Environment.NewLine}" +
$"JobId: {jobId}{Environment.NewLine}" +
(inner != null ? $"Inner Exception: {inner}" : string.Empty),
FormatInnerException(inner),
inner)
{
}

/// <summary>
/// Formats the contents of the inner exception in <see cref="WorkspaceClientException"/> so it can be included in the
/// exception message and presented in an informative way.
/// </summary>
/// <param name="ex">Inner exception that we want to include in the outer exception message.</param>
/// <return>
/// A string representing the contents of the inner exception.
/// </return>
private static string FormatInnerException(Exception ex)
{
string formattedException = string.Empty;
if (ex != null)
{
formattedException += $"Server Error: {ex.Message}{Environment.NewLine}";

// Handle specific types of exceptions for additional data
if (ex is RestErrorException restErrorException)
{
formattedException += $"Error Code: {restErrorException?.Body?.Code}{Environment.NewLine}" +
$"Server message: {restErrorException?.Body?.Message}{Environment.NewLine}";

var headers = restErrorException?.Response?.Headers;
if (headers != null && headers.ContainsKey("x-ms-request-id"))
{
formattedException += $"Server Request Id: {headers["x-ms-request-id"]}{Environment.NewLine}";
}
}
}

return formattedException;
}
}
}
2 changes: 1 addition & 1 deletion src/Simulation/Common/Simulators.Impl.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="$(EnlistmentRoot)src\Simulation\Simulators\QuantumSimulator\*.cs" />
<Compile Include="$(EnlistmentRoot)src\Simulation\Simulators.Impl\QuantumSimulator\*.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<ItemGroup>
<ProjectReference Include="..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" />
<ProjectReference Include="..\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\Simulators\Microsoft.Quantum.Simulators.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\Simulators\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\..\Azure\Azure.Quantum.Client\Microsoft.Azure.Quantum.Client.csproj" />
</ItemGroup>

Expand Down
5 changes: 4 additions & 1 deletion src/Simulation/Native/src/external/fused.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ class Fused
if (envNT == NULL) { // If the user didn't force the number of threads, make an intelligent guess
int nMaxThrds = std::thread::hardware_concurrency(); // Logical HW threads
if (nMaxThrds > 4) nMaxThrds/= 2; // Assume we have hyperthreading (no consistent/concise way to do this)
if (wfnCapacity < 1u << 20) {
if (wfnCapacity < 1ul << 14) nMaxThrds = 1;
else if (wfnCapacity < 1ul << 16) nMaxThrds = 2;
else if (wfnCapacity < 1ul << 20)
{
if (nMaxThrds > 8) nMaxThrds = 8; // Small problem, never use too many
else if (nMaxThrds > 3) nMaxThrds = 3; // Small problem on a small machine
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Xunit\Microsoft.Quantum.Xunit.csproj" />
<ProjectReference Include="..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" IsQscReference="true" />
<ProjectReference Include="..\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\Simulators\Microsoft.Quantum.Simulators.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions src/Simulation/QsharpCore/Arrays/Empty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using Microsoft.Quantum.Simulation.Core;

namespace Microsoft.Quantum.Arrays
{
public partial class EmptyArray<__TElement__>
{
public class Native : EmptyArray<__TElement__>
{
public Native(IOperationFactory m) : base(m) { }
public override Func<QVoid, IQArray<__TElement__>> __Body__ => _ =>
new QArray<__TElement__>();
}
}

}
24 changes: 24 additions & 0 deletions src/Simulation/QsharpCore/Arrays/Empty.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Arrays {

/// # Summary
/// Returns the empty array of a given type.
///
/// # Type Parameters
/// ## 'TElement
/// The type of elements of the array.
///
/// # Output
/// The empty array.
///
/// # Example
/// ```Q#
/// let empty = EmptyArray<Int>();
/// ```
function EmptyArray<'TElement>() : 'TElement[] {
body intrinsic;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public virtual DataTable Data
var results = collector.Results.ToTable();
Debug.Assert(results.keyColumnNames.Length > 2 && results.keyColumnNames[2] == "Caller");

var roots = results.rows.Where(r => r.KeyRow[2] == CallGraphEdge.CallGraphRootHashed);
var roots = results.rows.Where(r => r.KeyRow[2] == CallGraphEdge.CallGraphRootHashed);
var s_idx = Array.FindIndex(results.statisticsNames, n => n == "Sum");

for (var m_idx = 0; m_idx < results.metricNames.Length; m_idx++)
Expand All @@ -135,14 +135,14 @@ public virtual DataTable Data
row["Metric"] = label;

if (m_idx >= 0 && s_idx >= 0)
{
Double sum = 0;
Double max = 0; // all our metrics are positive
{
Double sum = 0;
Double max = 0; // all our metrics are positive
foreach (var r in roots)
{
Double metric_value = r.DataRow[m_idx, s_idx];
sum += metric_value;
max = System.Math.Max(max, metric_value);
{
Double metric_value = r.DataRow[m_idx, s_idx];
sum += metric_value;
max = System.Math.Max(max, metric_value);
}
row["Sum"] = sum;
row["Max"] = max;
Expand Down
29 changes: 0 additions & 29 deletions src/Simulation/Simulators.Tests/Circuits/Bug2212.qs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Arrays {
open Microsoft.Quantum.Diagnostics;

/// # Summary
/// Checks that empty arrays are indeed empty.
@Test("QuantumSimulator")
@Test("ToffoliSimulator")
function EmptyArraysAreEmpty() : Unit {
Fact(
Length(EmptyArray<Int>()) == 0,
"Empty array of type Int[] was not actually empty."
);
Fact(
Length(EmptyArray<(Double, Pauli[])>()) == 0,
"Empty array of type (Double, Pauli[])[] was not actually empty."
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\..\..\Simulators\Microsoft.Quantum.Simulators.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\..\..\Simulators\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\Library1\Library1.csproj" />
<ProjectReference Include="..\Library2\Library2.csproj" />
<ProjectReference Include="..\Library with Spaces\Library with Spaces.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Simulators.Core\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\Simulators\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="TestProjects\QsharpExe\QsharpExe.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<Import Project="..\Common\Simulators.Impl.props" />

<ItemGroup>
<Compile Include="..\Simulators\QCTraceSimulator\*.cs" />
<QSharpcompile Include="..\Simulators\QCTraceSimulator\Circuits\*.qs" />
<Compile Include="..\Simulators\QuantumProcessor\*.cs" />
<Compile Include="..\Simulators\ResourcesEstimator\*.cs" />
<Compile Include="..\Simulators\ToffoliSimulator\*.cs" />
<Compile Include="..\Simulators.Impl\QCTraceSimulator\*.cs" />
<QSharpcompile Include="..\Simulators.Impl\QCTraceSimulator\Circuits\*.qs" />
<Compile Include="..\Simulators.Impl\QuantumProcessor\*.cs" />
<Compile Include="..\Simulators.Impl\ResourcesEstimator\*.cs" />
<Compile Include="..\Simulators.Impl\ToffoliSimulator\*.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<file src="..\Native\osx\*" target="runtimes\osx-x64\native" />
<file src="..\Native\linux\*" target="runtimes\linux-x64\native" />
<file src="..\Native\win10\*" target="runtimes\win-x64\native" />
<file src="..\Simulators.Core\bin\$Configuration$\**\Microsoft.Quantum.Simulators.dll" target="lib" />
<file src="..\Simulators.Core\bin\$Configuration$\**\Microsoft.Quantum.Simulators.xml" target="lib" />
<file src="..\Simulators.Core\bin\$Configuration$\**\Microsoft.Quantum.Simulators.pdb" target="lib" />
<file src="..\Simulators.Core\bin\$Configuration$\**\Microsoft.Quantum.Simulation.*.dll" target="lib" />
<file src="..\Simulators.Core\bin\$Configuration$\**\Microsoft.Quantum.Simulation.*.xml" target="lib" />
<file src="..\Simulators.Core\bin\$Configuration$\**\Microsoft.Quantum.Simulation.*.pdb" target="lib" />
<file src="..\Simulators\bin\$Configuration$\**\Microsoft.Quantum.Simulators.dll" target="lib" />
<file src="..\Simulators\bin\$Configuration$\**\Microsoft.Quantum.Simulators.xml" target="lib" />
<file src="..\Simulators\bin\$Configuration$\**\Microsoft.Quantum.Simulators.pdb" target="lib" />
<file src="..\Simulators\bin\$Configuration$\**\Microsoft.Quantum.Simulation.*.dll" target="lib" />
<file src="..\Simulators\bin\$Configuration$\**\Microsoft.Quantum.Simulation.*.xml" target="lib" />
<file src="..\Simulators\bin\$Configuration$\**\Microsoft.Quantum.Simulation.*.pdb" target="lib" />
<file src="..\..\..\build\assets\qdk-nuget-icon.png" target="images" />
</files>
</package>
2 changes: 1 addition & 1 deletion src/Simulation/TargetDefinitions/Decompositions/MResetY.qs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Microsoft.Quantum.Measurement {
let result = Measure([PauliY], [target]);

// We must return the qubit to the Z basis as well.
S(target);
Adjoint S(target);
H(target);

if (result == One) {
Expand Down