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

Conversation

@msoeken
Copy link
Member

@msoeken msoeken commented Aug 25, 2020

This is the first PR into the M.Q.Preparation feature branch, starting with some cleanup of the existing code.

@msoeken msoeken changed the base branch from master to feature/state-preparation August 25, 2020 14:53
@msoeken msoeken requested review from anpaz and cgranade and removed request for anpaz August 27, 2020 09:59
@msoeken msoeken marked this pull request as ready for review August 27, 2020 10:00
@msoeken msoeken requested a review from guenp August 31, 2020 14:36
Copy link

@guenp guenp left a comment

Choose a reason for hiding this comment

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

Just a few comments.

// |coefficient[i] * oneNorm - discretizedCoefficient[i] * discreizedOneNorm| * nCoeffs <= 2^{1-bitsPrecision}.
function _QuantumROMDiscretization(bitsPrecision: Int, coefficients: Double[]) : (Double, Int[], Int[]) {
// |coefficient[i] * oneNorm - discretizedCoefficient[i] * discretizedOneNorm| * nCoeffs <= 2^{1-bitsPrecision}.
function _QuantumROMDiscretization(bitsPrecision: Int, coefficients: Double[])
Copy link

Choose a reason for hiding this comment

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

Perhaps it would also be good to use internal function here for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately this function is tested in a separate test project, so it cannot be internal (for now). So I leave the _ such that it does not end up in docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make a qsharp-compiler feature request for internalsvisibleto?

Copy link

Choose a reason for hiding this comment

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

in this case would it be an idea to create the internal function and make _QuantumROMDiscretization a wrapper to it with a deprecation note, and create a task to refactor said test project?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would leave this for now until we have a solution. I agree with @cgrande to open a feature request for this. An alternative solution would be to have a non-internal function with an attribute such as @UsedForTesting indicating that no docs should be generated.

@msoeken
Copy link
Member Author

msoeken commented Sep 1, 2020

Thanks for your comments @guenp.

Copy link
Contributor

@cgranade cgranade left a comment

Choose a reason for hiding this comment

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

I think these look like some really good improvements, thanks for doing this, @msoeken!

// NB: This is currently not marked as internal, as the QML library
// currently uses this function. Please see the relevant GitHub issue
// at https://github.com/microsoft/QuantumLibraries/issues/239.
function _CompileApproximateArbitraryStatePreparation(
Copy link
Contributor

Choose a reason for hiding this comment

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

As per the comment above, this function is currently called from the QML library; it'd be good to double-check that the QML library works with this function being internal.

// |coefficient[i] * oneNorm - discretizedCoefficient[i] * discreizedOneNorm| * nCoeffs <= 2^{1-bitsPrecision}.
function _QuantumROMDiscretization(bitsPrecision: Int, coefficients: Double[]) : (Double, Int[], Int[]) {
// |coefficient[i] * oneNorm - discretizedCoefficient[i] * discretizedOneNorm| * nCoeffs <= 2^{1-bitsPrecision}.
function _QuantumROMDiscretization(bitsPrecision: Int, coefficients: Double[])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make a qsharp-compiler feature request for internalsvisibleto?

msoeken and others added 3 commits September 2, 2020 13:03
Co-authored-by: Chris Granade <chgranad@microsoft.com>
…oft/QuantumLibraries into msoeken/state-preparation-cleanup
@msoeken
Copy link
Member Author

msoeken commented Sep 2, 2020

Thanks for your comments @cgranade, @guenp and @SamarSha. I re-request your review @cgranade, since I added new public API to M.Q.Canon (IsRangeEmpty) after your comment.

@msoeken msoeken requested a review from cgranade September 2, 2020 11:06
Copy link
Contributor

@cgranade cgranade left a comment

Choose a reason for hiding this comment

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

Approving without API review since this targets a feature branch rather than master; let's make sure to add IsRangeEmpty to the schedule before merging that feature to master. Thanks!


/// # Summary
/// Returns true if and only if input range is empty.
///
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be pretty basic in this case, but could we add an /// # Input and /// # Output block here?

@msoeken msoeken merged commit 3ab32ab into feature/state-preparation Sep 3, 2020
@msoeken msoeken deleted the msoeken/state-preparation-cleanup branch September 3, 2020 09:53
cgranade pushed a commit that referenced this pull request Nov 18, 2020
* Cleanup in M.Q.Preparation (#315)

* Cleanup QuantumROM.

* Cleanup uniform superposition.

* Cleanup quantum ROM.

* Clean-up arbitrary state preparation.

* Cleanup remaining files.

* Fix bug in QuantumROM.

* Fix error.

* Revert name due to #239.

* Apply suggestions from code review

Co-authored-by: Chris Granade <chgranad@microsoft.com>

* Addressing reviewer comments.

* Docs.

Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
Co-authored-by: Chris Granade <chgranad@microsoft.com>

* Fix namespace.

* Extend PurifiedMixedState for additional data preparation (#322)

* Squashed commit of the following:

commit 9841567
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Mon Aug 31 10:41:17 2020 +0200

    Fix bug in QuantumROM.

commit 9726ff2
Merge: 58d428e 0b02a6a
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Mon Aug 31 09:49:43 2020 +0200

    Merge branch 'master' into msoeken/state-preparation-cleanup

commit 58d428e
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Thu Aug 27 11:59:12 2020 +0200

    Cleanup remaining files.

commit b35222a
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Thu Aug 27 11:54:33 2020 +0200

    Clean-up arbitrary state preparation.

commit e8076f7
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Wed Aug 26 09:31:17 2020 +0200

    Cleanup quantum ROM.

commit 860c0ab
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Wed Aug 26 09:21:21 2020 +0200

    Cleanup uniform superposition.

commit b94ec8c
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Tue Aug 25 15:56:26 2020 +0200

    Cleanup QuantumROM.

* Remove duplicate code and reduce T-count.

* Cleanup.

* Squashed commit of the following:

commit cb77faa
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Mon Aug 31 16:46:12 2020 +0200

    Fix error.

commit 9841567
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Mon Aug 31 10:41:17 2020 +0200

    Fix bug in QuantumROM.

commit 9726ff2
Merge: 58d428e 0b02a6a
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Mon Aug 31 09:49:43 2020 +0200

    Merge branch 'master' into msoeken/state-preparation-cleanup

commit 58d428e
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Thu Aug 27 11:59:12 2020 +0200

    Cleanup remaining files.

commit b35222a
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Thu Aug 27 11:54:33 2020 +0200

    Clean-up arbitrary state preparation.

commit e8076f7
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Wed Aug 26 09:31:17 2020 +0200

    Cleanup quantum ROM.

commit 860c0ab
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Wed Aug 26 09:21:21 2020 +0200

    Cleanup uniform superposition.

commit b94ec8c
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Tue Aug 25 15:56:26 2020 +0200

    Cleanup QuantumROM.

* Squashed commit of the following:

commit cde7c0c
Author: Mathias Soeken <masoeken@microsoft.com>
Date:   Mon Aug 31 16:34:40 2020 +0200

    Unzipped function.

* Preparing function and tests for QuantumROM with signed coefficients.

* Further unification.

* Ineffecient way of creating sign bit.

* Embed sign computation in multiplex.

* Picking changes from #212.

* Changes from #212.

* Generalize.

* Generalize data register.

* Unifying signatures.

* Use UDT for PurifiedState.

* Docs and cleanup.

* Incoprate API changes.

* Fix bug on Mac.

* Make public because of #239.

* Add deprecated functions.

Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
Co-authored-by: Chris Granade <chgranad@microsoft.com>

* Implement last changes from #344 (#375)

* Implemented changes from #344 review.

* Ported signed quantum ROM test to use WithData.

* Made AssertSignedProbInt internal until #337.

* Apply suggestions from code review

Co-authored-by: Mathias Soeken <mathias.soeken@outlook.com>

Co-authored-by: Mathias Soeken <mathias.soeken@outlook.com>

* Apply suggestions from code review

Co-authored-by: Guen P <guenp@microsoft.com>

* Apply suggestions from code review

Co-authored-by: Mathias Soeken <mathias.soeken@outlook.com>

Co-authored-by: Mathias Soeken <mathias.soeken@outlook.com>
Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
Co-authored-by: Guen P <guenp@microsoft.com>
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