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

Commit

Permalink
Add Validate method to the IQirSubmitter interface (#799)
Browse files Browse the repository at this point in the history
* Create Validate member for IQirSubmitter interface.
* Use Validate for --dry-run option when submitting QIR.
* Removed extra blank line.
  • Loading branch information
cesarzc authored Aug 19, 2021
1 parent 9f35c0b commit 487c143
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Simulation/Core/Submitters/IQirSubmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ public interface IQirSubmitter : IAzureSubmitter
/// <returns>The submitted job.</returns>
Task<IQuantumMachineJob> SubmitAsync(
Stream qir, string entryPoint, IReadOnlyList<Argument> arguments, SubmissionOptions options);

/// <summary>
/// Validates a QIR program for execution on Azure Quantum.
/// </summary>
/// <param name="qir">The QIR program as a byte stream.</param>
/// <param name="entryPoint">The fully-qualified name of the entry point to execute.</param>
/// <param name="arguments">The arguments to the entry point in the order in which they are declared.</param>
/// <returns><c>null</c> if the program is valid, or an error message otherwise.</returns>
string? Validate(Stream qir, string entryPoint, IReadOnlyList<Argument> arguments);
}
}
4 changes: 2 additions & 2 deletions src/Simulation/EntryPointDriver/Azure/Azure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private static async Task<int> SubmitQir(

if (settings.DryRun)
{
DisplayError("Dry run is not supported with QIR submission.", null);
return 1;
return DisplayValidation(submitter.Validate(
submission.QirStream, submission.EntryPointName, submission.Arguments));
}

var job = submitter.SubmitAsync(
Expand Down
4 changes: 4 additions & 0 deletions src/Simulation/EntryPointDriver/Mock/NoOpQirSubmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ internal class NoOpQirSubmitter : IQirSubmitter
public Task<IQuantumMachineJob> SubmitAsync(
Stream qir, string entryPoint, IReadOnlyList<Argument> arguments, SubmissionOptions options) =>
Task.FromResult<IQuantumMachineJob>(new ExampleJob());

public string? Validate(
Stream qir, string entryPoint, IReadOnlyList<Argument> arguments) =>
null;
}
}
4 changes: 4 additions & 0 deletions src/Simulation/EntryPointDriver/Mock/NoOpSubmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ public Task<IQuantumMachineJob> SubmitAsync<TIn, TOut>(
Task.FromResult<IQuantumMachineJob>(new ExampleJob());

public string? Validate<TIn, TOut>(EntryPointInfo<TIn, TOut> entryPoint, TIn argument) => null;

public string? Validate(
Stream qir, string entryPoint, IReadOnlyList<Argument> arguments) =>
null;
}
}

0 comments on commit 487c143

Please sign in to comment.