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 deprecated BackendV1 elements, including base class, providers.models and qobj modules #13793

Merged
merged 15 commits into from
Mar 5, 2025

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Feb 5, 2025

Summary

This PR builds upon (and is BLOCKED BY) the changes in #13805.
This PR removes BackendV1 and all related modules and utils. This includes:

  • from qiskit/providers:

    • BackendV1
    • BackendV2Converter
    • convert_to_target
    • BackendPropertyError
    • BackendConfigurationError
  • from qiskit/providers/models: these were BackendV1 data structures. Full module removed

    • BackendConfiguration
    • BackendProperties
    • BackendStatus
    • QasmBackendConfiguration
    • PulseBackendConfiguration
    • UchannelLO
    • GateConfig
    • PulseDefaults
    • Command
    • JobStatus
    • GateProperties
    • Nduv
  • Removed PulseQobjDef from qiskit/providers/models (this steps a bit into pulse removal realm)

  • from qiskit/qobj: Full module removed.

    • QobjExperimentHeader
    • QobjHeader
    • QasmQobj
    • QasmQobjInstruction
    • QasmQobjExperimentConfig
    • QasmQobjExperiment
    • QasmQobjConfig
    • QasmExperimentCalibrations
    • GateCalibration
    • PulseQobj
    • PulseQobjInstruction
    • PulseQobjExperimentConfig
    • PulseQobjExperiment
    • PulseQobjConfig
    • QobjMeasurementOption
    • PulseLibraryItem

Note that there were two classes defined in the qobj utils (MeasLevel and MeasReturnType) used in the result class, so they have been moved to result/models.py.

TODOs

  • Reno

Details

qiskit.exceptions.OptionalDependencyImportWarning: While trying to import 'Qiskit Aer', some components were located but raised other errors during import. You might have an incompatible version installed. Qiskit will continue as if the optional is not available.
module 'qiskit_aer' failed to import with: ImportError("cannot import name 'convert_to_target' from 'qiskit.providers' (/home/vsts/work/1/s/qiskit/providers/__init__.py)")

@ElePT ElePT changed the title [WIP] Remove deprecated qobj, pulse module, and related tools from BackendV1 [WIP] Remove deprecated BackendV1 elements, including base class, providers.models and qobj modules Feb 17, 2025
@ElePT ElePT added the on hold Can not fix yet label Feb 17, 2025
@coveralls
Copy link

coveralls commented Feb 17, 2025

Pull Request Test Coverage Report for Build 13684630517

Details

  • 29 of 67 (43.28%) changed or added relevant lines in 9 files are covered.
  • 12 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+1.1%) to 88.101%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/pulse_v2/device_info.py 0 1 0.0%
qiskit/visualization/gate_map.py 0 37 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit/pulse/calibration_entries.py 1 83.49%
qiskit/pulse/parameter_manager.py 1 96.97%
qiskit/pulse/schedule.py 1 88.03%
qiskit/utils/deprecate_pulse.py 1 94.12%
crates/circuit/src/circuit_instruction.rs 3 89.46%
crates/qasm2/src/lex.rs 5 91.73%
Totals Coverage Status
Change from base Build 13683975981: 1.1%
Covered Lines: 75167
Relevant Lines: 85319

💛 - Coveralls

@ElePT ElePT changed the title [WIP] Remove deprecated BackendV1 elements, including base class, providers.models and qobj modules Remove deprecated BackendV1 elements, including base class, providers.models and qobj modules Feb 17, 2025
@ElePT ElePT marked this pull request as ready for review February 17, 2025 16:14
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

@ElePT ElePT removed the on hold Can not fix yet label Mar 3, 2025
@eliarbel
Copy link
Contributor

eliarbel commented Mar 3, 2025

Oops, just another qobj_id escape :-) I would remove it:

'qobj_id': ', '.join(x.name for x in self.circuits),

ElePT and others added 4 commits March 3, 2025 14:13
… Remove json decoding utils that weren't part of the public API and flew under the radar in the Fake Backend removal PR.
Comment on lines -34 to -46
class MeasReturnType(str, Enum):
"""PulseQobjConfig meas_return allowed values."""

AVERAGE = "avg"
SINGLE = "single"


class MeasLevel(IntEnum):
"""MeasLevel allowed values."""

RAW = 0
KERNELED = 1
CLASSIFIED = 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Will a warning about the move of these get into 1.4? It might be worth importing these back here from the new location, maybe with a module level __getattr__ to warn about the move since it is close to 2.0 and these are referenced in other packages.

Copy link
Contributor

Choose a reason for hiding this comment

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

My comment was made assuming MeasLevel and MeasReturnType were still public but I see now that they are in qiskit.result.model and not added to the docs. Are they not intended to be public any more?

Copy link
Contributor Author

@ElePT ElePT Mar 4, 2025

Choose a reason for hiding this comment

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

