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
2 changes: 1 addition & 1 deletion src/AzureClient/AzureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private async Task<ExecutionResult> SubmitOrExecuteJobAsync(
IEntryPoint? entryPoint = null;
try
{
entryPoint = EntryPointGenerator.Generate(submissionContext.OperationName, ActiveTarget.TargetId, ActiveTarget.RuntimeCapabilities);
entryPoint = EntryPointGenerator.Generate(submissionContext.OperationName, ActiveTarget.TargetId, ActiveTarget.RuntimeCapability);
}
catch (UnsupportedOperationException)
{
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.20102104-beta" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.12.201017032-pull" />
<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
12 changes: 6 additions & 6 deletions src/AzureClient/AzureExecutionTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#nullable enable

using System;
using Microsoft.Quantum.QsCompiler.ReservedKeywords;
using Microsoft.Quantum.QsCompiler;

namespace Microsoft.Quantum.IQSharp.AzureClient
{
Expand All @@ -16,12 +16,12 @@ internal class AzureExecutionTarget

public virtual string PackageName => $"Microsoft.Quantum.Providers.{GetProvider(TargetId)}";

public AssemblyConstants.RuntimeCapabilities RuntimeCapabilities => GetProvider(TargetId) switch
public RuntimeCapability RuntimeCapability => GetProvider(TargetId) switch
{
AzureProvider.IonQ => AssemblyConstants.RuntimeCapabilities.QPRGen0,
AzureProvider.Honeywell => AssemblyConstants.RuntimeCapabilities.QPRGen1,
AzureProvider.QCI => AssemblyConstants.RuntimeCapabilities.QPRGen1,
_ => AssemblyConstants.RuntimeCapabilities.Unknown
AzureProvider.IonQ => RuntimeCapability.BasicQuantumFunctionality,
AzureProvider.Honeywell => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.QCI => RuntimeCapability.BasicMeasurementFeedback,
_ => RuntimeCapability.FullComputation
};

public static bool IsValid(string targetId) => GetProvider(targetId) != null;
Expand Down
10 changes: 5 additions & 5 deletions src/AzureClient/EntryPoint/EntryPointGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Runtime.Loader;
using Microsoft.Extensions.Logging;
using Microsoft.Quantum.IQSharp.Common;
using Microsoft.Quantum.QsCompiler.ReservedKeywords;
using Microsoft.Quantum.QsCompiler;
using Microsoft.Quantum.Simulation.Common;
using Microsoft.Quantum.Simulation.Core;

Expand Down Expand Up @@ -76,7 +76,7 @@ public EntryPointGenerator(
}

public IEntryPoint Generate(string operationName, string? executionTarget,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown)
RuntimeCapability? runtimeCapability = null)
{
Logger?.LogDebug($"Generating entry point: operationName={operationName}, executionTarget={executionTarget}");

Expand Down Expand Up @@ -105,7 +105,7 @@ public IEntryPoint Generate(string operationName, string? executionTarget,
logger,
Path.Combine(Workspace.CacheFolder, $"__entrypoint{project.CacheDllName}"),
executionTarget,
runtimeCapabilities));
runtimeCapability));
}
catch (Exception e)
{
Expand All @@ -131,7 +131,7 @@ public IEntryPoint Generate(string operationName, string? executionTarget,
{
Logger?.LogDebug($"{snippets.Length} items found in snippets. Compiling.");
SnippetsAssemblyInfo = Compiler.BuildSnippets(
snippets, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__snippets__.dll"), executionTarget, runtimeCapabilities);
snippets, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__snippets__.dll"), executionTarget, runtimeCapability);
if (SnippetsAssemblyInfo == null || logger.HasErrors)
{
Logger?.LogError($"Error compiling snippets.");
Expand All @@ -150,7 +150,7 @@ public IEntryPoint Generate(string operationName, string? executionTarget,
}

EntryPointAssemblyInfo = Compiler.BuildEntryPoint(
operationInfo, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__.dll"), executionTarget, runtimeCapabilities);
operationInfo, compilerMetadata, logger, Path.Combine(Workspace.CacheFolder, "__entrypoint__.dll"), executionTarget, runtimeCapability);
if (EntryPointAssemblyInfo == null || logger.HasErrors)
{
Logger?.LogError($"Error compiling entry point for operation {operationName}.");
Expand Down
7 changes: 2 additions & 5 deletions src/AzureClient/EntryPoint/IEntryPointGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

#nullable enable

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Quantum.QsCompiler.ReservedKeywords;
using Microsoft.Quantum.QsCompiler;

namespace Microsoft.Quantum.IQSharp.AzureClient
{
Expand Down Expand Up @@ -45,6 +42,6 @@ public interface IEntryPointGenerator
/// <param name="runtimeCapabilities">The runtime capabilities of the intended execution target.</param>
/// <returns>The generated entry point.</returns>
public IEntryPoint Generate(string operationName, string? executionTarget,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown);
RuntimeCapability? runtimeCapabilities = null);
}
}
21 changes: 10 additions & 11 deletions src/Core/Compiler/CompilerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Quantum.IQSharp.Common;
Expand Down Expand Up @@ -132,22 +131,22 @@ public IEnumerable<QsNamespaceElement> IdentifyElements(string source)
QSharpLogger? logger = null,
bool compileAsExecutable = false,
string? executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown)
RuntimeCapability? runtimeCapability = null)
{
var loadOptions = new CompilationLoader.Configuration
{
GenerateFunctorSupport = true,
IsExecutable = compileAsExecutable,
AssemblyConstants = new Dictionary<string, string> { [AssemblyConstants.ProcessorArchitecture] = executionTarget ?? string.Empty },
RuntimeCapabilities = runtimeCapabilities
RuntimeCapability = runtimeCapability ?? RuntimeCapability.FullComputation
};
var loaded = new CompilationLoader(_ => sources, _ => references, loadOptions, logger);
return loaded.CompilationOutput;
}

/// <inheritdoc/>
public AssemblyInfo? BuildEntryPoint(OperationInfo operation, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string? executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown)
RuntimeCapability? runtimeCapability = null)
{
var signature = operation.Header.PrintSignature();
var argumentTuple = SyntaxTreeToQsharp.ArgumentTuple(operation.Header.ArgumentTuple, type => type.ToString(), symbolsOnly: true);
Expand All @@ -164,7 +163,7 @@ public IEnumerable<QsNamespaceElement> IdentifyElements(string source)
}}";

