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

Conversation

@cgranade
Copy link
Contributor

@cgranade cgranade commented Nov 15, 2019

This PR represents joint work with @alexeib2 on a new quantum machine learning library focused on the QCCC algorithm of Maria Schuld, Alex Bocharov, Krysta Svore, Nathan Wiebe ("Circuit-centric quantum classifiers", https://arxiv.org/abs/1804.00633).

Note that this PR is currently marked as draft, as work on this feature is in progress. Still to be done:

  • Normalize function, operation, type, and variable names with Q# style guide.
  • Resolve all deprecation warnings.
  • Normalize whitespace, bracket placement, etc.
  • Improve C# interoperability class, make more uniform with Python usage.
  • Remove C# -> Q# conversion class, moving required methods into core runtime as needed.
  • Improve and expand API documentation comments, write where missing.
  • Write unit tests.
  • Improve multiplexing in M.Q.Standard, incorporate new approximate multiplexing operations.
  • Ensure uniform application of copyright headers.
  • Ensure uniform order to function and operation arguments

Chris Granade and others added 2 commits November 15, 2019 00:49
This PR represents joint with with @alex Bocharov, and begins open development on a quantum machine learning library.
@cgranade
Copy link
Contributor Author

I've added one more TODO item to this draft PR to reflect that many operations have common inputs, but that appear in different order. The final API for this library should be uniform with respect to these choices to minimize user surprise.

Chris Granade and others added 6 commits November 20, 2019 15:21
…upport QML (#177)

* Started writing unit tests for new standard library functionality.

* Testing new array fn.

* Fixes to Runtime project.

* Added more tests.

* Added tesets for rest of functionality added to M.Q.Std.
* Drafted new apply ops

* Fixed docs

* Fixed minor bugs

* Added Permutation function + helper Arrays + Claim functions

* Added Adj + Ctl and set csproj back to generating docs

* Added tests

* Fixed test errors

* Updated code from comments; moved PermuteQubits to CommonGates

* Fixed minor bugs

* Apply suggestions from code review

Co-Authored-By: Chris Granade <cgranade@gmail.com>

* Added some fixes from changes

* Added most recommendations from Mathias

* Added example to ApplySeriesOfOps

* Added new examples

* Added PermuteQubits example

* Changed Swap Order to be appending to an array, added test for it

* Updated ApplyOpRepeatedlyOver Docs

* Added Mathias' comments

* Reverted csproj file

* Renamed TupleArrayAsNestedArray
cgranade and others added 3 commits November 22, 2019 15:25
* Removed unused "adapter" operations.

* Removed unused operation.

* Consolidated two APIs for estimating classification probabilities.

* Removed old version of CircuitResult operation.

* Simplified classification operation slightly.

* Eliminated unused operation.

* Clarified InferredLabel, updated argument order to respect currying.

* Moved bias update into training, fixed bug.

* Renamed operations to estimate classification probabilities.

* Simplify TallyHitsMisses.

* Trivial commit.

* Addressing @bettinaheim's feedback.
* Added comments

* Test case for new univariate optimizer.

* Update to latest alpha.

* Fix order of interval edges.

* Fix parabola test.

* Use new minimization to simplify training logic.

* Used new optimization function to simplify bias search.

* Revert to public alphas.

* Temporarily revert use of Test attribute.
Chris Granade added 4 commits December 6, 2019 17:43
* Add placeholder for QML unit tests.

* Add copyright header.

* Trigger build on feature work.
* Consolidated exact and approximate MultiplexZ.

* Consolidate exact and approx ApplyDiagonalUnitary

* Finished consolidating multiplexers.

* Code cleanup, inclusive language.

* Whitespace fix and name clarification.

* Consolidated arbitrary state preparation.

* Slight cleanup.

* API documentation comments.
* Clarify the restriction on the number of bits for IntAsBoolArray (#171)

* Clarify the restriction on the number of bits for IntAsBoolArray

This should fix #166 by providing a more specific error message.

* Update Standard/src/Convert/Convert.qs

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Allow to have bits = 0

Looks like our tests assume that number = 0 with bits = 0 is a valid scenario; updating the change to account for that

* Package updates (#188)

* Updated sourcelink on QML to match new version.
…187)

* Begin simplifying training API.

* Fix for TrainQcccSequential.

* Simplify OneStochasticTrainingEpoch.

* Simplified training API a little more.

* Remove unused operation.

* Started Chunks function.

* Began removing ExtractMiniBatch.

* Simplify training API with new SequentialModel UDT.

* Further consolidate APIs.

* Consolidated training and classification APIs further.

* Fixed bug in Chunks.

* Regression test for prev commit.

* Make internal implementation of sequential model trainer private.

* Make APIs more uniform.

* Added new array function to simplify Misclassifications.

* Remove ExtractMiniBatch.

* Removed deprecated operations.

* Fix type in Examples.

* More progress removing private fns and ops from public API.

* Further consolidated API surface.

* Addressing feedback.
Chris Granade and others added 9 commits January 8, 2020 13:56
* Clarify the restriction on the number of bits for IntAsBoolArray (#171)

* Clarify the restriction on the number of bits for IntAsBoolArray

This should fix #166 by providing a more specific error message.

* Update Standard/src/Convert/Convert.qs

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Allow to have bits = 0

Looks like our tests assume that number = 0 with bits = 0 is a valid scenario; updating the change to account for that

* Package updates (#188)

* Quantum AND gates (a.k.a. CCNOT with constant target) (#186)

* Two AND gate implementations.

* Added test case.

* Formatting.

* Code formatting.

* Update Standard/src/Canon/And.qs

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Assertion for 0-target.

* Added DOI to references.

* Named application for CCNOTop.

* Rename operations.

* Add Test attribute.

* Add links to arXiv.

* Rename operations.

* Better assertion for 0-target.

* Fix bug in LowDepthAnd.

* Docs.

* Doc string convention.

* Controlled variant for `ApplyAnd`.

* Controlled AndLowDepth.

* Adjoint Controlled LowDepthAnd.

* References.

* Simplify code.

* Apply suggestions from code review

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Integrate comment.

* Removed comment ref to IncrementByIntegerPhaseLE (#189)

There appears to be no function IncrementByIntegerPhaseLE, and I guess it is covered by ApplyLEOperationOnPhaseLE.

Co-authored-by: Chris Granade <cgranade@gmail.com>

* New Hadamard and SWAP test operations. (#196)

* First work on Hadamard and SWAP test operations.

* (c) header and typo fix.

* Fixed typo with placement of phase shift.

* Put public operations above private.

* Added tests for new operations.

* Added API documentation comments.

* Newline at end of file.

* Refactor AA namespace to use Q# style guide (#197)

* Began simplifying AA interface.

* Expose traditional AA as new public operation.

* Removed rest of "AmpAmp" prefix.

* Resolve deprecation warning.

* Switching to using the new Sdk (#194)

* Minor doc fixes (#190)

* Minor doc fixes

* Minor doc cleanup

There are probably still some unstated assumptions on the algorithms.

* Add "# Description" for MultiplyByModularInteger

...because there is inline math.

Co-Authored-By: Chris Granade <cgranade@gmail.com>

* "unitary operation" instead of "unitary operator"

Co-Authored-By: Chris Granade <cgranade@gmail.com>

* Add "# Description", remove refs in "# Summary"

Co-authored-by: Chris Granade <cgranade@gmail.com>

* Fix build by updating QML projects to use SDK.

Co-authored-by: Mariia Mykhailova <michaylova@gmail.com>
Co-authored-by: bettinaheim <34236215+bettinaheim@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: numpde <21158052+numpde@users.noreply.github.com>
* Clarify the restriction on the number of bits for IntAsBoolArray (#171)

* Clarify the restriction on the number of bits for IntAsBoolArray

This should fix #166 by providing a more specific error message.

* Update Standard/src/Convert/Convert.qs

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Allow to have bits = 0

Looks like our tests assume that number = 0 with bits = 0 is a valid scenario; updating the change to account for that

* Package updates (#188)

* Quantum AND gates (a.k.a. CCNOT with constant target) (#186)

* Two AND gate implementations.

* Added test case.

* Formatting.

* Code formatting.

* Update Standard/src/Canon/And.qs

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Assertion for 0-target.

* Added DOI to references.

* Named application for CCNOTop.

* Rename operations.

* Add Test attribute.

* Add links to arXiv.

* Rename operations.

* Better assertion for 0-target.

* Fix bug in LowDepthAnd.

* Docs.

* Doc string convention.

* Controlled variant for `ApplyAnd`.

* Controlled AndLowDepth.

* Adjoint Controlled LowDepthAnd.

* References.

* Simplify code.

* Apply suggestions from code review

Co-Authored-By: Chris Granade <chgranad@microsoft.com>

* Integrate comment.

* Removed comment ref to IncrementByIntegerPhaseLE (#189)

There appears to be no function IncrementByIntegerPhaseLE, and I guess it is covered by ApplyLEOperationOnPhaseLE.

Co-authored-by: Chris Granade <cgranade@gmail.com>

* New Hadamard and SWAP test operations. (#196)

* First work on Hadamard and SWAP test operations.

* (c) header and typo fix.

* Fixed typo with placement of phase shift.

* Put public operations above private.

* Added tests for new operations.

* Added API documentation comments.

* Newline at end of file.

* Refactor AA namespace to use Q# style guide (#197)

* Began simplifying AA interface.

* Expose traditional AA as new public operation.

* Removed rest of "AmpAmp" prefix.

* Resolve deprecation warning.

* Begin moving classifier structure creation to Q#.

* Moving example datasets into new namespace.

* Fix datasets used in layered structure demo.

* Fixed bug with cyclic entangling layer.

* Use new Hadamard test operation to simplify grad est.

* Simplify input encoder logic.

* Removed layer construction methods moved out to Q#.

* Revised name of approximate input encoder.

* Removed unused interop library.

* Update pack script for new layout.

* Addressing feedback.

Co-authored-by: Mariia Mykhailova <michaylova@gmail.com>
Co-authored-by: bettinaheim <34236215+bettinaheim@users.noreply.github.com>
Co-authored-by: Mathias Soeken <mathias.soeken@gmail.com>
Co-authored-by: numpde <21158052+numpde@users.noreply.github.com>
* Begin preparing for API review.

* A bit more refactoring.

* A bit more refactoring, more /// comments.

* Progress on ///, code quality.
Fix path to pubkey for QML signing.
@cgranade cgranade marked this pull request as ready for review February 11, 2020 23:36
@cgranade
Copy link
Contributor Author

cgranade commented Feb 11, 2020

This is currently blocked on #227, but is otherwise ready for merging to master, I think!

Update: No longer blocked, thanks for the review @tcNickolas!

Copy link
Contributor

@ScottCarda-MS ScottCarda-MS left a comment

Choose a reason for hiding this comment

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

Since everything in this PR seems to have passed through a previous PR, I didn't do much more than a cursory glance at the code, but nothing appeared to be out of place.

@geduardo
Copy link

My suggestion was wrong, nevermind!

Copy link
Contributor

@bettinaheim bettinaheim left a comment

Choose a reason for hiding this comment

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

I commented the thoughts that occurred to me as I went over it. They accumulated... feel free to ignore any of them.


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
Copy link
Contributor

Choose a reason for hiding this comment

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

This should just be overwritten if it's opened with VS19 I believe. It might still be worth it quickly doing that, since we no longer support VS17.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I generated this with dotnet new sln, didn't realize that it used an older version of the sln format.

<ProjectReference Include="..\..\Standard\src\Standard.csproj" />
</ItemGroup>

<!-- Configure NuGet package metadata as well. -->
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth setting up a common props file for most of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, yes. That said, I'd like to defer to a future PR.

@cgranade
Copy link
Contributor Author

Thanks for the feedback, @bettinaheim! Since this is a locked feature branch, I'll address your comments in a separate PR targeting this one, and will open that shortly. Thanks!

@cgranade cgranade merged commit 2f510ae into master Feb 23, 2020
@anpaz anpaz deleted the feature/qml branch July 24, 2020 19:41
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.

5 participants