-
Notifications
You must be signed in to change notification settings - Fork 67
Conversation
* Add tests executing a circuit on each fake backend Right now there is nothing in validating that we're able to use all the fake backends defined in qiskit.test.mock.backends. So when we make changes to the fake backends (or backends in general) we don't know if they work until someone goes to use them. This was especially needed for Qiskit/qiskit#4016. During the development of that PR all the tests pass but the docs builds failed because a fake backend is used in a jupyter-execute section. This commit addresses the situation by adding a simple test that just runs a simple deterministic circuit that just has some easy 1q gate run optimizations on the fake backend at each optimization level (to ensure we use all the backend properties needed for execution). This will provide us coverage over the fake backends to ensure that they at least are functional as we make changes to terra. As part of the development of these tests, 2 missing properties from the new qobj classes were added because the tests caught that they were missing. Additionally the properties json file for fake yorktown had to be updated, the properties there were incorrect when run with aer (and thus a noise model) all the results were invalid. Fixes Qiskit/qiskit#3735 * Add qiskit-aer to ci jobs To fully test the fake backend properties we need to use aer to build a noise model and run the simulation with that. This commit adds qiskit-aer to the ci configuration so that it is a vailable for these new tests. In general we don't want to rely on aer (because of the potential circular dependency) but for this case it's seems worth the tradeoff. * Reduce error rates on fake_openpulse_2q backend When running simulations with a noise model the tests were failing on fake_openpulse_2q because it was set as being too noisy. This commit drops the error rates set in the properties so we can run a circuit with a single x gate and get the expected result. * Handle simulators properly for fake backends The fake_qasm_simulator is set as a simulator, but the base fake_provider class was not setup to handle a backend which was a simulator. This commit handles this by having the fake_qasm_simulator return no properties, and also updates the run() method to not try and build a noise model for a simulator. * Adjust tests to use fake provider This commit adjusts the tests to use the fake provider to get a list of backends instead of scanning the backends module for Fake* objects. * Change fake_qasm_simulator basis to basic aer's For fake_qasm_simulator's run() method top work when aer is not installed it needs to be usable with the basic aer simulator. However, right now the basis set was closer to aer's. This commit adjusts it to be basic aer's which is LCD for running in a simulator. * Cleanup arg name for test
* Remove marshmallow from providers/ As a follow on to Qiskit/qiskit#3383 this continues the process of removing marshmallow from the provider interface in an effort to stabilize it before freezing it and introducing a new version. This commit removes all the usage of marshmallow schemas and models from the providers/ directory and replaces all the classes using it with flat classes and/or SimpleNamespace classes (if the models allowed arbitrary key value pairs). * Handle parameters correctly in GateConfig.to_dict() The parameters attribute of the GateConfig class is a list of Nduv objects not a single Nduv. So when running to_dict() on a GateConfig object it's necessary to run to_dict() on each Nduv, not the list. This commit corrects this oversight, and adds a test for it. * Fix nesting for properties.qubits.to_dict() * Fix docs * Add release notes * Fix new docs issues * Correct oversights in new classes * Handle wire protocol input for PulseLibraryItems PulseLibraryItems are normally constructed either manually or by a provider with a pulse backend. In the case of ibmq and the mock backends these are constructed from the deserialized json dicts of the response (or the stored response) from the iqx api. While the pulselibraryitem class expects a list of complex numbers, the json format for iqx sends complex numbers as a list of the form [real, imag]. To ease the transition to being able to just directly passing a list of complex numbers this commit handles the case where a PulseLibraryItem is attempted to be created with samples in the json format. When a list of lists is receieved for the samples parameter the class will convert that to an array of complex numbers. Ideally in the longer term this will not be necessary and providers (both ibmq and the fake provider) will do this conversion for us. * Update qiskit/providers/models/backendproperties.py Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com> * Don't force the 5 base job states Job statuses are often outside the 5 status that were previously defined in the marshmallow schema. This commit removes this restriction so providers can just set the status instead of overloading the class to change which status are allowed. * Fix lint Co-authored-by: Lauren Capelluto <laurencapelluto@gmail.com>
…iskit/qiskit#4129) * Revert "Moving up some parameter checks in the class hierarchy (Qiskit/qiskit#3668)" (Qiskit/qiskit#4117) This change has some unforseen backwards compatibility implications and is causing downstream projects like qiskit-aer to fail CI now. Given the pending release and this not being critical, this commit reverts this commit and we can revisit it after the 0.13.0 release. This reverts commit 5afe87ce1e5279ca716fdf5a3c478f2e27a6519f. add new fake backends * fix dt and dtm conversion by qiskit to SI * fix imports * lint * Update qiskit/test/mock/backends/armonk/fake_armonk.py Co-Authored-By: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Kevin Krsulich <kevin@krsulich.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#4124) * Add missing dict conversion in backconfiguration class After Qiskit/qiskit#4016 has merged a missed edge case in the handling of to_dict() and from_dict() for PulseBackendConfiguration was discovered via the aer unit tests. The u_channel_lo attribute is a nested object and needs to call UChannelLO's to_dict() and from_dict() methods in those respective calls. However, this conversion was not being done. This commit corrects the oversight. * Fix pulse defaults to dict There was an issue in the pulse defaults to_dict() method too where the converters attribute was incorrectly attempted to be output as a property in the output dictionary. This was incorrect and it just a helper there constructed based on other input. So outputting it with the dictionary was incorrect. This commit corrects this oversight. * Fix typo and tests * Fix typo in tests * Remove another extra defaults attribute * Update type hint Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
…gs before initializing class (Qiskit/qiskit#4728) * Add fake backends for Bogota, Montreal, and Toronto IBM Quantum has added 3 new backends recently: Bogota, Montreal, and Toronto. This commit creates new fake backends FakeBogota, FakeMontreal, and FakeToronto from snapshots of the real devices. * Refactor QobjConfiguration transformations to happen in to_dict and from_dict * Refactor PulseDefaults transformations to happen in to_dict and from_dict * Remove conversions from update fake backends scripts. * Update mock backends. Added ibmq_toronto and ibmq_montreal. * fix bug in the parametric pulse code. * Undo from_dict/init changes. * Do conversion of complex number better. * Update mock backend files. * Linting. * Add conversion tests. Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
utf-8 has been the default since PEP 3120. https://www.python.org/dev/peps/pep-3120/ Non trivial edits are to Makefile and verify_headers.py
…t#5620) * Add a lazy loading wrapper class for __qiskit_version__ This commit migrates the __qiskit_version__ module attribute away from using a dict constructed at import time to being an instance of a lazy loading class that will import the elements to get their version information only at run time if needed. This will improve the overall import performance and also reduce the possibility of introducing an import cycle when we remove namespace packaging. Related to Qiskit/qiskit#5100 and Qiskit/qiskit#5532 * Rename qiskit.execute module to qiskit.execute_function The qiskit.execute module has a name conflict with the re-exported path to it's sole public function qiskit.execute(). Whether python uses the module or the function is an import time race condition and by making the element imports occur at runtime this switches the normal evaluation to use the module instead of the function. However, this was always a bug and could have been triggered in other ways too. To make the imports deterministic either the function or the module needs to be renamed and since the module is less commonly used than the function that is renamed. * Rename qiskit.compiler inner modules to avoid name conflict The qiskit.compiler module has a name conflict with the re-exported path to public functions qiskit.compiler. Whether python uses the module or the function is an import time race condition, amd could be triggered by subtle changes in import evaluation order. To make the imports deterministic either the function or the module needs to be renamed and since the module is less commonly used than the function that is renamed. * Fix docs build * Apply suggestions from code review Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
…kit/qiskit#6286) * Update fake backend and fake provider to use versioned interface As was reported in Qiskit/qiskit#6280 the algorithms path doesn't work on minimal examples of the Backend and Jobs interface and instead only works in practice on ibmq, aer, or basic aer backends. Part of the reason for this was that all the testing of algorithms is done exclusively on those providers and there wasn't a minimal example to test against that doesn't have legacy overhead (like qobj, etc). This commit updates the fake providers and fake backends to use the latest version of the provider, backend, and job interfaces and to be strictly compatible (ie no qobj support). Besides exercising the new interface version it also enables us to test the eventual fix for Qiskit/qiskit#6280 when it's available. * Fix lint * Add legacy fake backends using BaseBackend
* make compatible with pylint and pycodestyle * black config * flake8 compatible config * Missing newline * Add black check to CI and dev requirements This commit updates the CI configuration and local tox configuration to leverage black instead of pycodestyle. It adds a check job to ci and the tox lint job so we can quickly check if black has been run. A tox job named 'black' is added to run black on all the code in the repo. * Run black on everything This commit reformats all the code in the qiskit-terra repository to use black. It changes no functionality in the project and just adjusts the code formatting to be consistent and automated. If you are looking at this commit in the git log you can likely safely ignore any diff from this commit as it is just the result of running '`black' on the repo and instead you should look at any commits before or after this for functional changes. Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
* Deprecate legacy provider interface In the 0.16.0 release we added a new versioned providers interface that included a V1 version of the Backend, Job, and Provider classes. Since then we've updated and unified almost all of the providers that exist to use the current interface. Having everything use the new interface means that we're now able to both evolve the interface in a controlled manner uniformly and also deprecate the legacy interface to signal to any other providers out there (especially those we don't maintain) that we'll only be supporting the versioned interface moving forward. * Fix lint * Run black * Add deprecation warning assertion on legacy backends tests Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Unify lazy handling of optional dependencies This introduces new `HAS_X` variables for each of Qiskit's optional dependencies, and provides a simple unified interface to them from `qiskit.utils.optionals`. These objects lazily test for their dependency when evaluated in a Boolean context, and have two `require_` methods to unify the exception handling. `require_now` tests immediately for the dependency and raises `MissingOptionalLibraryError` if it is not present, and `require_in_call` is a decorator that lazily tests for the dependencies when the function is called. These remove the burden of raising nice exceptions from the usage points; a function marked `HAS_MATPLOTLIB.require_in_call` can now safely `import matplotlib` without special handling, for example. This also provides a unified way for consumers of `qiskit` (such as the test suite) to query the presence of libraries. All tests are now lazy, and imports are moved to the point of usage, not the point of import of the module. This means that `import qiskit` is significantly faster for people who have many of the optional dependencies installed; rather than them all being loaded at initial import just to test their presence, they will now be loaded on demand. * Optimise time taken for `import qiskit` This makes several imports lazy, only being imported when they are actually called and used. In particular, no component of `scipy` is imported during `import qiskit` now, nor is `pkg_resources` (which is surprisingly heavy). No changes were made to algorithms or opflow, since these are not immediately imported during `import qiskit`, and likely require more significant work than the rest of the library. * Import missing to-be-deprecated names * Convert straggler tests to require_now * Correct requirements in test cases * Add `require_in_instance` class decorator Effectively this is just a wrapper around `__init__`, except that this class-decorator form will do the right thing even if `__init__` isn't explicitly defined on the given class. The implementation of `wrap_method` is a replacement for the older `test.decorators._wrap_method`, which didn't handle all the possible special cases as well, and messed up the documentation of its wrapped functions. That wasn't so important when it was just a private function, but now it has become public (so that `test.decorators.enforce_subclasses_call` can still use it from `qiskit.utils`), it needed reworking to be more polished. * Privatise non-public names rather than del * Add tests of `require_in_instance` * Fix typos in documentation * Add section on requirements to CONTRIBUTING * Update documentation on HoareOptimizer error * Remove UK localisation * Mention more uses of PIL in documentation Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Add fake backends for new IBM Quantum systems (Qiskit/qiskit#6808) This commit adds new fake backend classes for new IBM Quantum systems: Cairo, Hanoi, Kolkata, Nairobi, and Washington. Just as with the other fake backends these new classes contain snapshots of calibration and error data taken from the real system, and can be used for local testing, compilation and simulation. Legacy backends are not added for these new fake backends as the legacy backend interface is deprecated and will be removed in a future release so there is no need to expose that for the new backends (it was only added for compatibility testing on the old fake backends). * Update qiskit/test/mock/backends/washington/fake_washington.py Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Update releasenotes/notes/new-fake-backends-04ea9cb26374e385.yaml Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Fix lint Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…iskit#7437) * Relocate mock backends from qiskit.test.mock to qiskit.mock * Relocate mock backends from qiskit.test.mock to qiskit.mock * fix: Inline literal start-string without end-string * change package to qiskit.providers.fake_provider * fix test failure * reformat file * fix review comments * Release note is API change not feature Co-authored-by: Jake Lishman <jake@binhbar.com>
…iskit/qiskit#7839) * rename FakeMumbaiV2 to FakeMumbaiFractionalCX * add release note * improve release note
* Add backend converter script from Matthew Co-Authored-By: Matthew Treinish <mtreinish@kortar.org> * FakeBackendV2, FakeQasmBeckendV2, FakeJakartaV2 in progress * Temporary fix for circular import * First try of implementing FakeJakartaV2 based on FakeQasmBackendV2/FakeBackendV2 * Implement FakeQasmBackend methods into FakeBackendV2 * Implement FakePulseBackend methods into FakeBackendV2 * Import missing PulseDefaults and adjust _get_conf_from_json method position * Adjust _get_config_from_dict method position * Fix target property Need to take closer look at _convert_to_target method * Fix _default_options method * Add FakeProviderV2 for V2 fake backends * Remove FakeQasmBackendV2 class * Copy run method from FakeBackendV1 * change configuration to self._configuration * Update backend_converter.py Based on the latest version on Qiskit/qiskit-ibm-runtime#102 Co-Authored-By: Rathish Cholarajan <rathishc24@gmail.com> * @rathishcholarajan Use BackendConfiguration, BackendProperties and PulseDefaults classes for convert_to_target * Add dtm * Add qubit properties * Add drive, measure and acquire channels. * Fix test_fake_backends * Fix ConfigurableFakeBackend circular import problem * Fix configurable_backend circular import problem * FakeAlmadenV2 * FakeArmonkV2 * FakeAthensV2 * FakeBelemV2 * FakeBoeblingenV2 * Add fake backends (except rueschlikon, tenerife and tokyo) * import fake v2 backends in __init__.py * add fake backends to mock.backend.__init__ and fake provider * Fix typos * Add defs files to manila, poughkeepsie, rome and santiago * Fix FakeCambridgeV2 * Add Hanoi and Kolkata to FakeProviderV2 * Handle no pulse backends in V2 * Fix getting qubit properties from properties bug * Fix _parse_inst_map for BackendV2 with no pulse support * Revert "Update backend_converter.py" This reverts commit 2438935d218bf3e1059bef185d77c426cc0978d3. * Revert " @rathishcholarajan Use BackendConfiguration, BackendProperties and PulseDefaults classes for convert_to_target" This reverts commit eec4a49f590399c15a90c4579844009cc9d0dc20. * Use dicts instead of conf, props, defs objects * remove channels * add type hints * Use dict.get instead of brackets * clean up backend_converter.py * construct target using defs files if it exist * Fix typo in target.acquire_alignment * Handle BackendV2 in transpiler._parse_inst_map * Comment out backends in fake provider and Aer run method for testing * undo typo fix for target.acquire_alignment * Revert "Comment out backends in fake provider and Aer run method for testing" This reverts commit 2127b345b63e9dea1bbdbd44b397f1d14089213b. * Copy NoiseModel.from_backend() method from Aer * modify NoiseModel.from_backend method to support V2 backend * Build V2 backend noise model from self._props_dict * black reformatting * Move V2 backend code to above V1 and Legacy * Clean up FakeBackendV2 for testing * Order FakeBackendV2 to match BackendV2 * Uncomment out fake backends from fake provider v1 and fake legacy provider * Remove unused imports * Remove FakeTokyoV2 import * Remove warnings for missing conf, props and defs files * Remove lazy loading of target * Remove lazy loading of qubit properties * Remove deprecation warning for standard_gates option in noise model * linting for fake_backend.py * linting for backend_converter.py * fix `Redefining name 'warnings' from outer scope` error * lint: rename qubit_props_dict_from_props_dict * Raise error for pulse simulation * remove warnings flag * Move V2 to in front of V1 * revert changes in transpiler._parse_inst_map The changes are now in a separate PR: Qiskit/qiskit#7765 * remove warnings flag * fix 'no-else-raise' error * Add docstring to FakeBackendV2 * rename `kwargs` to `options` in .run method following BackendV2 * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * rearrange raising error for pulse job * Add a TODO comment for removing PulseDefaults * fix typo * black reformat * Add release note. * Fix no else raise error * Add blank new line in release note * black formatting * fix release note missing black tick * Rename FakeProviderV2 to FakeProviderForBackendV2 * Re-export FakeProviderForBackendV2 to qiskit.providers.fake_provider * black reformatting Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Add backend converter script from Matthew Co-Authored-By: Matthew Treinish <mtreinish@kortar.org> * FakeBackendV2, FakeQasmBeckendV2, FakeJakartaV2 in progress * Temporary fix for circular import * First try of implementing FakeJakartaV2 based on FakeQasmBackendV2/FakeBackendV2 * Implement FakeQasmBackend methods into FakeBackendV2 * Implement FakePulseBackend methods into FakeBackendV2 * Import missing PulseDefaults and adjust _get_conf_from_json method position * Adjust _get_config_from_dict method position * Fix target property Need to take closer look at _convert_to_target method * Fix _default_options method * Add FakeProviderV2 for V2 fake backends * Remove FakeQasmBackendV2 class * Copy run method from FakeBackendV1 * change configuration to self._configuration * Update backend_converter.py Based on the latest version on Qiskit/qiskit-ibm-runtime#102 Co-Authored-By: Rathish Cholarajan <rathishc24@gmail.com> * @rathishcholarajan Use BackendConfiguration, BackendProperties and PulseDefaults classes for convert_to_target * Add dtm * Add qubit properties * Add drive, measure and acquire channels. * Fix test_fake_backends * Fix ConfigurableFakeBackend circular import problem * Fix configurable_backend circular import problem * FakeAlmadenV2 * FakeArmonkV2 * FakeAthensV2 * FakeBelemV2 * FakeBoeblingenV2 * Add fake backends (except rueschlikon, tenerife and tokyo) * import fake v2 backends in __init__.py * add fake backends to mock.backend.__init__ and fake provider * Fix typos * Add defs files to manila, poughkeepsie, rome and santiago * Fix FakeCambridgeV2 * Add Hanoi and Kolkata to FakeProviderV2 * Handle no pulse backends in V2 * Fix getting qubit properties from properties bug * Fix _parse_inst_map for BackendV2 with no pulse support * Revert "Update backend_converter.py" This reverts commit 2438935d218bf3e1059bef185d77c426cc0978d3. * Revert " @rathishcholarajan Use BackendConfiguration, BackendProperties and PulseDefaults classes for convert_to_target" This reverts commit eec4a49f590399c15a90c4579844009cc9d0dc20. * Use dicts instead of conf, props, defs objects * remove channels * add type hints * Use dict.get instead of brackets * clean up backend_converter.py * construct target using defs files if it exist * Fix typo in target.acquire_alignment * Handle BackendV2 in transpiler._parse_inst_map * Comment out backends in fake provider and Aer run method for testing * undo typo fix for target.acquire_alignment * Revert "Comment out backends in fake provider and Aer run method for testing" This reverts commit 2127b345b63e9dea1bbdbd44b397f1d14089213b. * Copy NoiseModel.from_backend() method from Aer * modify NoiseModel.from_backend method to support V2 backend * Build V2 backend noise model from self._props_dict * black reformatting * Move V2 backend code to above V1 and Legacy * Clean up FakeBackendV2 for testing * Order FakeBackendV2 to match BackendV2 * Uncomment out fake backends from fake provider v1 and fake legacy provider * Remove unused imports * Remove FakeTokyoV2 import * Remove warnings for missing conf, props and defs files * Remove lazy loading of target * Remove lazy loading of qubit properties * Remove deprecation warning for standard_gates option in noise model * linting for fake_backend.py * linting for backend_converter.py * fix `Redefining name 'warnings' from outer scope` error * lint: rename qubit_props_dict_from_props_dict * Raise error for pulse simulation * remove warnings flag * Move V2 to in front of V1 * revert changes in transpiler._parse_inst_map The changes are now in a separate PR: Qiskit/qiskit#7765 * remove warnings flag * fix 'no-else-raise' error * Add docstring to FakeBackendV2 * rename `kwargs` to `options` in .run method following BackendV2 * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * rearrange raising error for pulse job * Add a TODO comment for removing PulseDefaults * fix typo * black reformat * Add release note. * Fix no else raise error * Add blank new line in release note * black formatting * fix release note missing black tick * Rename FakeProviderV2 to FakeProviderForBackendV2 * Re-export FakeProviderForBackendV2 to qiskit.providers.fake_provider * black reformatting Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Remove legacy providers interface This commit removes the legacy providers interface from terra. This includes the BaseBackend, BaseJob, BaseProvider abstract classes and everything that inherits from them in the tree. These classes were deprecated as part of qiskit-terra 0.18.0 and have been supersceded by the versioned provider interface and all providers should have migrated by now to these new supported interface. This also means we no longer support the qobj execution path and QuantumCircuit and Schedule objects are used directly everywhere for running. In the future we can look at deprecating and removing the assemble() function and qobj class in the future as nothing in tree is using them directly. But before we can deprecate these the IBM provider and aer will need to have native implementations. * Drop handling for incorrect backend.version in BaseBackend Now that BaseBackend is no longer in qiskit we don't need to special handle the case where backend.version is not the interface version (since it was a method in BaseBackend). This commit drops the handling for this and uses the interface for the versioned interface as it was originally intended. * Fix lint * Fix typo causing test failures The tests were failing because one of the default values for getting the backend version attribute was None instead of 0 causing a type error when an integer was expected. This was not caught previously because the BaseBackend handling checked for non integer versions and converted those to 0. However, now without BaseBackend we need to be more explicit and use an integer for the backend interface version. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Remove legacy providers interface This commit removes the legacy providers interface from terra. This includes the BaseBackend, BaseJob, BaseProvider abstract classes and everything that inherits from them in the tree. These classes were deprecated as part of qiskit-terra 0.18.0 and have been supersceded by the versioned provider interface and all providers should have migrated by now to these new supported interface. This also means we no longer support the qobj execution path and QuantumCircuit and Schedule objects are used directly everywhere for running. In the future we can look at deprecating and removing the assemble() function and qobj class in the future as nothing in tree is using them directly. But before we can deprecate these the IBM provider and aer will need to have native implementations. * Drop handling for incorrect backend.version in BaseBackend Now that BaseBackend is no longer in qiskit we don't need to special handle the case where backend.version is not the interface version (since it was a method in BaseBackend). This commit drops the handling for this and uses the interface for the versioned interface as it was originally intended. * Fix lint * Fix typo causing test failures The tests were failing because one of the default values for getting the backend version attribute was None instead of 0 causing a type error when an integer was expected. This was not caught previously because the BaseBackend handling checked for non integer versions and converted those to 0. However, now without BaseBackend we need to be more explicit and use an integer for the backend interface version. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…it#8000) * Multilpy dt value by conversion factor when reading from conf file. * Add simple test and release note. * Update releasenotes/notes/fix-target-dt-4d306f1e9b07f819.yaml Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
* Add missing delay instruction to fake backends This commit adds the delay instruction to the target for fake backends based on BackendV2. With BackendV2 and the Target delay isn't assumed to be present on every backend and it has to be explictly listed. This commit fixes this so that the compiler is aware that delay is a valid operation (without any additional constraints) on the BackendV2 based fake backends. * Add qubits to Delay target entry If any instructions available in a target are ideal, with no qubits or properties set, the target class assumes the backend is ideal (like in the case of an ideal simulator where are all instructions are globally defined and have no error or duration). To avoid this we need to define the Delay instruction on all qubits explicitly. This commit makes this change to ensure the target for backends still shows the qubits and properties for the other operations. However, in adding an instruction with no properties defined a bug in the plot gate error map function was uncovered where it errored because it assumes all instructions have properties defined, this was fixed at the same time. * Add release note * Update releasenotes/notes/delay-fake-backends-3f68c074e85d531f.yaml Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* convert dtm from nanoseconds to seconds * Handle dtm not defined in configuration * Add test for checking backend v2 dtm less than 1e-6 * add release note * new line in release note * Update qiskit/test/mock/fake_backend.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…cate (Qiskit/qiskit#8121) * redirect imports from qiskit.test.mock to qiskit.providers.fake_provider * import the rest of classes in fake_backend_v2 to fake_provider * redirect imports to fake_provider Anything that can be imported from fake_provider root are imported from there instead of sub files. * change jupyter-execute to code-block * redirect import * Combine multiple imports into one * Add missing ) * move all files except __init__ from qiskit.test.mock to qiskit.providers.fake_provider * redirect imports in fake_provider.__init__.py * redirect imports in mock.__init__.py * Use relative imports in fake_provider.__init__.py * redirect .utlis imports * Don't import fake_backend_v2.py in __init__ to avoid clashes of FakeBackendV2 names * Match imports from the old and new __init__ * Organize imports * black linting * Fix FakePulseBackend import order dependency * fix cyclic import * move relative import after absolute import * fix cyclic import * Update MANIFEST.ini with new path * add deprecation warning * add deprecation test * add release note * move test files from test.python.mock to test.python.providers.fake_provider * linting * linting * change deprecation warning location * update path for tools/update_fake_backends.py * rename docstrings * Update ibmq_mock.py * import back FakeBackendV2 and FakeBackend5QV2 in __init__ * Modify release note * reformat release note * remove unnecessary tests These two tests were introduced in PR Qiskit/qiskit#7437 to test the new imports which are not needed any more: Qiskit/qiskit#7437 (comment) * Use relative imports * redirect import in test_schedular.py * first draft of module level doc * Update docstring of fake provider v1 and v2 * Update wording of module level doc * add fake V1 and V2 backends * Correct fake v1 and v2 backends in the list * comment on backends that do not have V2 versions * list special fake backends * Add descriptions for sections * add code example using jupyter execute * Update code example and improve descriptions of the module * not using fake provider before fake provider get backend name is fixed * modify comment * formating fix * Remove fake backend coupling map from docstrings * linting * remove coupling map of Pooughkeepsie * add qiskit-aer to tox.ini as deps for docs build * Revert "remove coupling map of Pooughkeepsie" This reverts commit 45607489303fde0e65e550f117735ec4f468ff3d. * Revert "linting" This reverts commit eddfa65bf6f65f076c7eff4d1a20bb251c56658b. * Revert "Remove fake backend coupling map from docstrings" This reverts commit 3aee7a8b57e8ea248ede0bec9db67e02dcb08eed. * fix coupling maps * Fix minor typos * Issue deprecation warnings from all levels of package The previous commits in this PR did not maintain the old import paths for submodules of `qisit.test.mock`. This re-instatates them, with suitable deprecation warnings. Hopefully nobody is using these anyway, but it's better to be on the safe side. * Import from the correct location Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…cate (Qiskit/qiskit#8121) * redirect imports from qiskit.test.mock to qiskit.providers.fake_provider * import the rest of classes in fake_backend_v2 to fake_provider * redirect imports to fake_provider Anything that can be imported from fake_provider root are imported from there instead of sub files. * change jupyter-execute to code-block * redirect import * Combine multiple imports into one * Add missing ) * move all files except __init__ from qiskit.test.mock to qiskit.providers.fake_provider * redirect imports in fake_provider.__init__.py * redirect imports in mock.__init__.py * Use relative imports in fake_provider.__init__.py * redirect .utlis imports * Don't import fake_backend_v2.py in __init__ to avoid clashes of FakeBackendV2 names * Match imports from the old and new __init__ * Organize imports * black linting * Fix FakePulseBackend import order dependency * fix cyclic import * move relative import after absolute import * fix cyclic import * Update MANIFEST.ini with new path * add deprecation warning * add deprecation test * add release note * move test files from test.python.mock to test.python.providers.fake_provider * linting * linting * change deprecation warning location * update path for tools/update_fake_backends.py * rename docstrings * Update ibmq_mock.py * import back FakeBackendV2 and FakeBackend5QV2 in __init__ * Modify release note * reformat release note * remove unnecessary tests These two tests were introduced in PR Qiskit/qiskit#7437 to test the new imports which are not needed any more: Qiskit/qiskit#7437 (comment) * Use relative imports * redirect import in test_schedular.py * first draft of module level doc * Update docstring of fake provider v1 and v2 * Update wording of module level doc * add fake V1 and V2 backends * Correct fake v1 and v2 backends in the list * comment on backends that do not have V2 versions * list special fake backends * Add descriptions for sections * add code example using jupyter execute * Update code example and improve descriptions of the module * not using fake provider before fake provider get backend name is fixed * modify comment * formating fix * Remove fake backend coupling map from docstrings * linting * remove coupling map of Pooughkeepsie * add qiskit-aer to tox.ini as deps for docs build * Revert "remove coupling map of Pooughkeepsie" This reverts commit 45607489303fde0e65e550f117735ec4f468ff3d. * Revert "linting" This reverts commit eddfa65bf6f65f076c7eff4d1a20bb251c56658b. * Revert "Remove fake backend coupling map from docstrings" This reverts commit 3aee7a8b57e8ea248ede0bec9db67e02dcb08eed. * fix coupling maps * Fix minor typos * Issue deprecation warnings from all levels of package The previous commits in this PR did not maintain the old import paths for submodules of `qisit.test.mock`. This re-instatates them, with suitable deprecation warnings. Hopefully nobody is using these anyway, but it's better to be on the safe side. * Import from the correct location Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* adding FakePerth * Update releasenotes/notes/ibm_perth-5b1e9308dc302e2e.yaml * Mock over Fake * remove V1 * removing v2 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* adding FakeOslo * Update releasenotes/notes/fake_oslo-7bba98d7269f959b.yaml * only v2 * put FakePerth back
* adding FakePerth * Update releasenotes/notes/ibm_perth-5b1e9308dc302e2e.yaml * adding FakeAuckland This PRs adds FakeAuckland based on ibm_auckland. * V1 removed * Mock over Fake * remove V1 * removing v2 * remove v2 name Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* conf_geneva * reno * adding to the test * order * calibration data 2022-07-12 15:40:30+02:00 * calibration from 2022-06-24 23:00:30+02:00 * Update releasenotes/notes/ibm_geneva-5b1e9308dc302e2e.yaml * remove v1 * reno new Co-authored-by: Junye Huang <h.jun.ye@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…kit/qiskit#8759) * Add BackendV2Convert class for treating BackendV1 as BackendV2 This commit adds a new class BackendV2Converter which is a BackendV2 implementation that converts an input BackendV1 object into a BackendV2 implementation. This is useful for users that are supporting working with arbitrary providers so that they can standardize on using the newest access patterns even if a provider is still using BackendV1. Similarly, for qiskit's internal usage, this gives us a path to move all of the transpiler internals to use Target and avoid carrying around duplicate information in the PassManagerConfig for passes that haven't been updated. This will enable us to convert input BackendV1 instances to a target once on initial calling and have the transpiler only ever see a target. Fixes Qiskit/qiskit#8611 * Update docstring * Return empty options for _default_options * Remove leftover pylint disable * Expand standard gate conversions and handle missing basis_gates * Fix copy paste error qubit_props_list_from_props() docstring * Add name mapping argument to allow setting custom name-> gate mappings for conversion * Add missing gamma parameter * Fix handling of global ops in configuration * Raise exception on custom gates without mapping * Move name mapping to standard gates module * Fix lint and docs * Use gate object name attribute to build name mapping Co-authored-by: Jake Lishman <jake.lishman@ibm.com> * Fix lint * Fix pylint cyclic-import error * Update qiskit/providers/backend_compat.py Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com> * Remove supported_instructions and add option for adding delay The supported instructions field is underdocumented and it's not clear that the instructions it contains are something that we want to support directly. Since the only reason we added support for it in the target generation was to handle the delay for ibm backends (mostly in tests as the IBM provider will be using BackendV2 natively soon) this commit removes its usage and adds a new flag for explicitly adding delay to the backend's target. * Add mention of converter class to API changes section * Add missing flag usage to delay test * Run black Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
* Remove pulse defaults for old fake 20q backends The pulse defaults payload for the almaden, johannesburg, and singapore fake backends are collectively taking up > 50% of the total disk footprint of an installed copy of Qiskit. This is because the pusle defaults for these backends predate the use the of parameterized pulse definitions and contain arrays of sampled waveforms for the pulse definitions. This exceedingly large file size slows down the entire package and and makes it slower to install. When weighing the potential value these defaults files provide for simulating and compiling with pulse awareness for long retired devices against the real cost of having the files included in the package there isn't a reason to keep the files in the tree any longer. This commit removes the pulse defaults files for these fake backends to greatly shrink the installed package size of qiskit-terra. * Update releasenotes/notes/remove-pulse-defs-old-20q-4ed46085b4a15678.yaml * Update tests and docs Several tests and docs were relying on the pulse data being present in the fake backends. This commit updates the tests and docs to avoid this and either rely on different fake backends that use parametric pulses or not rely on a fake backend at all. In one case a bug is fixed the assembler which was causing the tests to incorrectly pass because the use of pulse backends without parametric pulses was masking incorrect behavior. * Revert passmanager config string test changes * Remove self.maxDiff in str test * Fix missing backtick Co-authored-by: Jake Lishman <jake@binhbar.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…it#10015) This commit fixes an issue with the filter_faulty and add_delay flag were both set on the BackendV2Converter and convert_to_target flag. In these cases the function would incorrectly add delay operations to the faulty qubits even though they should have no operations preset on them. This commit fixes the oversight to ensure that no operations are present on a qubit if it's listed as non-operational in an input BackendProperties.
…skit#10291) * Remove list argument broadcasting and simplify transpile() This commit updates the transpile() function to no longer support broadcast of lists of arguments. This functionality was deprecated in the 0.23.0 release. As part of this removal the internals of the transpile() function are simplified so we don't need to handle broadcasting, building preset pass managers, parallel dispatch, etc anymore as this functionality (without broadcasting) already exists through the transpiler API. Besides greatly simplifying the transpile() code and using more aspects of the public APIs that exist in the qiskit.transpiler module, this commit also should fix the overhead we have around parallel execution due to the complexity of supporting broadcasting. This overhead was partially addressed before in Qiskit/qiskit#7789 which leveraged shared memory to minimize the serialization time necessary for IPC but by using `PassManager.run()` internally now all of that overhead is removed as the initial fork will have all the necessary context in each process from the start. Three seemingly unrelated changes made here were necessary to support our current transpile() API without building custom pass manager construction. The first is the handling of layout from intlist. The current Layout class is dependent on a circuit because it maps Qubit objects to a physical qubit index. Ideally the layout structure would just map virtual indices to physical indices (see Qiskit/qiskit#8060 for a similar issue, also it's worth noting this is how the internal NLayout and QPY represent layout), but because of the existing API the construction of a Layout is dependent on a circuit. For the initial_layout argument when running with multiple circuits to avoid the need to broadcasting the layout construction for supported input types that need the circuit to lookup the Qubit objects the SetLayout pass now supports taking in an int list and will construct a Layout object at run time. This effectively defers the Layout object creation for initial_layout to run time so it can be built as a function of the circuit as the API demands. The second is the FakeBackend class used in some tests was constructing invalid backends in some cases. This wasn't caught in the previous structure because the backends were not actually being parsed by transpile() previously which masked this issue. This commit fixes that issue because PassManagerConfig.from_backend() was failing because of the invalid backend construction. The third issue is a new _skip_target private argument to generate_preset_pass_manager() and PassManagerConfig. This was necessary to recreate the behavior of transpile() when a user provides a BackendV2 and either `basis_gates` or `coupling_map` arguments. In general the internals of the transpiler treat a target as higher priority because it has more complete and restrictive constraints than the basis_gates/coupling map objects. However, for transpile() if a backendv2 is passed in for backend paired with coupling_map and/or basis_gates the expected workflow is that the basis_gates and coupling_map arguments take priority and override the equivalent attributes from the backend. To facilitate this we need to block pulling the target from the backend This should only be needed for a short period of time as when Qiskit/qiskit#9256 is implemented we'll just build a single target from the arguments as needed. Fixes Qiskit/qiskit#7741 * Fix _skip_target logic * Fix InstructionScheduleMap handling with backendv2 * Fix test failure caused by exception being raised later * Fix indentation error * Update qiskit/providers/fake_provider/fake_backend.py Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix standalone dt argument handling * Remove unused code * Fix lint * Remove duplicate import in set_layout.py A duplicate import slipped through in the most recent rebase. This commit fixes that oversight and removes the duplicate. * Update release notes Co-authored-by: Jake Lishman <jake.lishman@ibm.com> * Adjust logic for _skip_transpile to check if None * Simplify check cmap code * Only check backend if it exists --------- Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
…skit#10258) * fix measure_v2 * modify measure_all * dispatch backend * add test of the builder with backendV2 * reconfigure test codes and some func * refactoring * add reno * fix _measure_v2 * fix backend.meas_map in measure_v2 * fix reno * delete get_qubit_channels from utils * add get_qubits_channels in qubit_channels * recostruct test about the builder with backendV2 * add meas_map to Target class * fix after mergin main branch * fix documents about meas_map * format target.py * add reno * add meas_map to target in convert_to_target * add the more description about meas_map * Update releasenotes/notes/enable_target_aware_meas_map-0d8542402a74e9d8.yaml Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com> * fix test_meas_map * remove format_meas_map * rename meas_map in target to concurrent_measuments * change reno * remove Unused Union Dict * concurrent_measurements set as getattr(configuration, meas_map) * Update qiskit/transpiler/target.py Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com> * Update qiskit/transpiler/target.py Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com> * format --------- Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
…kit#10547) * Fix broken documentation references in `qiskit.providers` This fixes all the broken crossreferences in the Sphinx build of `qiskit.providers`, found by using Sphinx's nitpicky mode. Leaving aside the errors due to attempted crossreferences to Python builtin and standard-library types (which are fixed in another commit), there were just over 500 errors in this module (the count inflated severely because of docstring inheritance) which are now all fixed. * Remove unneeded reference to base type * Fix broken import * Update qiskit/providers/backend.py Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> --------- Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
* big moves, import still works * most tests pass (some I cannot seem to run locally) * fix tests -- how to remove DiagonalGate? * typehints and docs * more type hints * Deprecate SQU * deprecate Snapshot * Fix missing future annotations import * minimize deprecation effort * Change to pending deprecation, no exact-location import supported * fix MCG<->MGC typo and snapshot deprecation * fix pylint, try fixing docs * remove gates from extensions toctree * Add reno, fully deprecate SQU and Snapshot * Apply Sasha's review comments - fix usage of .squ and .snapshot w/o import - fix docstring usage of extensions - fix tests * capture snapshot deprecation warning * review comments - capture warning of SQU - update reno to explicitly mention pending deprecation, add DiagonalGate and ExtensionError * missed `diagonal` method --------- Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
…9351) * Many mentions to QASM should be changed to OpenQASM2 * adjust tests * another round * suggestion in https://github.com/Qiskit/qiskit-terra/pull/9351/files#r1068676297 * https://github.com/Qiskit/qiskit-terra/pull/9351/files#r1068704441 * Normalise spacing of OpenQASM [23] --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
d347a7b
to
36086d6
Compare
Update aer imports, fix lint Revert "Remove test backends, keep provider-specific fake backends" This reverts commit 9a9af6c. Fix copyright Remove test backends, keep provider-specific fake backends Update docs Fix style
a6bafb0
to
851e653
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 for this huge work! This will unlock the transition on the Qiskit side once is released :)
self.assertEqual(result._layout.initial_layout._p2v, expected_layouts[level]) | ||
|
||
@data(0, 1, 2, 3) | ||
def test_layout_tokyo_fully_connected_cx(self, level): |
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 for taking care of this! Only minor comment I have is that this test is failing:
AssertionError: {6: Qubit(QuantumRegister(5, 'qr'), 0), 5:[838 chars] 14)} != {0: Qubit(QuantumRegister(15, 'ancilla'), [838 chars] 14)}
Diff is 1699 characters long. Set self.maxDiff to None to see it
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 for the review kt474. After talking to Matthew he pointed out that there were better alternatives for integration tests, so I have ended up completely replacing this file. This test assumes that the current terra main
is used (there are a few changes that are ahead of the release). Let me know if there are any issues with the new test too.
cecd29f
to
1b9bbcb
Compare
Closing for now, as decided to handle this in |
Summary
This PR addresses the second task in Qiskit/qiskit#9553. The goal of this effort is to both improve the maintainability of the fake backends and decouple provider-specific behavior from qiskit.
So far, this PR is a naive (history-preserving) copy-paste of the provider-specific fake backends in qiskit, as a second-step, these should be updated to inherit from the
IBMBackend
class.The original unit tests were quite minimal, as these classes were originally designed to use in other tests. For this reason I have added one integration test which copies a (somewhat random) selection of tests from this transpiler test that uses several different fake backends. If this test doesn't conform with your use of the
integration
folder, I am open to change it.Details and comments
Closes #511.
(!!!) Reminder: If we want to preserve the commit history on this module, commit squashing must be disabled before merging.