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

Removed code deprecated in 0.22 [transpiler and providers] #10872

Merged
merged 14 commits into from
Oct 19, 2023

Conversation

Matrixmang0
Copy link
Contributor

@Matrixmang0 Matrixmang0 commented Sep 20, 2023

Summary

* Removed the argument 'qubit_channel_mapping' in the class 'qiskit.transpiler.passes.calibration.rzx_builder.RZXCalibrationBuilder'

* Replaced the argument 'qobj[Qobj]' in 'qiskit.providers.aer.QasmSimulator.run()' with 'qcirc[QuantumCircuit]'

* Altered the test files accordingly

* Added a release note

Details and comments

This PR addresses issue #10813. It involves the removal of the qubit_channel_mapping argument from the RZXCalibrationBuilder class and provides a migration example in the release notes. Additionally, this also replaces the qobj argument [Qobj object], has been replaced with qcirc [QuantumCircuit object]. Tests that conflicted with these changes have been modified to accommodate this adjustment.

The test file test_basicaer_qobj_headers.py has been removed, which previously checked for the header component passed into the qobj object and whether it could be retrieved through the result object. Since we are removing the qobj itself, this test can be disregarded, hence it has been deleted, and corresponding migration instructions have been added to the release notes.

This PR has been requested to tagged as Changelog: Removal to reflect the removal deprecated components.

)

	* Removed the argument 'qubit_channel_mapping' in the class 'qiskit.transpiler.passes.calibration.rzx_builder.RZXCalibrationBuilder'

	* Replaced the argument 'qobj[Qobj]' in 'qiskit.providers.aer.QasmSimulator.run()' with 'qcirc[QuantumCircuit]'

	* Altered the test files accordingly

	* Added a release note
@Matrixmang0 Matrixmang0 requested review from jyu00 and a team as code owners September 20, 2023 21:26
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Sep 20, 2023
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

@CLAassistant
Copy link

CLAassistant commented Sep 20, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Matrixmang0 Matrixmang0 changed the title Removed code deprecated in 0.22 [transpiler and providers] (#10813) Removed code deprecated in 0.22 [transpiler and providers] Sep 21, 2023
@1ucian0 1ucian0 added the Changelog: Removal Include in the Removed section of the changelog label Sep 21, 2023
@1ucian0 1ucian0 self-assigned this Sep 22, 2023
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution. I took a look at the PR and left a few comments, let me know if anything is unclear :)

Comment on lines 7 to 14
old:
# Create an RZXCalibrationBuilder object with the qubit_channel_mapping argument
builder = RZXCalibrationBuilder(qubit_channel_mapping=[[0, 1]])
new:
# Create a target object for the Aer simulator
target = providers.aer.QasmSimulator().target()
# Create an RZXCalibrationBuilder object using the target object
builder = RZXCalibrationBuilder(target=target)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that not specifying these lines as code blocks is confusing Sphinx and breaking the lint and docs build (see the docs workflow). While you can add code blocks with the following syntax:

    Here is some reno text... For example:

    .. code-block:: python
    
      # This is a comment
      # Respecting the indentation of the code block is important
      x = 1

I think that this example may actually confuse users, as it looks like target is a direct replacement for qubit_channel_mapping, when this not the case. Given that this was a deprecation without replacement, I'd say that we don't need a migration example here. I would directly remove it and keep it simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for the feedback. Let me update the .yaml file and push the commit

