This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Support several parameters for IQ# Azure Quantum job execution #161
Merged
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
89282df
Updates to IQ# syntax highlighting
rmshaffer f53eb9c
Validate targets and load provider packages
rmshaffer 75a8e35
Update Python interface for Azure commands
rmshaffer 1787ea4
Merge branch 'feature/azure-client' into rmshaffer/azure-targets
rmshaffer 52098e6
Simplify AzureExecutionTarget class
rmshaffer 53fd8e9
Generate EntryPoint and compile into new assembly
rmshaffer a33a2c9
Changes for JobNotCompleted case
rmshaffer e47c9df
Merge branch 'rmshaffer/azure-targets' into rmshaffer/azure-entrypoint
rmshaffer 4449040
Refactor entry point code into new classes
rmshaffer 6f3a6fe
Use correct input and output types
rmshaffer d47fddd
Simplify property syntax
5215155
Add simple tests for AzureExecutionTarget class
rmshaffer eeb4b11
Merge branch 'rmshaffer/azure-targets' into rmshaffer/azure-entrypoint
rmshaffer 5e62413
Recompile everything for specified execution target
rmshaffer 26a79ea
Add tests and error handling
rmshaffer 69a4fe6
Improve variable names
rmshaffer c63a006
Add status message while loading provider package
rmshaffer 1c7d83f
Merge branch 'feature/azure-client' into rmshaffer/azure-targets
rmshaffer cbdd00e
Merge branch 'rmshaffer/azure-targets' into rmshaffer/azure-entrypoint
rmshaffer 944cec0
Merge branch 'feature/azure-client' into rmshaffer/azure-targets
rmshaffer 12c7e12
Merge branch 'rmshaffer/azure-targets' into rmshaffer/azure-entrypoint
rmshaffer b8e680b
Merge branch 'feature/azure-client' into rmshaffer/azure-targets
rmshaffer 126f43b
Merge branch 'rmshaffer/azure-targets' into rmshaffer/azure-entrypoint
rmshaffer 43c07ae
Add documentation to AzureExecutionTarget.GetProvider
rmshaffer 2552632
Merge branch 'feature/azure-client' into rmshaffer/azure-targets
rmshaffer 4bf71db
Merge branch 'rmshaffer/azure-targets' into rmshaffer/azure-entrypoint
rmshaffer 52c481d
Extend tests to call EntryPoint.SubmitAsync
rmshaffer a470662
Wait for job completion on %azure.execute
rmshaffer 354d826
Update comment
rmshaffer 9041701
Add timeout for %azure.execute
rmshaffer 0300ecd
Minor fixes in AzureClient
rmshaffer 8ce9c63
Minor formatting and comment tweaks
rmshaffer e3e7bcc
Style improvements in test code
rmshaffer f807723
More consistent handling of job objects
rmshaffer 1409213
Consistent error handling for IWorkspace calls
rmshaffer 78196ff
Update to latest QDK released version
rmshaffer fce176e
Merge branch 'feature/azure-client' into rmshaffer/azure-entrypoint
rmshaffer 0164134
Merge branch 'feature/azure-client' into rmshaffer/azure-entrypoint
rmshaffer edbe96e
Add encoders for CloudJob and TargetStatus
rmshaffer 1b27c4b
Move extension methods into encoder files
rmshaffer 3dabab4
Change signature of CloudJob.ToDictionary
rmshaffer 7c69473
Update histogram deserialization and add encoders
rmshaffer a9bc3d3
Use JsonConverter classes directly
rmshaffer c9dec08
Small cleanup
rmshaffer b92db91
Register single JsonEncoder
rmshaffer bb82ac4
Add a simple HTML histogram display based on StateVectorToHtmlResultE…
rmshaffer 78886f7
Various improvements from PR suggestions
rmshaffer 274ebde
Use UTC for dates returned to Python
rmshaffer 62a358e
Support jobName and shots parameters
rmshaffer 204ed5a
Unify submission and execution code
rmshaffer 7450585
Add some documentation to AzureSubmissionContext
rmshaffer bc90371
Documentation fix
rmshaffer f30a387
Add timeout and pollingInterval parameters
rmshaffer 9b3b74b
Use switch syntax for entryPointInput
eb8de48
Remove 'All rights reserved.'
0429635
Addressing PR feedback and compiler warnings
rmshaffer 5213b99
Use LINQ for decodedParameters
rmshaffer 7e1146e
Merge branch 'rmshaffer/azure-entrypoint' into rmshaffer/azure-encoders
rmshaffer c0a7ce0
Merge branch 'rmshaffer/azure-encoders' into rmshaffer/azure-jobsettings
rmshaffer b75a891
Update parameter names for consistency
rmshaffer a000b92
Merge branch 'feature/azure-client' into rmshaffer/azure-jobsettings
rmshaffer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #nullable enable | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using Microsoft.Quantum.IQSharp.Jupyter; | ||
| using Microsoft.Quantum.Runtime; | ||
|
|
||
| namespace Microsoft.Quantum.IQSharp.AzureClient | ||
| { | ||
| /// <summary> | ||
| /// Represents the configuration settings for a job submission to Azure Quantum. | ||
| /// </summary> | ||
| public sealed class AzureSubmissionContext : IQuantumMachineSubmissionContext | ||
| { | ||
| private static readonly int DefaultShots = 500; | ||
| private static readonly int DefaultExecutionTimeoutInSeconds = 30; | ||
| private static readonly int DefaultExecutionPollingIntervalInSeconds = 5; | ||
|
|
||
| internal static readonly string ParameterNameOperationName = "__operationName__"; | ||
| internal static readonly string ParameterNameJobName = "jobName"; | ||
| internal static readonly string ParameterNameShots = "shots"; | ||
| internal static readonly string ParameterNameTimeout = "timeout"; | ||
| internal static readonly string ParameterNamePollingInterval = "poll"; | ||
|
|
||
| /// <inheritdoc/> | ||
| public string FriendlyName { get; set; } = string.Empty; | ||
|
|
||
| /// <inheritdoc/> | ||
| public int Shots { get; set; } = DefaultShots; | ||
|
|
||
| /// <summary> | ||
| /// The Q# operation name to be executed as part of this job. | ||
| /// </summary> | ||
| public string OperationName { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// The input parameters to be provided to the specified Q# operation. | ||
| /// </summary> | ||
| public Dictionary<string, string> InputParameters { get; set; } = new Dictionary<string, string>(); | ||
|
|
||
| /// <summary> | ||
| /// The execution timeout for the job, expressed in seconds. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This setting only applies to %azure.execute. It is ignored for %azure.submit. | ||
| /// The timeout determines how long the IQ# kernel will wait for the job to complete; | ||
| /// the Azure Quantum job itself will continue to execute until it is completed. | ||
| /// </remarks> | ||
| public int ExecutionTimeout { get; set; } = DefaultExecutionTimeoutInSeconds; | ||
|
|
||
| /// <summary> | ||
| /// The polling interval, in seconds, to check for job status updates | ||
| /// while waiting for an Azure Quantum job to complete execution. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This setting only applies to %azure.execute. It is ignored for %azure.submit. | ||
| /// </remarks> | ||
| public int ExecutionPollingInterval { get; set; } = DefaultExecutionPollingIntervalInSeconds; | ||
|
|
||
| /// <summary> | ||
| /// Parses the input from a magic command into an <see cref="AzureSubmissionContext"/> object | ||
| /// suitable for job submission via <see cref="IAzureClient"/>. | ||
| /// </summary> | ||
| public static AzureSubmissionContext Parse(string inputCommand) | ||
| { | ||
| var inputParameters = AbstractMagic.ParseInputParameters(inputCommand, firstParameterInferredName: ParameterNameOperationName); | ||
| var operationName = inputParameters.DecodeParameter<string>(ParameterNameOperationName); | ||
| var jobName = inputParameters.DecodeParameter<string>(ParameterNameJobName, defaultValue: operationName); | ||
| var shots = inputParameters.DecodeParameter<int>(ParameterNameShots, defaultValue: DefaultShots); | ||
| var timeout = inputParameters.DecodeParameter<int>(ParameterNameTimeout, defaultValue: DefaultExecutionTimeoutInSeconds); | ||
| var pollingInterval = inputParameters.DecodeParameter<int>(ParameterNamePollingInterval, defaultValue: DefaultExecutionPollingIntervalInSeconds); | ||
|
|
||
| var decodedParameters = inputParameters.ToDictionary( | ||
| item => item.Key, | ||
| item => inputParameters.DecodeParameter<string>(item.Key)); | ||
|
|
||
| return new AzureSubmissionContext() | ||
| { | ||
| FriendlyName = jobName, | ||
| Shots = shots, | ||
| OperationName = operationName, | ||
| InputParameters = decodedParameters, | ||
| ExecutionTimeout = timeout, | ||
| ExecutionPollingInterval = pollingInterval, | ||
| }; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the plan for these two properties to connect up to
%config, or will there be another way to set them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With these changes, the two properties can be set via
timeoutandpollparameters to the%azure.executemagic command. It’s worth discussing whether they should be on%configinstead, but since they only apply to%azure.executeit seemed to make sense to put them here for now.