Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add random circuit algo #139

Merged
merged 16 commits into from
Mar 29, 2024
Merged

Add random circuit algo #139

merged 16 commits into from
Mar 29, 2024

Conversation

ykharkov
Copy link
Member

Description of changes:
Added random circuit generator, that takes the number of qubits, number of gates and maximum number of operands for each gate as an input.

This PR reimplements the feature proposed in #122
by @Morcu, created in a fork repo.

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

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

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

Copy link

codecov bot commented Mar 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d240d09) to head (657a96b).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #139   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        29    +3     
  Lines         1028      1053   +25     
  Branches       181       185    +4     
=========================================
+ Hits          1028      1053   +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@rmshaffer rmshaffer left a comment

Choose a reason for hiding this comment

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

Added a few comments. Overall I am not sure that the current implementation is actually useful for anything.

Also, I believe these two comments from the original PR still apply:

Comment on lines 61 to 65
# Get the constructor's signature to determine required parameters
init_signature = inspect.signature(gate_class.__init__)

# Calculate the number of parameters (excluding 'self')
num_params = len(init_signature.parameters) - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it should work for now, but in case these constructors get more args added in the future, it is likely more robust to check the actual class ... something like:

num_params = (
    3 if issubclass(gate_class, TripleAngledGate) else
    2 if issubclass(gate_class, DoubleAngledGate) else
    1 if issubclass(gate_class, AngledGate) else
    0
)

Copy link
Member Author

Choose a reason for hiding this comment

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

Braket SDK doesn't have DoubleAngled or TripleAngled classes, unfortunately. The existing code should work fine.

notebooks/textbook/Random_Circuit.ipynb Outdated Show resolved Hide resolved
notebooks/textbook/Random_Circuit.ipynb Outdated Show resolved Hide resolved
notebooks/textbook/Random_Circuit.ipynb Outdated Show resolved Hide resolved
Copy link
Contributor

@rmshaffer rmshaffer left a comment

Choose a reason for hiding this comment

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

Looking good! A few more minor comments, nothing too critical.

Also note that #140 is adding a summary table to the README - if that gets merged first, then a link to this random_circuit function should probably also be added to that summary table.

@rmshaffer rmshaffer merged commit 62643bd into main Mar 29, 2024
13 checks passed
@rmshaffer rmshaffer deleted the feature/random_circuit branch March 29, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants