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

Reduce doc build time for learning representations #2165

Merged

Conversation

Misty-W
Copy link
Contributor

@Misty-W Misty-W commented Jan 26, 2024

Description

Fixes #2075

Use cached PEC data and skip PEC executions in optimization loop, to speed up doc build time for learning-depolarizing-noise.md

Local execution time: ~100 seconds --> ~4 seconds

Problem with optimization fixed (tested locally and on RTD)- was comparing ideal values of the wrong circuit. Now that the circuit matches the one used to generate the data, the optimizer converges to the correct value.


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

@Misty-W Misty-W self-assigned this Jan 26, 2024
@Misty-W Misty-W linked an issue Jan 26, 2024 that may be closed by this pull request
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (68af75d) 98.20% compared to head (a83f059) 98.26%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2165      +/-   ##
==========================================
+ Coverage   98.20%   98.26%   +0.06%     
==========================================
  Files          88       88              
  Lines        4170     4146      -24     
==========================================
- Hits         4095     4074      -21     
+ Misses         75       72       -3     

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

@Misty-W Misty-W marked this pull request as ready for review January 26, 2024 06:53
@Misty-W Misty-W marked this pull request as draft January 26, 2024 16:04
@Misty-W Misty-W marked this pull request as ready for review January 27, 2024 05:35
@natestemen natestemen self-requested a review January 30, 2024 19:48
Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

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

Nice work! We love fast docs!

The one (nonblocking) question I have is if someone downloads this notebook (as a markdown file) and converts it a python notebook, will it run out of the box, or create an error looking for the PEC data file? Either way, I'm okay to merge. Just something I think we should be aware of/know the answer to.

LineQubit.range(2), n_moments=10, random_state=np.random.RandomState(1)
LineQubit.range(2), n_moments=5, random_state=np.random.RandomState(1)
Copy link
Member

Choose a reason for hiding this comment

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

Why is it that this change does not require a change to the data that is loaded in further into the file? Naively, I would have thought if we are changing the circuit, then the PEC data would need to change as well. Does the PEC data consist of representations of the gates, which does not change 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.

The change is to match the circuits used to generate the file. The file was generated separately from this notebook and is already used in test_learning.py to make the tests run efficiently.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh okay that makes sense! Thanks for the clarification. Can you comment on what's in the data file? (just for the sake of me learning!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An array of values of execute_with_pec for different values of depolarizing noise strength epsilon (equally spaced apart by ??). The zeroth column is the value of epsilon used in the representations for PEC.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense! And the circuit used in the data is the the same as the one defined here?

circuit = random_x_z_cnot_circuit(
LineQubit.range(2), n_moments=5, random_state=np.random.RandomState(1)
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

@Misty-W
Copy link
Contributor Author

Misty-W commented Feb 5, 2024

The one (nonblocking) question I have is if someone downloads this notebook (as a markdown file) and converts it a python notebook, will it run out of the box, or create an error looking for the PEC data file? Either way, I'm okay to merge. Just something I think we should be aware of/know the answer to.

If they "run all cells" it will error out if they don't have the data files, and it's a shame the "hidden" cell shows in the Jupyter notebook. But they can (and should) run the next cell, which does the real workflow with execute_with_pec. We just don't want to run it every docs build.

@Misty-W Misty-W merged commit 2205eb8 into master Feb 5, 2024
30 checks passed
@Misty-W Misty-W deleted the 2075-reduce-doc-build-time-for-learning-representations branch February 5, 2024 19:48
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.

Reduce doc build time for Learning Representations
2 participants