diff --git a/src/Simulation/Core/IQuantumMachine.cs b/src/Simulation/Core/IQuantumMachine.cs index abe2c4538f0..5593572ef16 100644 --- a/src/Simulation/Core/IQuantumMachine.cs +++ b/src/Simulation/Core/IQuantumMachine.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Threading.Tasks; using Microsoft.Quantum.Simulation.Core; @@ -10,9 +9,7 @@ namespace Microsoft.Quantum.Runtime /// /// Interface that a quantum machine must implement. /// - /// Type of job that handles the execution of a program in the quantum machine. - /// Type of result the quantum machine returns. - public interface IQuantumMachine + public interface IQuantumMachine { /// /// Gets the ID of the quantum machine provider. @@ -29,14 +26,14 @@ public interface IQuantumMachine /// /// Executes a Q# program. /// Submits a job to execute it and continuously checks whether it has been completed. - /// Once its execution completes, returns its output. + /// Once its execution completes, returns an object that implements the IQuantumMachineOutput interface through which the execution output can be obtained. /// /// Information about the Q# program /// Input for the Q# program /// Type of input the quantum program receives. /// Type of output the quantum program returns. - /// Sampled output of the quantum program - Task> ExecuteAsync(EntryPointInfo info, TInput input); + /// An object that implements the IQuantumMachineOutput interface. + Task> ExecuteAsync(EntryPointInfo info, TInput input); /// /// Submits a job to execute a Q# program. @@ -46,7 +43,7 @@ public interface IQuantumMachine /// Input for the Q# program /// Type of input the quantum program receives. /// Type of output the quantum program returns. - /// A Job instance. Status and results from the execution can be retrieved from this instance. - Task SubmitAsync(EntryPointInfo info, TInput input); + /// An object that implements the IQuantumMachineJob interface through which data about the job can be obtained. + Task SubmitAsync(EntryPointInfo info, TInput input); } } diff --git a/src/Simulation/Core/IQuantumMachineJob.cs b/src/Simulation/Core/IQuantumMachineJob.cs new file mode 100644 index 00000000000..8e5ab684ba4 --- /dev/null +++ b/src/Simulation/Core/IQuantumMachineJob.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Quantum.Runtime +{ + /// + /// Interface to track a job submitted to a quantum machine. + /// + public interface IQuantumMachineJob + { + /// + /// Gets whether job execution failed. + /// + bool Failed { get; } + + /// + /// Gets the ID of submitted job. + /// + string Id { get; } + + /// + /// Gets whether job execution is in progress. + /// + bool InProgress { get; } + + /// + /// Gets the status of the submitted job. + /// + string Status { get; } + + /// + /// Gets whether the job execution completed successfully. + /// + bool Succeeded { get; } + + /// + /// Gets an URI to access the job. + /// + Uri Uri { get; } + + /// + /// Cancels the job. + /// + /// The cancellation token for the cancel operation. + Task CancelAsync(CancellationToken cancellationToken = default); + + /// + /// Refreshes the state of the job. + /// + /// The cancellation token for the refresh operation. + Task RefreshAsync(CancellationToken cancellationToken = default); + } +} diff --git a/src/Simulation/Core/IQuantumMachineOutput.cs b/src/Simulation/Core/IQuantumMachineOutput.cs new file mode 100644 index 00000000000..204765d50f4 --- /dev/null +++ b/src/Simulation/Core/IQuantumMachineOutput.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; + +namespace Microsoft.Quantum.Runtime +{ + /// + /// Interface to access the results of a program executed in a quantum machine. + /// Type of output the quantum program returns. + /// + public interface IQuantumMachineOutput + { + /// + /// Gets a histogram of outputs. + /// The key is the output and the value is its frequency. + /// + IReadOnlyDictionary Histogram { get; } + + /// + /// Gets the job associated to the output. + /// + IQuantumMachineJob Job { get; } + + /// + /// Gets the number of times the program was executed. + /// + int Shots { get; } + } +}