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
15 changes: 6 additions & 9 deletions src/Simulation/Core/IQuantumMachine.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -10,9 +9,7 @@ namespace Microsoft.Quantum.Runtime
/// <summary>
/// Interface that a quantum machine must implement.
/// </summary>
/// <typeparam name="TJob">Type of job that handles the execution of a program in the quantum machine.</typeparam>
/// <typeparam name="TRawResult">Type of result the quantum machine returns.</typeparam>
public interface IQuantumMachine<TJob, TRawResult>
public interface IQuantumMachine
{
/// <summary>
/// Gets the ID of the quantum machine provider.
Expand All @@ -29,14 +26,14 @@ public interface IQuantumMachine<TJob, TRawResult>
/// <summary>
/// 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.
/// </summary>
/// <param name="info">Information about the Q# program</param>
/// <param name="input">Input for the Q# program</param>
/// <typeparam name="TInput">Type of input the quantum program receives.</typeparam>
/// <typeparam name="TOutput">Type of output the quantum program returns.</typeparam>
/// <returns>Sampled output of the quantum program</returns>
Task<Tuple<TOutput, TRawResult>> ExecuteAsync<TInput, TOutput>(EntryPointInfo<TInput, TOutput> info, TInput input);
/// <returns>An object that implements the IQuantumMachineOutput interface.</returns>
Task<IQuantumMachineOutput<TOutput>> ExecuteAsync<TInput, TOutput>(EntryPointInfo<TInput, TOutput> info, TInput input);

/// <summary>
/// Submits a job to execute a Q# program.
Expand All @@ -46,7 +43,7 @@ public interface IQuantumMachine<TJob, TRawResult>
/// <param name="input">Input for the Q# program</param>
/// <typeparam name="TInput">Type of input the quantum program receives.</typeparam>
/// <typeparam name="TOutput">Type of output the quantum program returns.</typeparam>
/// <returns>A Job instance. Status and results from the execution can be retrieved from this instance.</returns>
Task<TJob> SubmitAsync<TInput, TOutput>(EntryPointInfo<TInput, TOutput> info, TInput input);
/// <returns>An object that implements the IQuantumMachineJob interface through which data about the job can be obtained.</returns>
Task<IQuantumMachineJob> SubmitAsync<TInput, TOutput>(EntryPointInfo<TInput, TOutput> info, TInput input);
}
}
57 changes: 57 additions & 0 deletions src/Simulation/Core/IQuantumMachineJob.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Interface to track a job submitted to a quantum machine.
/// </summary>
public interface IQuantumMachineJob
{
/// <summary>
/// Gets whether job execution failed.
/// </summary>
bool Failed { get; }

/// <summary>
/// Gets the ID of submitted job.
/// </summary>
string Id { get; }

/// <summary>
/// Gets whether job execution is in progress.
/// </summary>
bool InProgress { get; }

/// <summary>
/// Gets the status of the submitted job.
/// </summary>
string Status { get; }

/// <summary>
/// Gets whether the job execution completed successfully.
/// </summary>
bool Succeeded { get; }

/// <summary>
/// Gets an URI to access the job.
/// </summary>
Uri Uri { get; }

/// <summary>
/// Cancels the job.
/// </summary>
/// <param name="cancellationToken">The cancellation token for the cancel operation.</param>
Task CancelAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Refreshes the state of the job.
/// </summary>
/// <param name="cancellationToken">The cancellation token for the refresh operation.</param>
Task RefreshAsync(CancellationToken cancellationToken = default);
}
}
30 changes: 30 additions & 0 deletions src/Simulation/Core/IQuantumMachineOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;

namespace Microsoft.Quantum.Runtime
{
/// <summary>
/// Interface to access the results of a program executed in a quantum machine.
/// <typeparam name="TOutput">Type of output the quantum program returns.</typeparam>
/// </summary>
public interface IQuantumMachineOutput<TOutput>
{
/// <summary>
/// Gets a histogram of outputs.
/// The key is the output and the value is its frequency.
/// </summary>
IReadOnlyDictionary<TOutput, double> Histogram { get; }

/// <summary>
/// Gets the job associated to the output.
/// </summary>
IQuantumMachineJob Job { get; }

/// <summary>
/// Gets the number of times the program was executed.
/// </summary>
int Shots { get; }
}
}