amazon-braket / amazon-braket-algorithm-library

Apache License 2.0
89 stars 33 forks source link

Random circuit function #122

Closed Morcu closed 7 months ago

Morcu commented 11 months ago

Issue #, if available: Add random_circuit function for testing #495

Description of changes:

Added random_circuit function to create random circuits.

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

rmshaffer commented 11 months ago

Hey @Morcu, thanks very much for starting this contribution! Random circuit functionality will be a great addition to this library.

According to the contribution guidelines for this repo, the algorithm code should contain:

For example, see the implementation of the Bernstein-Vazirani algorithm here. (Please read the rest of the contribution guidelines as well to get an idea for what is expected.)

In order to do this, I would suggest we structure this implementation around a particular algorithm which uses random circuits. Open to your ideas here, but I think the simplest example would be single-qubit Clifford randomized benchmarking (RB) - a good explanation of this is available here. Then the algorithm code can be focused on defining the RB circuit ensembles, running them, and collecting the results. (The random_circuit function you have written would be part of this, of course! It will probably need a way to specify a limited gate set, rather than always using all available Braket gates.) The example notebook could demonstrate constructing several single-qubit RB circuits of varying length, running them on a simulator with noise (and/or on hardware), and analyzing the results.

I know that's a bit beyond the scope of what you've done in this first iteration, but please let us know if you're interested in taking this on, and/or if you have any questions after you've thought about it a bit!

yitchen-tim commented 11 months ago

Hi @Morcu, thanks for the contribution! Adding to the previous comment, besides adhering to the guideline about the code location and the function name, we suggest you to choose one of the two categories for your contribution:

  1. "textbook": This category is for algorithms that generally appear in a textbook or in a lecture. To contribute into this category, like @rmshaffer suggested, we suggest you to implement something like Randomized Benchmarking circuits as the random circuits.
  2. "auxiliary_functions": This category is for auxiliary functions that support the development of algorithms or hardware testings. If you decide to contribute to this category, you can move your notebook into notebooks/auxiliary_functions. Since you would be the first one to contribute into this category, you would need to create this folder under notebooks.

Thanks again for the contribution!

Morcu commented 11 months ago

Hi @rmshaffer and @yitchen-tim,

Thanks for your feedback! I'm on board with implementing it as suggested. I'll align my work with the contribution guidelines, focusing on the necessary functions and structure. Excited to contribute and will keep you updated on my progress. 😄

rmshaffer commented 7 months ago

Thank you @Morcu for the start on this contribution! @ykharkov picked up part of this in #139, and we have merged that into the repo now under a new auxiliary_functions folder. Closing this PR since it is stale and has some overlap with #139.

If you'd like to continue your contributions on top of this, along the lines of what is discussed in the comments here (for example - adding a Randomized Benchmarking algorithm which uses this random circuit generator), please feel free to open a new PR to this repo!