var sources = new Dictionary<Uri, string>() {{ entryPointUri, entryPointSnippet }}.ToImmutableDictionary();
return BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: true, executionTarget, runtimeCapabilities);
return BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: true, executionTarget, runtimeCapability);
}

/// <summary>
Expand All @@ -173,7 +172,7 @@ public IEnumerable<QsNamespaceElement> IdentifyElements(string source)
/// with the same name as the snippet id.
/// </summary>
public AssemblyInfo? BuildSnippets(Snippet[] snippets, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string? executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown)
RuntimeCapability? runtimeCapability = null)
{
string openStatements = string.Join("", AutoOpenNamespaces.Select(
entry => string.IsNullOrEmpty(entry.Value)
Expand All @@ -193,7 +192,7 @@ string WrapInNamespace(Snippet s) =>
};

warningCodesToIgnore.ForEach(code => logger.WarningCodesToIgnore.Add(code));
var assembly = BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapabilities);
var assembly = BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapability);
warningCodesToIgnore.ForEach(code => logger.WarningCodesToIgnore.Remove(code));

return assembly;
Expand All @@ -203,23 +202,23 @@ string WrapInNamespace(Snippet s) =>
/// Builds the corresponding .net core assembly from the code in the given files.
/// </summary>
public AssemblyInfo? BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string? executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown)
RuntimeCapability? runtimeCapability = null)
{
var sources = ProjectManager.LoadSourceFiles(files, d => logger?.Log(d), ex => logger?.Log(ex));
return BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapabilities);
return BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapability);
}

/// <summary>
/// Builds the corresponding .net core assembly from the Q# syntax tree.
/// </summary>
private AssemblyInfo? BuildAssembly(ImmutableDictionary<Uri, string> sources, CompilerMetadata metadata, QSharpLogger logger, string dllName, bool compileAsExecutable, string? executionTarget,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities)
RuntimeCapability? runtimeCapability = null)
{
logger.LogDebug($"Compiling the following Q# files: {string.Join(",", sources.Keys.Select(f => f.LocalPath))}");

// Ignore any @EntryPoint() attributes found in libraries.
logger.WarningCodesToIgnore.Add(QsCompiler.Diagnostics.WarningCode.EntryPointInLibrary);
var qsCompilation = this.UpdateCompilation(sources, metadata.QsMetadatas, logger, compileAsExecutable, executionTarget, runtimeCapabilities);
var qsCompilation = this.UpdateCompilation(sources, metadata.QsMetadatas, logger, compileAsExecutable, executionTarget, runtimeCapability);
logger.WarningCodesToIgnore.Remove(QsCompiler.Diagnostics.WarningCode.EntryPointInLibrary);

if (logger.HasErrors || qsCompilation == null) return null;
Expand Down
7 changes: 4 additions & 3 deletions src/Core/Compiler/ICompilerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Quantum.IQSharp.Common;
using Microsoft.Quantum.QsCompiler;
using Microsoft.Quantum.QsCompiler.ReservedKeywords;
using Microsoft.Quantum.QsCompiler.SyntaxTree;

Expand All @@ -25,19 +26,19 @@ public interface ICompilerService
/// by the provided <see cref="OperationInfo"/> object.
/// </summary>
AssemblyInfo BuildEntryPoint(OperationInfo operation, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown);
RuntimeCapability runtimeCapability = null);

/// <summary>
/// Builds the corresponding .net core assembly from the code in the given Q# Snippets.
/// </summary>
AssemblyInfo BuildSnippets(Snippet[] snippets, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown);
RuntimeCapability runtimeCapabilities = null);

/// <summary>
/// Builds the corresponding .net core assembly from the code in the given files.
/// </summary>
AssemblyInfo BuildFiles(string[] files, CompilerMetadata metadatas, QSharpLogger logger, string dllName, string executionTarget = null,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities = AssemblyConstants.RuntimeCapabilities.Unknown);
RuntimeCapability runtimeCapability = null);

/// <summary>
/// Returns the names of all declared callables and types.
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.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.12.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.201017032-pull" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.12.201017032-pull" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.201017032-pull" />
<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.12.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.201017032-pull" />
</ItemGroup>

</Project>
9 changes: 4 additions & 5 deletions src/Jupyter/Visualization/StateDisplayOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.Jupyter.Core.Protocol;
using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;
using Newtonsoft.Json;

namespace Microsoft.Quantum.IQSharp.Jupyter
{
Expand Down Expand Up @@ -139,11 +138,11 @@ internal static QVoid DumpToChannel(QuantumSimulator sim, IChannel channel, ICon
}

/// <summary>
/// An implementation of <see cref="Microsoft.Quantum.Diagnostics.DumpMachine{__T__}" />
/// An implementation of <see cref="Diagnostics.DumpMachine{__T__}" />
/// that dumps the state of its target machine to a Jupyter-displayable
/// object.
/// </summary>
public class JupyterDumpMachine<T> : Microsoft.Quantum.Simulation.Simulators.QuantumSimulator.QsimDumpMachine<T>
public class JupyterDumpMachine<T> : QuantumSimulator.QsimDumpMachine<T>
{
private QuantumSimulator Simulator { get; }
internal IConfigurationSource? ConfigurationSource = null;
Expand Down Expand Up @@ -182,11 +181,11 @@ public JupyterDumpMachine(QuantumSimulator m) : base(m)
}

/// <summary>
/// An implementation of <see cref="Microsoft.Quantum.Diagnostics.DumpRegister{__T__}" />
/// An implementation of <see cref="Diagnostics.DumpRegister{__T__}" />
/// that dumps the state of its target machine to a Jupyter-displayable
/// object.
/// </summary>
public class JupyterDumpRegister<T> : Microsoft.Quantum.Simulation.Simulators.QuantumSimulator.QSimDumpRegister<T>
public class JupyterDumpRegister<T> : QuantumSimulator.QSimDumpRegister<T>
{
private QuantumSimulator Simulator { get; }
internal IConfigurationSource? ConfigurationSource = null;
Expand Down
4 changes: 2 additions & 2 deletions src/Kernel/Magic/DebugMagic.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable
Expand Down Expand Up @@ -60,7 +60,7 @@ public DebugMagic(
ILogger<DebugMagic>? logger
) : base(
"debug",
new Documentation
new Microsoft.Jupyter.Core.Documentation
{
Summary = "Steps through the execution of a given Q# operation or function.",
Description = $@"
Expand Down
4 changes: 2 additions & 2 deletions src/MockLibraries/Mock.Chemistry/Mock.Chemistry.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20102104-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.201017032-pull">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.201017032-pull" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/MockLibraries/Mock.Standard/Mock.Standard.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20102104-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.201017032-pull">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.201017032-pull" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Tests/IQsharpEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static async Task<string> AssertEstimate(IQSharpEngine engine, string sni
PrintResult(response, channel);
Assert.AreEqual(ExecuteStatus.Ok, response.Status);
Assert.IsNotNull(result);
Assert.AreEqual(8, result.Rows.Count);
Assert.AreEqual(9, result.Rows.Count);
var keys = result.Rows.Cast<DataRow>().Select(row => row.ItemArray[0]).ToList();
CollectionAssert.Contains(keys, "T");
CollectionAssert.Contains(keys, "CNOT");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20102104-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.201017032-pull">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20102104-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.201017032-pull">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20102104-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.201017032-pull">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand All @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.12.20102104-beta" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.12.201017032-pull" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/WorkspaceControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task EstimateCCNOTDriver()
var response = await controller.Estimate("Tests.qss.CCNOTDriver", args, messages.Add);

Assert.AreEqual(0, messages.Count);
Assert.AreEqual(8, response.Count);
Assert.AreEqual(9, response.Count);
Assert.AreEqual(10.0, response["CNOT"]);
Assert.AreEqual(7.0, response["T"]);
Assert.AreEqual(3.0, response["Width"]);
Expand Down
Loading