Hmm I see. I wasn't aware of the external use of these classes, I treated them as an internal migration. They were not part of the docs, not even in the original location, and they were buried among other outdated utilities so I didn't think they would be used externally. Now taking a closer look, they were probably intended to be public even though they technically weren't. Thanks for pointing this out @wshanks.

Copy link
Contributor Author

@ElePT ElePT Mar 4, 2025

Choose a reason for hiding this comment

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

See 27c2c63. I added a note specifying the old and new import paths. As for the deprecation warning, it was discussed internally and it is not in scope for an internal API. For external devs, the reno should contain the migration info. For IBM internal devs, I can help migrate. So far I have seen qiskit-experiments and qiskit-ibm-runtime importing these classes, let me know if you are aware of others.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, @ElePT! I missed the fact that this was always internal before with my previous messages 🤦‍♂️ With the commit you mentioned, you added these classes to qiskit.result but didn't add them to the docs. Will they still be considered private going forward?

I checked qiskit-experiments' usage and it only uses = and == with the enum members so I think we could redefine the enums internally if necessary. I was a little worried about some of the other enum features like in where using two definitions of the enum might not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I confirmed that they will stay private. I think that vendoring them in qiskit-experiments would be a good idea moving forward.

@mtreinish mtreinish added priority: high Changelog: Removal Include in the Removed section of the changelog labels Mar 4, 2025
mtreinish pushed a commit to Qiskit/qiskit-neko that referenced this pull request Mar 5, 2025
…55)

BackendV1 and qiskit.qobj removals in Qiskit/qiskit#13793 cause the test in qiskit_neko/tests/experiments/test_tomography.py to fail. This is part of the tests that are blocking the Qiskit/qiskit#13793 and Qiskit/qiskit#13872 PR in Qiskit from being merged.

There is a PR in Qiskit Experiments that address these removals: qiskit-community/qiskit-experiments#1526. Until it is merged, we need to skip this failing test.

Tracked in #54
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.

Overall this LGTM. Thanks for doing this! This finally finishes a process I started back in 2019 with #3383 of trying to clean up these interfaces. I'm glad to see that 4 years later we're finally able to remove this legacy code from Qiskit. This is incredibly satisfying to see.

I just had a couple small comments inline. I thinkt he only one that needs an update is the release notes one though.

@@ -21,7 +21,7 @@
provider is anything that provides an external service to Qiskit. The typical
example of this is a Backend provider which provides
:class:`~qiskit.providers.Backend` objects which can be used for executing
:class:`~qiskit.circuit.QuantumCircuit` and/or :class:`~qiskit.pulse.Schedule`
Copy link
Member

Choose a reason for hiding this comment

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

This PR doesn't remove schedules yet but it's fine. :)

Comment on lines -292 to -297
If migrating a provider from :class:`~qiskit.providers.BackendV1`
one thing to keep in mind is for
backwards compatibility you might need to add a configuration method that
will build a :class:`~qiskit.providers.models.BackendConfiguration` object
and :class:`~qiskit.providers.models.BackendProperties` from the attributes
defined in this class for backwards compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

We could have left this comment in the docstring because someone could conceivably be migrating from BackendV1 post removal (as part of fixing 2.0 compatibility). But it also is fine to remove it since this lives in the 1.4 docs.

@@ -138,7 +138,7 @@ def draw(self, renderer):

class Bloch:
"""Class for plotting data on the Bloch sphere. Valid data can be
either points, vectors, or qobj objects.
Copy link
Member

Choose a reason for hiding this comment

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

lol, what!? There is nothing that ever took a qobj here afaik.

Comment on lines +4 to +7
The ``BackendV1`` model has been removed following its deprecation in
Qiskit 1.2.0. This includes the ``BackendV1`` class as well as related
modules and utils, as they have been superseded by the :class:`.BackendV2`
model. The list of removed items includes:
Copy link
Member

Choose a reason for hiding this comment

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

You might want to mention this also includes things that previously could accept a backend v1 object like generate_preset_pass_manager etc.

legacy ``BackendV1`` components (such as ``BackendConfiguration`` or ``BackendProperties``)

* ``BackendPropertyError`` and ``BackendConfigurationError``: exceptions linked to removed classes

Copy link
Member

Choose a reason for hiding this comment

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

I think there are a couple of removals missing here. The ones I caught are:

  • Target.from_configuration() backend_properties` arg
  • target_to_backend_properties

I might have missed others though.

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.

LGTM, thanks for the quick update.

@mtreinish mtreinish enabled auto-merge March 5, 2025 20:11
@mtreinish mtreinish added this pull request to the merge queue Mar 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 5, 2025
@ElePT ElePT added this pull request to the merge queue Mar 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 5, 2025
@mtreinish mtreinish added this pull request to the merge queue Mar 5, 2025
Merged via the queue into Qiskit:main with commit 9c00a93 Mar 5, 2025
20 checks passed
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 priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove BackendV1 and related dependencies, deprecated in 1.2 Remove qobj, deprecated in 1.2
6 participants