Comment on lines 388 to 403
def run(self, qcirc, **backend_options):
"""Run qcirc asynchronously.

Args:
qobj (Qobj): payload of the experiment
qcirc (Union[QuantumCircuit, List[QuantumCircuit]]): circuit of the experiment
backend_options (dict): backend options
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I have understood, this deprecation was introduced when the interface of BasicAer backends (for example, QasmSimulatorPy) was updated to follow the interface of BackendV1. If you look at the BackendV1 class (link), the run method has a run_input field where you input the circuit, so it would probably make sense to use the name run_input instead of qcirc 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.

Thank you so much for pointing it out. I will make the necessary edits and push the commit for review.

Comment on lines 17 to 24
Replaced the argument `qobj[Qobj]` in :meth:`qiskit.providers.aer.QasmSimulator.run()` with `qcirc[QuantumCircuit]`

old:
# Transpile the circuit for the target simulator
simulator = QasmSimulator()
transpiled_circuit = transpile(qc, simulator)
# Assemble the transpiled circuit into a Qobj
qobj = assemble(transpiled_circuit, shots=1024)
# Run the simulation
job = simulator.run(qobj)
new:
# Transpile the circuit for the target simulator
simulator = QasmSimulator()
transpiled_circuit = transpile(qc, simulator)
# Run the simulation
job = simulator.run(transpiled_circuit, shots=1024)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also keep this second section very simple, the deprecation was already explained in the original PR (see reno here). So here, I would get rid of the "old" section and just mention that the deprecated qobj input has been removed and an example with the new use (in a code block as explained above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely will do and thank you so much for your continuous feedback. Being new to the OS contributions, all your suggestions were invaluable for me.

@Matrixmang0 Matrixmang0 requested a review from ElePT September 28, 2023 21:06
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Thanks a lot! I have added a small comment, but the changes look good to me. Because I am not that familiar with the original deprecation. I'd rather have a second reviewer check that this is the intended change (@1ucian0), especially with the qobj -> run_input rename.

Comment on lines 395 to 402
For legacy providers migrating to the new versioned providers,
provider interface a :class:`~qiskit.qobj.QasmQobj` or
:class:`~qiskit.qobj.PulseQobj` objects should probably be
supported too (but deprecated) for backwards compatibility. Be
sure to update the docstrings of subclasses implementing this
method to document that. New provider implementations should not
do this though as :mod:`qiskit.qobj` will be deprecated and
removed along with the legacy providers interface.
Copy link
Contributor

Choose a reason for hiding this comment

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

This part of the docstring doesn't look necessary 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.

Thank you once more for your assistance. I too felt the same, let me retain the original wording in the string. Your help is greatly appreciated.

Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

LGTM. A very impressive first contribution.

since the qubit_channel_mapping deprecation was introduced by @nkanazawa1989 in #8276, maybe better if he also have a look.

Similarly, #5128 by @mtreinish deprecatd the qobj support in QasmSimulatorPy. Is the removal as inteneded?

Thanks!

Matrixmang0 and others added 3 commits October 3, 2023 22:42
Formatted the docstring of .run() fnction as per the review suggestion

Co-authored-by: Luciano Bello <[email protected]>
…cc6df9.yaml


Added extra detail on the version of ``qiskit-terra`` from which ``qubit_channel_mapping`` was depreciated

Co-authored-by: Luciano Bello <[email protected]>
…cc6df9.yaml


Better formatted the release notes

Co-authored-by: Luciano Bello <[email protected]>
@Matrixmang0
Copy link
Contributor Author

LGTM. A very impressive first contribution.

since the qubit_channel_mapping deprecation was introduced by @nkanazawa1989 in #8276, maybe better if he also have a look.

Similarly, #5128 by @mtreinish deprecatd the qobj support in QasmSimulatorPy. Is the removal as inteneded?

Thanks!

Thank you for your kind words; they mean a lot. That was great encouragement for me. Special thanks to @ElePT for their guidance—it made this contribution possible. Excited to contribute more and be part of the community!

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6396275891

  • 8 of 9 (88.89%) changed or added relevant lines in 1 file are covered.
  • 13 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.01%) to 87.016%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/providers/basicaer/qasm_simulator.py 8 9 88.89%
Files with Coverage Reduction New Missed Lines %
qiskit/providers/basicaer/unitary_simulator.py 1 80.26%
crates/qasm2/src/lex.rs 6 90.91%
crates/qasm2/src/parse.rs 6 97.6%
Totals Coverage Status
Change from base Build 6394675399: -0.01%
Covered Lines: 74153
Relevant Lines: 85218

💛 - Coveralls

@1ucian0 1ucian0 added this to the 0.45.0 milestone Oct 18, 2023
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

This LGTM, thanks for taking care of this. I just caught one small mistake in the updated docstring for basicaer that I commented on inline.

I also just realized that qiskit.providers.basicaer.UnitarySimulatorPy.run() (https://github.com/Qiskit/qiskit/blob/main/qiskit/providers/basicaer/unitary_simulator.py#L206) never deprecated a Qobj input and will still support it while the qasm simulator and statevector simulator will not. I still think we should move forward with your PR, but it's something we'll want to clean up in a subsequent PR.

qiskit/providers/basicaer/qasm_simulator.py Outdated Show resolved Hide resolved
@1ucian0
Copy link
Member

1ucian0 commented Oct 19, 2023

I still think we should move forward with your PR, but it's something we'll want to clean up in a subsequent PR.

#11046

@1ucian0 1ucian0 enabled auto-merge October 19, 2023 11:50
@1ucian0 1ucian0 added this pull request to the merge queue Oct 19, 2023
Merged via the queue into Qiskit:main with commit eef868d Oct 19, 2023
13 checks passed
@Matrixmang0 Matrixmang0 deleted the remove-deprecate branch October 19, 2023 15:31
@Matrixmang0 Matrixmang0 restored the remove-deprecate branch October 19, 2023 15:31
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 Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants