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

Remove pulse scoped_parameters and search_parameters #11692

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

wshanks
Copy link
Contributor

@wshanks wshanks commented Jan 31, 2024

The scoped_parameters and search_parameters methods have been removed from the ScheduleBlock class. These methods returned Parameter objects that partially linked to the parameters in the ScheduleBlock instance but assigning values using these objects did not work correctly. Users should use ScheduleBlock.parameters instead and iterate through ScheduleBlock.references and compare to the Schedule.parameters attributes of the subreferences when needing to distinguish which subroutine a parameter is used in. See #11654 for more information.

The code removal itself was straightforward here because the relevant methods were not used anywhere else except the tests. For the tests, it was a little tricky because I didn't want to remove logic that was testing schedule references. Where I could, I changed the scoped parameter checks to regular parameter checks. I might have kept more tests than needed. I added one test for assignment to a parameter in a subroutine since not having such a test was why #11654 was not found earlier.

The documentation was also tricky because the scoped parameters were used to document some of the features of schedule references. I tried to pull out the discussion of scoped parameters while leaving the examples of assigning references. I substituted in some use of regular parameters (changed to have distinguishable names) just as a way to show that data from the subroutine was available in the caller after the assignment.

Related deprecation in #11691.

@wshanks wshanks requested review from eggerdj and a team as code owners January 31, 2024 20:45
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core
  • @nkanazawa1989

@wshanks wshanks added the mod: pulse Related to the Pulse module label Jan 31, 2024
@wshanks wshanks added this to the 1.0.0 milestone Jan 31, 2024
@coveralls
Copy link

coveralls commented Jan 31, 2024

Pull Request Test Coverage Report for Build 7736372337

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 116 unchanged lines in 11 files lost coverage.
  • Overall coverage decreased (-0.2%) to 89.324%

Files with Coverage Reduction New Missed Lines %
qiskit/primitives/containers/estimator_pub.py 2 97.53%
qiskit/primitives/containers/sampler_pub.py 2 97.01%
qiskit/qasm3/init.py 2 94.74%
crates/qasm2/src/lex.rs 3 92.44%
qiskit/primitives/statevector_estimator.py 3 94.55%
qiskit/init.py 4 90.48%
qiskit/primitives/containers/bindings_array.py 9 92.37%
qiskit/primitives/containers/observables_array.py 10 90.63%
qiskit/qasm3/exporter.py 11 94.97%
qiskit/qasm3/printer.py 16 88.89%
Totals Coverage Status
Change from base Build 7732338312: -0.2%
Covered Lines: 60098
Relevant Lines: 67281

💛 - Coveralls

@wshanks wshanks added the Changelog: Removal Include in the Removed section of the changelog label Jan 31, 2024
The `scoped_parameters` and `search_parameters` methods have been
removed from the `ScheduleBlock` class. These methods returned
`Parameter` objects that partially linked to the parameters in the
`ScheduleBlock` instance but assigning values using these objects did not
work correctly. Users should use `ScheduleBlock.parameters` instead and
iterate through `ScheduleBlock.references` and compare to the
`Schedule.parameters` attributes of the subreferences when needing to
distinguish which subroutine a parameter is used in. See
Qiskit#11654 for more information.
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

I guess my main comments are really #11691 (review) and #11691 (comment).

The scale of the necessary documentation changes here worries me that these methods might be more widely used, and their removal maybe shouldn't be rushed in, but I don't know pulse users, and I'll defer to @wshanks and @nkanazawa1989 as code-owners - there is of course the giant mitigating circumstance that these methods probably didn't work for their intended use case before (which tbh is not great that we didn't spot...).

Other than that, the removal looks generally ok, and it's good to increase the test coverage for the actual assignment, thanks Will.

Comment on lines 4 to 12
The ``scoped_parameters`` and ``search_parameters`` methods have been
removed from the `.ScheduleBlock` class. These methods returned
`.Parameter` objects that partially linked to the parameters in the
`.ScheduleBlock` instance but assigning values using these objects did not
work correctly. Users should use `.ScheduleBlock.parameters` instead and
iterate through `.ScheduleBlock.references` and compare to the
`.Schedule.parameters` attributes of the subreferences when needing to
distinguish which subroutine a parameter is used in. See `#11654
https://github.com/Qiskit/qiskit/issues/11654`__ for more information.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The ``scoped_parameters`` and ``search_parameters`` methods have been
removed from the `.ScheduleBlock` class. These methods returned
`.Parameter` objects that partially linked to the parameters in the
`.ScheduleBlock` instance but assigning values using these objects did not
work correctly. Users should use `.ScheduleBlock.parameters` instead and
iterate through `.ScheduleBlock.references` and compare to the
`.Schedule.parameters` attributes of the subreferences when needing to
distinguish which subroutine a parameter is used in. See `#11654
https://github.com/Qiskit/qiskit/issues/11654`__ for more information.
The ``scoped_parameters`` and ``search_parameters`` methods have been
removed from the :class:`.ScheduleBlock` class. These methods returned
:class:`.Parameter` objects that partially linked to the parameters in the
:class:`.ScheduleBlock` instance but assigning values using these objects did not
work correctly. Users should use :attr:`.ScheduleBlock.parameters` instead and
iterate through :attr`.ScheduleBlock.references` and compare to the
:attr:`.Schedule.parameters` attributes of the subreferences when needing to
distinguish which subroutine a parameter is used in. See `#11654
<https://github.com/Qiskit/qiskit/issues/11654>`__ for more information.

Copy link
Member

Choose a reason for hiding this comment

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

Lint is just complaining about a now-unused import re at the top of this file, I think.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

This looks ok to me. I'll approve and tag for merge to get things moving, but I'm not knowledgeable about the pulse module, so I don't know much about the documentation. If another pulse maintainer spots problems in it, let's open a new PR after 1.0.0rc1 is out to correct the documentation.

@jakelishman jakelishman added this pull request to the merge queue Feb 1, 2024
Merged via the queue into Qiskit:main with commit 58188de Feb 1, 2024
12 checks passed
@wshanks wshanks deleted the remove-parameter-scoping branch February 1, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Removal Include in the Removed section of the changelog mod: pulse Related to the Pulse module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants