Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #619 from microsoft/sccarda/mergeInFromMain
Browse files Browse the repository at this point in the history
Merge in from main
  • Loading branch information
ScottCarda-MS authored Mar 21, 2022
2 parents 28d48e7 + ffdb2d9 commit 98e26ec
Show file tree
Hide file tree
Showing 35 changed files with 265 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Tool/bin/Debug/netcoreapp3.1/Microsoft.Quantum.IQSharp.dll",
"program": "${workspaceFolder}/src/Tool/bin/Debug/net6.0/Microsoft.Quantum.IQSharp.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Tool",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
Expand Down
4 changes: 2 additions & 2 deletions build/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ $artifacts = @{
"./src/ExecutionPathTracer/bin/$Env:BUILD_CONFIGURATION/netstandard2.1/Microsoft.Quantum.IQSharp.ExecutionPathTracer.dll",
"./src/Jupyter/bin/$Env:BUILD_CONFIGURATION/netstandard2.1/Microsoft.Quantum.IQSharp.Jupyter.dll",
"./src/Kernel/bin/$Env:BUILD_CONFIGURATION/netstandard2.1/Microsoft.Quantum.IQSharp.Kernel.dll",
"./src/Tool/bin/$Env:BUILD_CONFIGURATION/netcoreapp3.1/Microsoft.Quantum.IQSharp.dll",
"./src/Web/bin/$Env:BUILD_CONFIGURATION/netcoreapp3.1/Microsoft.Quantum.IQSharp.Web.dll"
"./src/Tool/bin/$Env:BUILD_CONFIGURATION/net6.0/Microsoft.Quantum.IQSharp.dll",
"./src/Web/bin/$Env:BUILD_CONFIGURATION/net6.0/Microsoft.Quantum.IQSharp.Web.dll"
) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) };
}

Expand Down
4 changes: 2 additions & 2 deletions build/steps-selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ steps:
workingDirectory: '$(System.DefaultWorkingDirectory)/build'

- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.100'
displayName: 'Use .NET Core SDK 6.0.100'
inputs:
packageType: sdk
version: '3.1.100'
version: '6.0.x'

- pwsh: ./bootstrap.ps1
displayName: "Bootstrap"
Expand Down
4 changes: 2 additions & 2 deletions build/steps-selfcontained.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ steps:
displayName: "Copy build artifacts to IQ# working directory"

- task: UseDotNet@2
displayName: 'Use .NET Core SDK 3.1.100'
displayName: 'Use .NET Core SDK 6.0.100'
inputs:
packageType: sdk
version: '3.1.100'
version: '6.0.x'

##
# Pack
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.100",
"version": "6.0.100",
"rollForward": "latestMinor"
}
}
6 changes: 4 additions & 2 deletions images/iqsharp-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ ENV NUGET_XMLDOC_MODE=skip \
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true

# Now that we have all the dependencies in place, we install the .NET Core SDK itself.
# Notice that we're installing the SDK for both .NET Core 3.1 as well as .NET 6.0 for compatibility.
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg && \
mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ && \
wget -q https://packages.microsoft.com/config/debian/9/prod.list && \
mv prod.list /etc/apt/sources.list.d/microsoft-prod.list && \
chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \
chown root:root /etc/apt/sources.list.d/microsoft-prod.list && \
apt-get -y update && \
apt-get -y install dotnet-sdk-3.1=3.1.416-1 && \
apt-get -y install dotnet-sdk-3.1=3.1.416-1 dotnet-sdk-6.0 && \
apt-get -y install procps && \
apt-get clean && rm -rf /var/lib/apt/lists/

# Install prerequisites needed for integration with Live Share and VS Online.
Expand Down Expand Up @@ -128,7 +130,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.22.191200-beta" && \
RUN dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.23.198514-beta" && \
dotnet tool install \
--global \
Microsoft.Quantum.IQSharp \
Expand Down
2 changes: 1 addition & 1 deletion src/AzureClient/AzureClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Azure.Quantum.Jobs" Version="1.0.0-beta.3" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.22.186614-beta" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.23.198514-beta" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
<PackageReference Include="System.Reactive" Version="4.3.2" />
Expand Down
46 changes: 37 additions & 9 deletions src/AzureClient/AzureExecutionTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@

namespace Microsoft.Quantum.IQSharp.AzureClient
{
internal enum AzureProvider { IonQ, Honeywell, QCI, Mock }
internal enum AzureProvider
{
IonQ,
Quantinuum,
// NB: This provider name is deprecated, but may exist in older
// workspaces and should still be supported.
Honeywell,
QCI,
Mock
}

internal class AzureExecutionTarget
{
Expand All @@ -21,14 +30,23 @@ protected AzureExecutionTarget(string? targetId)

public string? TargetId { get; }

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

AzureProvider.IonQ => "Microsoft.Quantum.Providers.IonQ",
AzureProvider.Quantinuum => "Microsoft.Quantum.Providers.Honeywell",
AzureProvider.Honeywell => "Microsoft.Quantum.Providers.Honeywell",
AzureProvider.QCI => "Microsoft.Quantum.Providers.QCI",
_ => $"Microsoft.Quantum.Providers.{GetProvider(TargetId)}"
};

public RuntimeCapability RuntimeCapability => GetProvider(TargetId) switch
{
AzureProvider.IonQ => RuntimeCapability.BasicQuantumFunctionality,
AzureProvider.Honeywell => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.QCI => RuntimeCapability.BasicMeasurementFeedback,
_ => RuntimeCapability.FullComputation
AzureProvider.IonQ => RuntimeCapability.BasicQuantumFunctionality,
AzureProvider.Quantinuum => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.Honeywell => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.QCI => RuntimeCapability.BasicMeasurementFeedback,
_ => RuntimeCapability.FullComputation
};

/// <summary>
Expand All @@ -50,7 +68,13 @@ protected AzureExecutionTarget(string? targetId)
/// <summary>
/// It creates the AzureExecutionTarget instance for the given targetId.
/// </summary>
public static AzureExecutionTarget? Create(string? targetId) => GetProvider(targetId) is null
/// <returns>
/// An instance of <see cref="AzureExecutionTarget"/> if
/// <param name="targetId" /> describes a target for a valid
/// provider, and <c>null</c> otherwise.
/// </returns>
public static AzureExecutionTarget? Create(string? targetId) =>
GetProvider(targetId) is null
? null
: new AzureExecutionTarget(targetId);

Expand All @@ -59,10 +83,14 @@ protected AzureExecutionTarget(string? targetId)
/// Gets the Azure Quantum provider corresponding to the given execution target.
/// </summary>
/// <param name="targetId">The Azure Quantum execution target ID.</param>
/// <returns>The <see cref="AzureProvider"/> enum value representing the provider.</returns>
/// <returns>
/// The <see cref="AzureProvider"/> enum value representing the
/// provider, or <c>null</c> if <paramref name="targetId"/> does
/// not describe a valid provider.
/// </returns>
/// <remarks>
/// Valid target IDs are structured as "provider.target".
/// For example, "ionq.simulator" or "honeywell.qpu".
/// For example, "ionq.simulator" or "quantinuum.qpu".
/// </remarks>
protected static AzureProvider? GetProvider(string? targetId)
{
Expand Down
2 changes: 2 additions & 0 deletions src/AzureClient/Mocks/MockTargetStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public MockTargetStatus(string id) : base()
}

public override string TargetId { get; }

public override string ToString() => $"MockTargetStatus {{ TargetId = \"{TargetId}\" }}";
}
}
2 changes: 1 addition & 1 deletion src/AzureClient/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class Resources
"No execution target has been configured for Azure Quantum job submission.";

public const string AzureClientErrorInvalidTarget =
"The specified execution target is not valid for Q# job submission in the current Azure Quantum workspace.";
"The specified target is not enabled in this workspace. Please make sure the target name is valid and that the associated provider is added to your workspace. To add a provider to your quantum workspace in the Azure Portal, see https://aka.ms/AQ/Docs/AddProvider";

public const string AzureClientErrorJobNotFound =
"No job with the given ID was found in the current Azure Quantum workspace.";
Expand Down
9 changes: 5 additions & 4 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
<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.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.CSharpGeneration" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.QSharp.Core" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.23.198514-beta" />
<PackageReference Include="Microsoft.Quantum.CSharpGeneration" Version="0.23.198514-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.23.198514-beta" />
<PackageReference Include="Microsoft.Quantum.QSharp.Core" Version="0.23.198514-beta" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="NuGet.Resolver" Version="5.1.0" />
<PackageReference Include="System.DirectoryServices.Protocols" Version="5.0.1" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>

Expand Down
11 changes: 6 additions & 5 deletions src/Core/Loggers/QsharpLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,16 @@ public static LogLevel MapLevel(LSP.DiagnosticSeverity original) =>

public IEnumerable<string> ErrorIds =>
Logs
.Where(m => m.Severity == VisualStudio.LanguageServer.Protocol.DiagnosticSeverity.Error)
.Select(m => m.Code);
.Where(m => m.Severity == VisualStudio.LanguageServer.Protocol.DiagnosticSeverity.Error && m.Code?.Second != null)
.Select(m => m.Code?.Second);

protected override void Print(LSP.Diagnostic m)
{
if (m.IsError() && ErrorCodesToIgnore.Any(code => m.Code == QsCompiler.CompilationBuilder.Errors.Code(code))) return;
if (m.IsWarning() && WarningCodesToIgnore.Any(code => m.Code == QsCompiler.CompilationBuilder.Warnings.Code(code))) return;
string diagnosticCode = m.Code?.Second ?? "";
if (m.IsError() && ErrorCodesToIgnore.Any(code => diagnosticCode == QsCompiler.CompilationBuilder.Errors.Code(code))) return;
if (m.IsWarning() && WarningCodesToIgnore.Any(code => diagnosticCode == QsCompiler.CompilationBuilder.Warnings.Code(code))) return;

Logger?.Log(MapLevel(m.Severity), "{Code} ({Source}:{Range}): {Message}", m.Code, m.Source, m.Range, m.Message);
Logger?.Log(MapLevel(m.Severity), "{Code} ({Source}:{Range}): {Message}", diagnosticCode, m.Source, m.Range, m.Message);
Logs.Add(m);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Core/Platform/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ internal static class PlatformUtils
{
FileName = "/bin/bash",
Arguments = "-c \"free --total --bytes\"",
RedirectStandardOutput = true
RedirectStandardOutput = true,
RedirectStandardError = true,
};
using var proc = Process.Start(processStartInfo);
await foreach (var line in proc.StandardOutput.ReadAllLinesAsync())
Expand Down
8 changes: 4 additions & 4 deletions src/Core/References/NugetPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Settings : Workspace.Settings
}

// The framework used to find packages.
public static NuGetFramework NETCOREAPP3_1 = NuGetFramework.ParseFolder("netcoreapp3.1");
public static NuGetFramework NETSTANDARD2_1 = NuGetFramework.ParseFolder("netstandard2.1");

// Nuget's logger.
public NuGetLogger Logger { get; }
Expand Down Expand Up @@ -311,7 +311,7 @@ string[] CheckOnFramework(NuGetFramework framework)
return files.ToArray();
}

var names = CheckOnFramework(NETCOREAPP3_1);
var names = CheckOnFramework(NETSTANDARD2_1);

Assembly? LoadAssembly(string path)
{
Expand Down Expand Up @@ -409,7 +409,7 @@ public IEnumerable<SourcePackageDependencyInfo> ResolveDependencyGraph(PackageId
dependencyBehavior: DependencyBehavior.Lowest,
targetIds: new[] { pkgId.Id },
requiredPackageIds: Enumerable.Empty<string>(),
packagesConfig: Items.Select(p => new PackageReference(p, NETCOREAPP3_1, true)),
packagesConfig: Items.Select(p => new PackageReference(p, NETSTANDARD2_1, true)),
preferredVersions: Enumerable.Empty<PackageIdentity>(),
availablePackages: AvailablePackages,
packageSources: Repositories.Select(s => s.PackageSource),
Expand Down Expand Up @@ -476,7 +476,7 @@ internal async Task FindDependencies(
var dependencyInfoResource = await repo.GetResourceAsync<DependencyInfoResource>();
if (dependencyInfoResource == null) continue;

var dependencyInfo = await dependencyInfoResource.ResolvePackage(package, NETCOREAPP3_1, context, this.Logger, CancellationToken.None);
var dependencyInfo = await dependencyInfoResource.ResolvePackage(package, NETSTANDARD2_1, context, this.Logger, CancellationToken.None);
if (dependencyInfo == null) continue;

AvailablePackages.Add(dependencyInfo);
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.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.23.198514-beta" />
</ItemGroup>

</Project>
30 changes: 23 additions & 7 deletions src/Jupyter/Magic/Resolution/MagicResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public class MagicSymbolResolver : IMagicSymbolResolver
.ToImmutableHashSet();

private readonly List<AssemblyInfo> kernelAssemblies = new List<AssemblyInfo>();
private Dictionary<string, MagicSymbol[]> cache;
private readonly Dictionary<string, MagicSymbol[]> assemblySymbolCache;
private readonly Dictionary<string, MagicSymbol> resolutionCache;
private IServiceProvider services;
private IReferences references;
private IWorkspace workspace;
Expand All @@ -67,14 +68,15 @@ public class MagicSymbolResolver : IMagicSymbolResolver
/// </summary>
public MagicSymbolResolver(IServiceProvider services, ILogger<MagicSymbolResolver> logger, IEventService eventService)
{
this.cache = new Dictionary<string, MagicSymbol[]>();
this.assemblySymbolCache = new Dictionary<string, MagicSymbol[]>();
this.resolutionCache = new Dictionary<string, MagicSymbol>();
this.logger = logger;

this.services = services;
this.references = services.GetService<IReferences>();
this.workspace = services.GetService<IWorkspace>();

// Add the assmebly containing this type to the resolver.
// Add the assembly containing this type to the resolver.
this.AddKernelAssembly<MagicSymbolResolver>();

eventService?.TriggerServiceInitialized<IMagicSymbolResolver>(this);
Expand Down Expand Up @@ -116,7 +118,17 @@ private IEnumerable<AssemblyInfo> RelevantAssemblies()
/// </remarks>
public MagicSymbol? Resolve(string symbolName)
{
if (symbolName == null || !symbolName.TrimStart().StartsWith("%")) return null;
if (symbolName == null || !symbolName.TrimStart().StartsWith("%"))
{
return null;
}
lock (resolutionCache)
{
if (resolutionCache.TryGetValue(symbolName, out var cachedSymbol))
{
return cachedSymbol;
}
}

this.logger.LogDebug($"Looking for magic {symbolName}");

Expand All @@ -125,6 +137,10 @@ private IEnumerable<AssemblyInfo> RelevantAssemblies()
if (symbolName == magic.Name)
{
this.logger.LogDebug($"Using magic {magic.Name}");
lock (resolutionCache)
{
resolutionCache[symbolName] = magic;
}
return magic;
}
}
Expand All @@ -149,9 +165,9 @@ public IEnumerable<MagicSymbol> FindMagic(AssemblyInfo assm)
return result;
}

lock (cache)
lock (assemblySymbolCache)
{
if (cache.TryGetValue(assm.Assembly.FullName, out result))
if (assemblySymbolCache.TryGetValue(assm.Assembly.FullName, out result))
{
return result;
}
Expand Down Expand Up @@ -215,7 +231,7 @@ public IEnumerable<MagicSymbol> FindMagic(AssemblyInfo assm)

logger.LogInformation("Took {Elapsed} to scan {Assembly} for magic symbols.", stopwatch.Elapsed, assm.Assembly.FullName);
result = allMagic.ToArray();
cache[assm.Assembly.FullName] = result;
assemblySymbolCache[assm.Assembly.FullName] = result;
}

return result;
Expand Down
Loading

0 comments on commit 98e26ec

Please sign in to comment.