-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
) * 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
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:
|
|
d162af9
to
2e5eee5
Compare
There was a problem hiding this 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 :)
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
4ceb9e6
to
12f5a50
Compare
There was a problem hiding this 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.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
releasenotes/notes/remove-deprecated-code-in-0.22.0-139fa09ee0cc6df9.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/remove-deprecated-code-in-0.22.0-139fa09ee0cc6df9.yaml
Outdated
Show resolved
Hide resolved
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]>
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! |
Pull Request Test Coverage Report for Build 6396275891
💛 - Coveralls |
There was a problem hiding this 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.
|
Co-authored-by: Matthew Treinish <[email protected]>
Summary
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.