Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
01b135f
Refactor QSharp.Core into Foundation + Core (#254)
swernli Jun 18, 2020
73e7104
Merging master and fixing up solution file.
swernli Jun 23, 2020
90851b4
Merge pull request #282 from microsoft:swernli/merge-master
swernli Jun 23, 2020
329bcea
Merge remote-tracking branch 'origin/master' into swernli/decomp-merg…
swernli Jul 6, 2020
bea7acb
Merge pull request #296 from microsoft:swernli/decomp-merge-master
swernli Jul 7, 2020
80a9c6d
Merge remote-tracking branch 'origin/master' into swernli/decomp-merg…
swernli Aug 18, 2020
8a88b4e
Merge remote-tracking branch 'origin/master' into swernli/decomp-merg…
swernli Aug 21, 2020
5d670a8
Merge remote-tracking branch 'origin/master' into swernli/decomp-merg…
swernli Aug 21, 2020
2563547
Fixing ResourceEstimator conditional support
swernli Aug 21, 2020
7a37c05
Merge pull request #347 from microsoft/swernli/decomp-merge-master
swernli Aug 21, 2020
e94e9db
Merge remote-tracking branch 'origin/master' into swernli/decomp-merg…
swernli Aug 25, 2020
924aee7
Merge pull request #356 from microsoft/swernli/decomp-merge-master
swernli Aug 25, 2020
1676b4f
Skipping ResourceEstimator tests for targeted Exes
swernli Aug 19, 2020
ca50abe
Create QsharpCore targeting package (#352)
swernli Aug 20, 2020
7130778
Re-enable ResourceEstimator tests
swernli Aug 23, 2020
e35ba6b
Clean up internal operation names.
swernli Aug 26, 2020
078f122
Update src/Simulation/Simulators.Tests/QuantumTestSuite/AssertProbMul…
swernli Aug 26, 2020
d764d9b
Merge pull request #358 from microsoft/swernli/decomp-working2
swernli Aug 27, 2020
7632883
Adding Type2 targeting package and tests (#363)
swernli Sep 4, 2020
9898da5
Merge remote-tracking branch 'origin/master' into swernli/decomp-merg…
swernli Sep 4, 2020
46968b4
Merge pull request #365 from microsoft/swernli/decomp-merge-master
swernli Sep 4, 2020
9a8af05
Fixing csproj QDK versions
swernli Sep 4, 2020
91e2f9e
Merge pull request #366 from microsoft/swernli/decomp-version-fix
swernli Sep 4, 2020
9fda148
Add Type1 target package and simulator support (#367)
swernli Sep 21, 2020
daa957e
Merge remote-tracking branch 'origin/main' into swernli/decomp-merge-…
swernli Sep 22, 2020
4ad13c1
Moving UnsupportedOperationException into Common
swernli Sep 22, 2020
39b273b
Merge pull request #381 from microsoft/swernli/decomp-merge-master
swernli Sep 22, 2020
a45e7c7
Return projects to original paths to fix e2e build
swernli Oct 13, 2020
81948c7
Fix bug in MResetY
swernli Oct 14, 2020
7e057aa
Merge remote-tracking branch 'origin/main' into swernli/decomp-projec…
swernli Oct 14, 2020
ac3a622
Merge pull request #397 from microsoft/swernli/decomp-project-rename
swernli Oct 14, 2020
7c4edd2
Move EmptyArray to QsharpFoundation
swernli Oct 19, 2020
f3752b7
Merge pull request #403 from microsoft/swernli/decomp-fix-e2e
swernli Oct 21, 2020
590d0a6
Merge remote-tracking branch 'origin/main' into swernli/decomp-fix-e2e
swernli Oct 21, 2020
1c4c139
Remove extra project reference
swernli Oct 21, 2020
7b455f6
Merge branch 'feature/decomp' into swernli/decomp-fix-e2e
swernli Oct 21, 2020
85f892c
Merge pull request #405 from microsoft/swernli/decomp-fix-e2e
swernli Oct 21, 2020
07a1af4
Merge remote-tracking branch 'origin/main' into swernli/decomp-fix-e2e
swernli Oct 26, 2020
a365c5f
Fix Reset decomposition capability requirement
swernli Oct 26, 2020
af1ae73
Fix RFrac decomposition to allow negative exponentiation
swernli Oct 26, 2020
cf79eec
Merge pull request #414 from microsoft/swernli/decomp-fix-e2e
swernli Oct 27, 2020
f7d3530
Fixing negative exponentiation in ExpFrac
swernli Oct 27, 2020
cb10e4e
Add Comment about support of negative exponents
swernli Oct 27, 2020
85a516b
Merge branch 'feature/decomp' into swernli/decomp-fix-e2e
swernli Oct 27, 2020
eb4a193
Merge pull request #415 from microsoft/swernli/decomp-fix-e2e
swernli Oct 28, 2020
2d6dc66
Merge remote-tracking branch 'origin/main' into swernli/merge/feature…
swernli Oct 29, 2020
25a1256
Merge branch 'main' into swernli/merge/feature/decomp
swernli Oct 29, 2020
50b404a
Merge branch 'main' into swernli/merge/feature/decomp
swernli Oct 31, 2020
f19dc1e
Merge remote-tracking branch 'origin/main' into swernli/merge/feature…
swernli Nov 5, 2020
626300c
Fix QDK versions after merge from main
swernli Nov 6, 2020
53d204f
Preserve old C# override behavior by default, with opt in for new beh…
swernli Nov 6, 2020
7bd06ac
Removing CheckQubitUniqueness and RotationAngleValidaiton intrinsics
swernli Nov 6, 2020
bba798f
Merge branch 'main' into swernli/merge/feature/decomp
swernli Nov 6, 2020
74acb68
Merge branch 'main' into swernli/merge/feature/decomp
swernli Nov 7, 2020
5644801
Use alternate mechanism for skipping tests
swernli Nov 9, 2020
fde02ad
Merge branch 'main' into swernli/merge/feature/decomp
swernli Nov 9, 2020
70dcb0e
Native Simulator: change prereq check in state injection to return fa…
Nov 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file modified AdvantageBenchmark/privateBuild/advantage.sln
Binary file not shown.
4 changes: 4 additions & 0 deletions AdvantageBenchmark/privateBuild/host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

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

</Project>
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,7 @@ SOFTWARE.

-------------------------------------------------------------------

Microsoft.Quantum.Compiler 0.12.20082209-beta - MIT
Microsoft.Quantum.Compiler 0.13.20102604 - MIT


(c) 2008 VeriSign, Inc.
Expand Down
1,212 changes: 678 additions & 534 deletions Simulation.sln

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Push-Location (Join-Path $PSScriptRoot "src/Simulation/Simulators")
.\FindNuspecReferences.ps1
Pop-Location

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

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

if ($Env:ENABLE_QIRRUNTIME -eq "true") {
Push-Location (Join-Path $PSScriptRoot "src/QirRuntime")
.\install-prereqs.ps1
Expand Down
9 changes: 9 additions & 0 deletions build/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ $artifacts = @{
"Microsoft.Quantum.Development.Kit",
"Microsoft.Quantum.EntryPointDriver",
"Microsoft.Quantum.QSharp.Core",
"Microsoft.Quantum.Type1.Core",
"Microsoft.Quantum.Type2.Core",
"Microsoft.Quantum.Runtime.Core",
"Microsoft.Quantum.Simulators",
"Microsoft.Quantum.Simulators.Type1",
"Microsoft.Quantum.Simulators.Type2",
"Microsoft.Quantum.Xunit"
) | ForEach-Object { Join-Path $Env:NUGET_OUTDIR "$_.$Env:NUGET_VERSION.nupkg" };

Expand All @@ -37,9 +41,14 @@ $artifacts = @{
".\src\Simulation\Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Runtime.Core.dll",
".\src\Simulation\EntryPointDriver\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.EntryPointDriver.dll",
".\src\Simulation\QsharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll",
".\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\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"
) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) };

Expand Down
5 changes: 5 additions & 0 deletions build/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ Pack-Dotnet '../src/Azure/Azure.Quantum.Client/Microsoft.Azure.Quantum.Client.cs
Pack-One '../src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj' '-IncludeReferencedProjects'
Pack-Dotnet '../src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj'
Pack-Dotnet '../src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj'
Pack-Dotnet '../src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj'
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/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'
Pack-One '../src/Xunit/Microsoft.Quantum.Xunit.csproj'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<ItemGroup>
<ProjectReference Include="..\Core\Microsoft.Quantum.Runtime.Core.csproj" />
<ProjectReference Include="..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions src/Simulation/Common/OperationException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Runtime.CompilerServices;

#nullable enable

namespace Microsoft.Quantum.Simulation.Common
{
/// <summary>
/// A class that implements exception to be thrown when Operation is not supported.
/// </summary>
public class UnsupportedOperationException : PlatformNotSupportedException
{
public UnsupportedOperationException(string text = "",
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0)
: base($"{file}::{line}::[{member}]:{text}")
{
}
}

}
3 changes: 0 additions & 3 deletions src/Simulation/Common/Simulators.Dev.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

<ItemGroup>
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\Core\Microsoft.Quantum.Runtime.Core.csproj" />
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\Common\Microsoft.Quantum.Simulation.Common.csproj" IncludeInSimulatorPackage="true" />
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\QCTraceSimulator\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj" IncludeInSimulatorPackage="true" />
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj" Condition=" '$([MSBuild]::NormalizePath($(EnlistmentRoot)src\Simulation\Simulators))' != '$(MSBuildProjectDirectory)'" IncludeInSimulatorPackage="true" />
</ItemGroup>

<ItemGroup>
Expand Down
53 changes: 53 additions & 0 deletions src/Simulation/Common/Simulators.Impl.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<EnlistmentRoot>$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory)..\..\..\))</EnlistmentRoot>
</PropertyGroup>

<Import Project="AssemblyCommon.props" />
<Import Project="DebugSymbols.props" />
<Import Project="Simulators.Dev.props" />

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<CsharpGeneration>false</CsharpGeneration><!-- we will provide our own -->
</PropertyGroup>

<PropertyGroup>
<LanguageVersion>8.0</LanguageVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

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

<ItemGroup>
<Compile Include="$(EnlistmentRoot)src\Simulation\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
</ItemGroup>

<ItemGroup>
<None Include="$(EnlistmentRoot)src\Simulation\Native\win10\**\*">
<Link>runtimes\win-x64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
<None Include="$(EnlistmentRoot)src\Simulation\Native\osx\**\*">
<Link>runtimes\osx-x64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
<None Include="$(EnlistmentRoot)src\Simulation\Native\linux\**\*">
<Link>runtimes\linux-x64\native\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
</ItemGroup>

</Project>
34 changes: 34 additions & 0 deletions src/Simulation/Common/Simulators.Test.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<EnlistmentRoot>$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory)..\..\..\))</EnlistmentRoot>
</PropertyGroup>

<Import Project="AssemblyCommon.props" />
<Import Project="DebugSymbols.props" />
<Import Project="Simulators.Dev.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<CsharpGeneration>false</CsharpGeneration><!-- we will provide our own -->
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(EnlistmentRoot)src\Simulation\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(EnlistmentRoot)src\Simulation\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" IsQscReference="true" />
<ProjectReference Include="$(EnlistmentRoot)src\Xunit\Microsoft.Quantum.Xunit.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

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

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

Expand Down
1 change: 1 addition & 0 deletions src/Simulation/EntryPointDriver.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ let private compileCSharp (sources : string seq) =
"System.Runtime.Extensions"
"System.Runtime.Numerics"
"Microsoft.Quantum.EntryPointDriver"
"Microsoft.Quantum.QSharp.Foundation"
"Microsoft.Quantum.QSharp.Core"
"Microsoft.Quantum.QsDataStructures"
"Microsoft.Quantum.Runtime.Core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Core\Microsoft.Quantum.Runtime.Core.csproj" />
<ProjectReference Include="..\Simulators\Microsoft.Quantum.Simulators.csproj" />
<ProjectReference Include="..\..\Azure\Azure.Quantum.Client\Microsoft.Azure.Quantum.Client.csproj" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Simulation/Native/src/simulator/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern "C"
return Microsoft::Quantum::Simulator::get(id)->JointEnsembleProbability(bv, qv);
}

MICROSOFT_QUANTUM_DECL void InjectState(
MICROSOFT_QUANTUM_DECL bool InjectState(
_In_ unsigned sid,
_In_ unsigned n,
_In_reads_(n) unsigned* q,
Expand All @@ -61,7 +61,7 @@ extern "C"
}
std::vector<unsigned> qubits(q, q + n);

Microsoft::Quantum::Simulator::get(sid)->InjectState(qubits, amplitudes);
return Microsoft::Quantum::Simulator::get(sid)->InjectState(qubits, amplitudes);
}

MICROSOFT_QUANTUM_DECL void allocateQubit(_In_ unsigned id, _In_ unsigned q)
Expand Down
2 changes: 1 addition & 1 deletion src/Simulation/Native/src/simulator/capi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C"
_In_reads_(n) int* b,
_In_reads_(n) unsigned* q);

MICROSOFT_QUANTUM_DECL void InjectState(
MICROSOFT_QUANTUM_DECL bool InjectState(
_In_ unsigned sid,
_In_ unsigned n,
_In_reads_(n) unsigned* q, // The listed qubits must be unentangled and in state |0>
Expand Down
28 changes: 14 additions & 14 deletions src/Simulation/Native/src/simulator/local_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ TEST_CASE("permute_basis", "[local_test]")
const double amp = 1.0 / std::sqrt(5);
std::vector<ComplexType> amplitudes = {{amp, 0.0}, {amp, 0.0}, {amp, 0.0}, {0.0, 0.0},
{0.0, 0.0}, {0.0, 0.0}, {amp, 0.0}, {amp, 0.0}};
psi.inject_state({q0, q1, q2}, amplitudes);
REQUIRE(psi.inject_state({q0, q1, q2}, amplitudes));

SECTION("identity permutation")
{
Expand Down Expand Up @@ -453,7 +453,7 @@ TEST_CASE("permute_basis depends on the order of logical qubits (2)", "[local_te
// Inject state, which would allow us to easily check permutations. It's not a normalized state but for this
// test it doesn't matter.
std::vector<ComplexType> amplitudes = {{0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {3.0, 0.0}};
psi.inject_state({q0, q1}, amplitudes);
REQUIRE(psi.inject_state({q0, q1}, amplitudes));
// after the state injection, positions of the qubits are q0:0 and q1:1

SECTION("q0-q1 order (matches the current positions of the qubits in the standard basis)")
Expand Down Expand Up @@ -496,7 +496,7 @@ TEST_CASE("permute_basis depends on the order of logical qubits (3)", "[local_te
// test it doesn't matter.
std::vector<ComplexType> amplitudes = {{0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {3.0, 0.0},
{4.0, 0.0}, {5.0, 0.0}, {6.0, 0.0}, {7.0, 0.0}};
psi.inject_state({q0, q1, q2}, amplitudes);
REQUIRE(psi.inject_state({q0, q1, q2}, amplitudes));

SECTION("q0-q1-q2 order")
{
Expand Down Expand Up @@ -544,7 +544,7 @@ TEST_CASE("Inject total cat state", "[local_test]")
std::vector<ComplexType> amplitudes = {{amp, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {amp, 0.0}};
REQUIRE(amplitudes.size() == N);

sim.InjectState(qs, amplitudes);
REQUIRE(sim.InjectState(qs, amplitudes));

// undo the injected state back to |00>
sim.CX({qs[0]}, qs[1]);
Expand All @@ -571,13 +571,13 @@ TEST_CASE("Should fail to inject state if qubits aren't all |0>", "[local_test]"

// unentangled but not |0>
sim.H(qs[1]);
REQUIRE_THROWS(sim.InjectState(qs, amplitudes));
REQUIRE_THROWS(sim.InjectState({qs[0], qs[1]}, amplitudes_sub));
REQUIRE_FALSE(sim.InjectState(qs, amplitudes));
REQUIRE_FALSE(sim.InjectState({qs[0], qs[1]}, amplitudes_sub));

// entanglement doesn't make things any better
sim.CX({qs[1]}, qs[2]);
REQUIRE_THROWS(sim.InjectState(qs, amplitudes));
REQUIRE_THROWS(sim.InjectState({qs[0], qs[1]}, amplitudes_sub));
REQUIRE_FALSE(sim.InjectState(qs, amplitudes));
REQUIRE_FALSE(sim.InjectState({qs[0], qs[1]}, amplitudes_sub));
}

TEST_CASE("Inject total state on reordered qubits", "[local_test]")
Expand All @@ -599,7 +599,7 @@ TEST_CASE("Inject total state on reordered qubits", "[local_test]")

// Notice, that we are listing the qubits in order that doesn't match their allocation order. We are saying here,
// that InjectState should create Bell pair from qs[1] and qs[2]!
sim.InjectState({qs[1], qs[2], qs[0]}, amplitudes);
REQUIRE(sim.InjectState({qs[1], qs[2], qs[0]}, amplitudes));
REQUIRE((sim.isclassical(qs[0]) && !sim.M(qs[0])));

// undo the state change and check that the whole system is back to |000>
Expand Down Expand Up @@ -652,7 +652,7 @@ TEST_CASE("Inject state on two qubits out of three", "[local_test]")
sim.H(q0);
}

sim.InjectState({x, y}, amplitudes);
REQUIRE(sim.InjectState({x, y}, amplitudes));

// undo the state injection with quantum op and check that the qubits we injected state for are back to |0>
sim.H(x);
Expand Down Expand Up @@ -697,7 +697,7 @@ TEST_CASE("Perf of injecting equal superposition state", "[skip]") // local micr
std::vector<ComplexType> amplitudes(N, {amp, 0.0});

auto start = high_resolution_clock::now();
sim.InjectState(qs, amplitudes);
REQUIRE(sim.InjectState(qs, amplitudes));
sim.M(qs[0]); // to have the same overhead compared to preparation test case
std::cout << " Total state injection:\t";
std::cout << duration_cast<microseconds>(high_resolution_clock::now() - start).count();
Expand All @@ -712,7 +712,7 @@ TEST_CASE("Perf of injecting equal superposition state", "[skip]") // local micr
std::vector<ComplexType> amplitudes(N, {amp, 0.0});

auto start = std::chrono::high_resolution_clock::now();
sim.InjectState(qs, amplitudes);
REQUIRE(sim.InjectState(qs, amplitudes));
sim.H(q_last);
sim.M(qs[0]); // to have the same overhead compared to preparation test case
std::cout << " Partial state injection:\t";
Expand Down Expand Up @@ -761,7 +761,7 @@ TEST_CASE("Perf of injecting cat state", "[skip]") // local micro_benchmark
amplitudes[N - 1] = {amp, 0.0};

auto start = std::chrono::high_resolution_clock::now();
sim.InjectState(qs, amplitudes);
REQUIRE(sim.InjectState(qs, amplitudes));
sim.M(qs[0]); // to have the same overhead compared to preparation test case
std::cout << " Total cat state injection:\t";
std::cout << duration_cast<microseconds>(high_resolution_clock::now() - start).count();
Expand All @@ -778,7 +778,7 @@ TEST_CASE("Perf of injecting cat state", "[skip]") // local micro_benchmark
amplitudes[N - 1] = {amp, 0.0};

auto start = std::chrono::high_resolution_clock::now();
sim.InjectState(qs, amplitudes);
REQUIRE(sim.InjectState(qs, amplitudes));
sim.CX({qs[0]}, q_last);
sim.M(qs[0]); // to have the same overhead compared to preparation test case
std::cout << " Partial cat state injection:\t";
Expand Down
4 changes: 2 additions & 2 deletions src/Simulation/Native/src/simulator/simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class Simulator : public Microsoft::Quantum::Simulator::SimulatorInterface
return p;
}

void InjectState(const std::vector<logical_qubit_id>& qubits, const std::vector<ComplexType>& amplitudes)
bool InjectState(const std::vector<logical_qubit_id>& qubits, const std::vector<ComplexType>& amplitudes)
{
recursive_lock_type l(mutex());
psi.inject_state(qubits, amplitudes);
return psi.inject_state(qubits, amplitudes);
}

bool isclassical(logical_qubit_id q)
Expand Down
2 changes: 1 addition & 1 deletion src/Simulation/Native/src/simulator/simulatorinterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SimulatorInterface

virtual double JointEnsembleProbability(std::vector<Gates::Basis> bs, std::vector<unsigned> qs) = 0;

virtual void InjectState(
virtual bool InjectState(
const std::vector<logical_qubit_id>& qubits,
const std::vector<ComplexType>& amplitudes) = 0;

Expand Down
Loading