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
Show all changes
49 commits
Select commit Hold shift + click to select a range
d143ae5
Add %simulate_noise and %noise_model magic commands.
cgranade Feb 11, 2021
b7c2f3a
Guard new magic behind experimental.
cgranade Feb 11, 2021
f09d591
Fix to noise model source, use noise_model::ideal().
cgranade Feb 12, 2021
c93a872
Bump version and begin adding more documentation.
cgranade Feb 12, 2021
4abef44
Add simulate_noise to qsharp-core.
cgranade Feb 13, 2021
7590111
Bump version and fix some syntax errors.
cgranade Feb 13, 2021
f09e92c
Add to noise model encoder.
cgranade Feb 18, 2021
b3cd5ff
Support setting opensim capacity through %config.
cgranade Feb 18, 2021
77206c9
Started adding integration tests for experimental opensim.
cgranade Feb 18, 2021
6ea4ee1
Fixed tests.
cgranade Feb 19, 2021
2f4996d
Bump version and register display encoders.
cgranade Feb 19, 2021
1fb0ad5
Fix some display issues in noise model encoder.
cgranade Feb 19, 2021
3473ca9
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Feb 22, 2021
c13dc83
fixing a bug in json noise model import (#412)
crazy4pi314 Feb 25, 2021
681c91a
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Mar 18, 2021
9cdeb77
Merge branch 'cgranade/experimental/opensim' of https://github.com/mi…
cgranade Mar 18, 2021
75e4a3b
Update to 0.15.210324351-alpha.
cgranade Mar 18, 2021
3ea3f76
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Mar 23, 2021
39b9ebc
Update to 0.15.210324357-alpha.
cgranade Mar 23, 2021
076e146
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Apr 14, 2021
b738460
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Jun 2, 2021
08d825b
Capture more information in assertion logs.
cgranade Jun 3, 2021
7ee0713
Adapt to changes in noise model serialization API.
cgranade Jun 3, 2021
e572354
One more fix to serialization support.
cgranade Jun 3, 2021
3ab1342
Use alpha from https://github.com/microsoft/qsharp-runtime/pull/709.
cgranade Jun 4, 2021
bb357cc
Support more processes and instruments in display encoders.
cgranade Jun 4, 2021
f864f81
Allow Python client to inform kernel about experimental features.
cgranade Jun 4, 2021
c15d777
Allow clients to override kernel name used to communicate with IQ#.
cgranade Jun 4, 2021
2102c29
Fix serialization bug.
cgranade Jun 4, 2021
580eb0a
Allow loading noise models by name.
cgranade Jun 4, 2021
f97f608
Revert accidental changes.
cgranade Jun 4, 2021
dbcb869
Allow getting/setting noise models by name, add docs.
cgranade Jun 5, 2021
22e7d73
Expose representations and named noise models.
cgranade Jun 7, 2021
104bcfb
Update package versions to latest alpha build.
cgranade Jun 7, 2021
1490e94
Update to latest build.
cgranade Jun 8, 2021
ace7b9a
Improve visualization and serialization.
cgranade Jun 8, 2021
cdce975
Update to latest build.
cgranade Jun 8, 2021
19cd817
Add Python magics, expose experimental build info to Python.
cgranade Jun 9, 2021
2035f01
Display encoder for sparse stabilizer states.
cgranade Jun 9, 2021
11b527e
Build info as a magic command.
cgranade Jun 9, 2021
4a1853d
Update to latest build.
cgranade Jun 9, 2021
ce6d5dd
Fix bug in group presentations.
cgranade Jun 9, 2021
821f477
Expose build info.
cgranade Jun 9, 2021
40df0f4
Fixed bug in mixed pauli process serialization.
cgranade Jun 9, 2021
fa37ae7
Update to latest build.
cgranade Jun 9, 2021
2d4114e
One more slight encoder fix.
cgranade Jun 9, 2021
cc52fb0
Move IQ# build to latest version of Ubuntu.
cgranade Jun 11, 2021
a387935
Trivial change to invalidate builds.
cgranade Jun 12, 2021
6bec1c0
Use -any.whl to block Windows-specific wheels on Linux images.
cgranade Jun 14, 2021
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
2 changes: 2 additions & 0 deletions build/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ variables:

jobs:
- job: "iqsharp"
pool:
vmImage: 'ubuntu-latest'
steps:
- template: steps.yml
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
Expand Down
4 changes: 3 additions & 1 deletion images/iqsharp-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ RUN mkdir -p ${HOME}/.nuget/NuGet && \
cat ${HOME}/.nuget/NuGet/NuGet.Config
# Add Python and NuGet packages from the build context
ADD nugets/*.nupkg ${LOCAL_PACKAGES}/nugets/
ADD wheels/*.whl ${LOCAL_PACKAGES}/wheels/
# When adding wheels, use *-any.whl to make sure that platform-specific wheels
# are not incorrectly added to the Docker image.
ADD wheels/*-any.whl ${LOCAL_PACKAGES}/wheels/
# Give the notebook user ownership over the packages and config copied from
# the context.
RUN chown ${USER} -R ${LOCAL_PACKAGES}/ && \
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
<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.16.2105140472" />
<PackageReference Include="Microsoft.Quantum.CSharpGeneration" Version="0.16.2105140472" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.16.2105140472" />
<PackageReference Include="Microsoft.Quantum.QSharp.Core" Version="0.16.2105140472" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.17.210627752-alpha" />
<PackageReference Include="Microsoft.Quantum.CSharpGeneration" Version="0.17.210627752-alpha" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.17.210627752-alpha" />
<PackageReference Include="Microsoft.Quantum.QSharp.Core" Version="0.17.210627752-alpha" />
<PackageReference Include="NuGet.Resolver" Version="5.1.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ExecutionPathTracer/ExecutionPathTracer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.16.2105140472" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.17.210627752-alpha" />
</ItemGroup>

</Project>
21 changes: 21 additions & 0 deletions src/Jupyter/ConfigurationSource/IConfigurationSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Microsoft.Quantum.Experimental;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -129,5 +130,25 @@ public T GetOptionOrDefault<T>(string optionName, T defaultValue) =>
/// </summary>
public TraceVisualizationStyle TraceVisualizationStyle =>
GetOptionOrDefault("trace.style", TraceVisualizationStyle.Default);

/// <summary>
/// Specifies the number of qubits that the experimental simulators
/// support for use in running Q# programs.
/// </summary>
public uint ExperimentalSimulatorCapacity =>
GetOptionOrDefault<uint>("experimental.simulators.nQubits", 3);

/// <summary>
/// Specifies the representation to use for the initial state
/// when simulating Q# programs with experimental simulators.
/// </summary>
public string ExperimentalSimulatorRepresentation =>
GetOptionOrDefault<string>("experimental.simulators.representation", "mixed");

/// <summary>
/// Specifies the format used in dumping stabilizer states.
/// <summary>
public StabilizerStateVisualizationStyle ExperimentalSimulatorStabilizerStateVisualizationStyle =>
GetOptionOrDefault<StabilizerStateVisualizationStyle>("experimental.simulators.stabilizerStateStyle", StabilizerStateVisualizationStyle.MatrixWithDestabilizers);
}
}
77 changes: 50 additions & 27 deletions src/Jupyter/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Jupyter.Core;
using Microsoft.Quantum.Simulation.Common;
using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;
using Newtonsoft.Json;
using NumSharp;

namespace Microsoft.Quantum.IQSharp.Jupyter
{
Expand Down Expand Up @@ -166,33 +168,6 @@ public static T WithStackTraceDisplay<T>(this T simulator, IChannel channel)
return simulator;
}

/// <summary>
/// Removes common indents from each line in a string,
/// similarly to Python's <c>textwrap.dedent()</c> function.
/// </summary>
public static string Dedent(this string text)
{
// First, start by finding the length of common indents,
// disregarding lines that are only whitespace.
var leadingWhitespaceRegex = new Regex(@"^[ \t]*");
var minWhitespace = int.MaxValue;
foreach (var line in text.Split("\n"))
{
if (!string.IsNullOrWhiteSpace(line))
{
var match = leadingWhitespaceRegex.Match(line);
minWhitespace = match.Success
? System.Math.Min(minWhitespace, match.Value.Length)
: minWhitespace = 0;
}
}

// We can use that to build a new regex that strips
// out common indenting.
var leftTrimRegex = new Regex(@$"^[ \t]{{{minWhitespace}}}", RegexOptions.Multiline);
return leftTrimRegex.Replace(text, "");
}

/// <summary>
/// Retrieves and JSON-decodes the value for the given parameter name.
/// </summary>
Expand Down Expand Up @@ -275,5 +250,53 @@ public static T DecodeParameter<T>(this Dictionary<string, string> parameters, s
}
return JsonConvert.DeserializeObject(parameterValue, type) ?? defaultValue;
}

internal static string AsLaTeXMatrixOfComplex(this NDArray array) =>
// NB: Assumes 𝑛 × 𝑛 × 2 array, where the trailing index is
// [real, imag].
// TODO: Consolidate with logic at:
// https://github.com/microsoft/QuantumLibraries/blob/505fc27383c9914c3e1f60fb63d0acfe60b11956/Visualization/src/DisplayableUnitaryEncoders.cs#L43
string.Join(
"\\\\\n",
Enumerable
.Range(0, array.Shape[0])
.Select(
idxRow => string.Join(" & ",
Enumerable
.Range(0, array.Shape[1])
.Select(
idxCol => $"{array[idxRow, idxCol, 0]} + {array[idxRow, idxCol, 1]} i"
)
)
)
);

internal static IEnumerable<NDArray> IterateOverLeftmostIndex(this NDArray array)
{
foreach (var idx in Enumerable.Range(0, array.shape[0]))
{
yield return array[idx, Slice.Ellipsis];
}
}

internal static string AsTextMatrixOfComplex(this NDArray array, string rowSep = "\n") =>
// NB: Assumes 𝑛 × 𝑛 × 2 array, where the trailing index is
// [real, imag].
// TODO: Consolidate with logic at:
// https://github.com/microsoft/QuantumLibraries/blob/505fc27383c9914c3e1f60fb63d0acfe60b11956/Visualization/src/DisplayableUnitaryEncoders.cs#L43
"[" + rowSep + string.Join(
rowSep,
Enumerable
.Range(0, array.Shape[0])
.Select(
idxRow => "[" + string.Join(", ",
Enumerable
.Range(0, array.Shape[1])
.Select(
idxCol => $"{array[idxRow, idxCol, 0]} + {array[idxRow, idxCol, 1]} i"
)
) + "]"
)
) + rowSep + "]";
}
}
20 changes: 20 additions & 0 deletions src/Jupyter/NoiseModelSource/INoiseModelSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation
// Licensed under the MIT License.

#nullable enable

using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Microsoft.Quantum.Experimental
{

public interface INoiseModelSource
{
NoiseModel NoiseModel { get; set; }
}

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

#nullable enable

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Microsoft.Quantum.Experimental
{

public class NoiseModelSource : INoiseModelSource
{
public NoiseModel NoiseModel { get; set; } =
NoiseModel.TryGetByName("ideal", out var ideal)
? ideal
: throw new Exception("Could not load ideal noise model.");
}

}
Loading