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 get_dt_from_backend func to the builder command #10253

Merged
merged 33 commits into from
Jul 18, 2023

Conversation

to24toro
Copy link
Contributor

@to24toro to24toro commented Jun 11, 2023

Summary

Added a new buillder command get_dt_from_backend to builder.py.
This returns dt differently based with the type of a backend class.

Details and comments

Need to review after #10150.

@to24toro to24toro requested review from a team, eggerdj, wshanks and ikkoham as code owners June 11, 2023 02:15
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @ikkoham
  • @nkanazawa1989

@to24toro to24toro changed the title Feature/add get dt from backend Adding get dt from backend Jun 11, 2023
@to24toro to24toro changed the title Adding get dt from backend Adding get_dt_from_backend func to the builder command Jun 11, 2023
@coveralls
Copy link

coveralls commented Jun 11, 2023

Pull Request Test Coverage Report for Build 5542245283

  • 9 of 9 (100.0%) changed or added relevant lines in 1 file are covered.
  • 11 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.004%) to 86.004%

Files with Coverage Reduction New Missed Lines %
qiskit/extensions/quantum_initializer/squ.py 2 80.0%
crates/qasm2/src/lex.rs 3 91.14%
crates/qasm2/src/parse.rs 6 97.58%
Totals Coverage Status
Change from base Build 5541406727: 0.004%
Covered Lines: 71753
Relevant Lines: 83430

💛 - Coveralls

@to24toro to24toro changed the title Adding get_dt_from_backend func to the builder command Add get_dt_from_backend func to the builder command Jun 12, 2023
@nkanazawa1989 nkanazawa1989 self-assigned this Jun 12, 2023
@nkanazawa1989 nkanazawa1989 added Changelog: New Feature Include in the "Added" section of the changelog mod: pulse Related to the Pulse module labels Jun 12, 2023
Copy link
Collaborator

@TsafrirA TsafrirA left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

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

Thanks @to24toro , I think this simplifies internals of logic requiring backend dt. However, I have a suggestion for different approach.

Note that the pulse builder already supports commands seconds_to_samples and samples_to_seconds, and end user doesn't require the dt information other than converting time unit. This makes me think get_dt_from_backend doesn't need to be a builder command. Instead, you can implement a method to return backend dt directly in the _PulseBuilder class, e.g. _PulseBuilder.time_resolution, and let seconds_to_samples and samples_to_seconds access this method through _active_builder function?

https://github.com/Qiskit/qiskit-terra/blob/e9f8b7c50968501e019d0cb426676ac606eb5a10/qiskit/pulse/builder.py#L1021

Since _PulseBuilder is a private class, its method is much more maintainable compared with the public builder command.

@to24toro
Copy link
Contributor Author

to24toro commented Jul 5, 2023

@nkanazawa1989
Can I remove the release note because my change only affects the private class _PulseBuilder and has minimal impact on users?

@@ -0,0 +1,4 @@
---
features:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this note because this is now change in the internals (the builder class is protected) so there is no need for end user communication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed at 8effc99.

Copy link
Contributor

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

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

Thanks this makes code much readable and clean.

@nkanazawa1989 nkanazawa1989 added this pull request to the merge queue Jul 18, 2023
Merged via the queue into Qiskit:main with commit 35eaf83 Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: pulse Related to the Pulse module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants