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

Clean up QuantumScript._par_info #3185

Merged
merged 47 commits into from
Oct 25, 2022
Merged

Clean up QuantumScript._par_info #3185

merged 47 commits into from
Oct 25, 2022

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Oct 18, 2022

Note that PR branches off of #3097 and must be merged after it.

The QuantumTape._par_info (now QuantumScript._par_info) was a dictionary mapping from integers starting at zero to a dictionary. This modifies that data structure to be a simple list instead.

This required several changes through the code base:

  • Switching tape._par_info.items() to enumerate(tape._par_info)
  • Switching tape._par_info.values() into tape._par_info.

Base automatically changed from qscript to master October 20, 2022 17:47
@codecov
Copy link

codecov bot commented Oct 21, 2022

Codecov Report

Merging #3185 (5fc88ef) into master (f5d1e68) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3185      +/-   ##
==========================================
- Coverage   99.69%   99.69%   -0.01%     
==========================================
  Files         275      275              
  Lines       24014    24012       -2     
==========================================
- Hits        23940    23938       -2     
  Misses         74       74              
Impacted Files Coverage Δ
pennylane/circuit_graph.py 93.06% <100.00%> (ø)
pennylane/gradients/gradient_transform.py 100.00% <100.00%> (ø)
pennylane/gradients/parameter_shift_cv.py 99.59% <100.00%> (ø)
pennylane/tape/qscript.py 100.00% <100.00%> (ø)
pennylane/tape/tape.py 97.58% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@albi3ro albi3ro added the review-ready 👌 PRs which are ready for review by someone from the core team. label Oct 24, 2022
Copy link
Contributor

@AlbertMitjans AlbertMitjans left a comment

Choose a reason for hiding this comment

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

Just one comment:

The docstring of QuantumScript._update_trainable_params should be updated:

def _update_trainable_params(self):
    """Set the trainable parameters

    Sets:
        _trainable_params (list[int]): Script parameter indices of trainable parameters

    self._par_info.keys() is assumed to be sorted and up to date when calling
    this method. This assumes that self._par_info was created in a sorted manner,
    as in _update_par_info.

    Call `_update_par_info` before `_update_trainable_params`
    """

albi3ro and others added 2 commits October 25, 2022 10:59
Co-authored-by: Albert Mitjans <a.mitjanscoma@gmail.com>
Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Looks good! 👏

pennylane/tape/qscript.py Outdated Show resolved Hide resolved
@albi3ro albi3ro merged commit 22402ce into master Oct 25, 2022
@albi3ro albi3ro deleted the par_info_list branch October 25, 2022 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants