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

Begin simplifying and updating the Get-GateCount sample #202

Merged
merged 10 commits into from
Jun 21, 2019

Conversation

cgranade
Copy link
Contributor

This PR begins to simplify the gate count sample by splitting the one Program.cs into several files that are each easier to read, making outputting CSVs optional, and by consolidating common logic into a few extension methods.

Copy link
Member

@anpaz anpaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good. We need to be consistent on properties vs fields and their naming (they should all be capitalized.

I like how the configuration have pulled into their own structs. I would take it even further and add EntryOperation to avoid some code duplication in RunGateCount.

As you pointed out this morning. Marking this as Approved although it is more like Approved With Suggestions.

Chemistry/GetGateCount/3-GetGateCount.csproj Show resolved Hide resolved
Chemistry/GetGateCount/Configuration.cs Show resolved Hide resolved
Chemistry/GetGateCount/Configuration.cs Show resolved Hide resolved
Chemistry/GetGateCount/Configuration.cs Outdated Show resolved Hide resolved
Chemistry/GetGateCount/Configuration.cs Outdated Show resolved Hide resolved
public double CNOTCount;
public double NormMultipler;
public long ElapsedMilliseconds;
public Dictionary<string, string> TraceSimulationStats;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep these? I don't see them used or printed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are in principle accessible via the PowerShell interface, but they're not otherwise used, no.

Chemistry/GetGateCount/PowerShellIntegration.cs Outdated Show resolved Hide resolved

var gateCountResults = new GateCountResults();
#region Trace Simulator on Trotter step
if (config.hamiltonianSimulationAlgorithm == HamiltonianSimulationAlgorithm.ProductFormula)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these are mostly copy/paste... I would take the Configuration concept and go a step further and move the which Q# operation to run as part of the configuration and a Name property, so you don't have to have the code duplication here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I actually tried to do that, but ran into a couple slight issues in that the GetMetric method of the trace simulator takes a type argument for the operation in question, and in that the optimized qubitization operation takes an additional parameter for the target error. I'd prefer if possible to defer this improvement to the next PR on this sample if that's OK.

/// <summary>
/// Configuration data for Hamiltonian simulation algorithm
/// </summary>
public struct HamiltonianSimulationConfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a HamiltonianSimulationConfig class with different config properties depending on the type of algorithm, I would create an IHamiltonianSimulationConfig interface with a couple of methods needed to run the simulation, for example HamiltonianSimulationAlgorithm and EntryOperation, and then have the ProductFormulaConfig and QubitizationConfig implement this interface.
This would also address the duplicated code in RunGateCount.

@cgranade cgranade changed the base branch from master to release/v0.8 June 20, 2019 23:02
@cgranade cgranade requested a review from anpaz June 20, 2019 23:03
@cgranade
Copy link
Contributor Author

Merging in now, with future work tracked in #203. Thanks!

@cgranade cgranade merged commit 179e732 into release/v0.8 Jun 21, 2019
@cgranade cgranade deleted the cgranade/simplify-get-gatecount branch June 21, 2019 22:27
anpaz added a commit that referenced this pull request Jul 19, 2019
* Begin simplifying and updating the Get-GateCount sample (#202)

* Ignore gate count outputs.

* Begin simplifying gate count sample.

* More work on simplifying the gate count sample, updating to beta package.

* Removed a few levels of nested types.

* First → Single, fixed plotting issues.

* Added some blank lines for readability.

* Changed fields to properties, applied uppercase naming.

* Fixed some comments in powershell integration.

* Moving to script-based build.

* Moving to script-based build.

* Moving to 0.8.1906.2007-beta

* Validation of IntegralData only supported in Windows

* Adding step to publish test results.

* Update samples for 0.8 beta. (#206)

* Beginning work on converting samples to 0.8.

* Enabled using devcontainer to lock Quantum Development Kit version.

* Updated several samples to 0.8 beta.

* Updated devcontainer to 0.8 beta.

* Updated several more samples to 0.8.

* Updated a few more projects.

* Adapting development container for working with chemistry, python.

* Add QInfer to docker, put metadata back.

* Added mpl requirements to Dockerfile.

* Updated tomography sample to 0.8.

* Fixed warning in DatabaseSearch.

* Fixed typo.

* Update .devcontainer/README.md

Co-Authored-By: Andres Paz <anpaz@microsoft.com>

* Fixed spelling in F# solution.

* Step 1 of renaming F# driver.

* Step 2 of renaming F# driver.

* Updating qdk to latest version
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants