-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Adding Target
and InstructionProperties
representations to rust
#12292
Open
raynelfss
wants to merge
119
commits into
Qiskit:main
Choose a base branch
from
raynelfss:move-target
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,480
−402
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add `Target` class to test mobility between Rust and Python. - Add `add_instruction` method to test compatibility with instructions.
- Property check caused most cases to panic. - Will be commented out and restored at a later time.
- Instructions property returns all added to the target. - Similar behavior to source.
- Add comments to instruction property. - Use new_bound for new PyDicts.
- Remove redundant transformation of PyObject to PyTuple. - Remove debugging print statement.
- Add `InstructionProperties` class to process properties in rust. - Add `is_instance` and `is_class` to identify certain Python objects. - Modify logic of `add_instruction` to use class check. - Other tweaks and fixes.
- Partial addition from Target.py\ - Introduction of hashable qarg data structure. - Other tweaks and fixes.
- Complete missing procedures in function. - Rename `Qargs` to `HashableVec`. - Make `HashableVec` generic. - Separate `import_from_module_call` into call0 and call1. - Other tweaks and fixes.
- Remove stray print statements. - Other tweaks and fixes.
- Remove all unsafe unwraps
- Update `update_from_instruction_schedule_map to use PyResult and '?' operator. - Use Bound Python objects whenever possible. - Other tweaks and fixes.
- Add temporary _target module for testing. - Remove update_from_instruction_schedule_map function back to python. - Add python properties for all public attributes in rust - Other tweaks and fixes.
- Add identical method `qargs` to obtain the qargs of a target. - Other tweaks and fixes.
- Add function with identical behavior to the original in Target. - Other tweaks and fixes.
- Add target module to qiskit init file. - Remove is_instance method. - Modify set_calibration method in InstructionProperty to leave typechecking to Python. - Change rust Target alias to Target2. - Other tweaks and fixes,
- Fix wrong setters/getters for calibration in InstructionProperty object in rust.
- Add FromPyObject trait to Hashable vec to receive Tuples and transform them directly into this type. - Add operations_for_qargs for Target class in Rust side and Python. - Fix return dict keys for `qargs_for_operation_name`. - Add `timing_constrains` and `operation_from_name` to Python side. - Other tweaks and fixes.
- Fix wrong name for function operation_for_qargs. - Fix missing return value in the python side. - Other tweaks and fixes.
- Make `InstructionProperties` "_calibration" attribute visible. - Removed attribute "calibration", treat as class property. - Other tweaks and fixes
- Port class method to rust and connect to Python wrapper. - Other tweaks and fixes.
- Other tweaks and fixes.
- These changes break current functionality of other functions, butemulate intended behavior better. - Fixes coming soon.
doichanj
pushed a commit
to Qiskit/qiskit-aer
that referenced
this pull request
May 20, 2024
This commit removes the qiskit aer translation plugin. This was added as a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit since 0.45.2 and is no longer necessary. The mechanism by which the workaround worked was unsound in practice as it was mutating the target and also explicitly using private attributes of the Target. This is causing real issues now as it only worked by assuming the target wasn't shared between passmanagers which is never guaranteed. Similarly the reliance on internal private attributes of the Target class will cause issues in the future when the target internals change (see Qiskit/qiskit#12292). This commit opts to remove the plugin in its entirity as it's no longer necessary and actively causing issues with Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As it's private internal detail there isn't a release note. Fixes Qiskit/qiskit#12425 Fixes #2141
- Use tupleize to cast `Qargs` to `Tuple` in `instructions`. - Use downcast to extract string in `add_instruction`. - Other tweaks and fixes.
doichanj
pushed a commit
to doichanj/qiskit-aer
that referenced
this pull request
May 23, 2024
This commit removes the qiskit aer translation plugin. This was added as a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit since 0.45.2 and is no longer necessary. The mechanism by which the workaround worked was unsound in practice as it was mutating the target and also explicitly using private attributes of the Target. This is causing real issues now as it only worked by assuming the target wasn't shared between passmanagers which is never guaranteed. Similarly the reliance on internal private attributes of the Target class will cause issues in the future when the target internals change (see Qiskit/qiskit#12292). This commit opts to remove the plugin in its entirity as it's no longer necessary and actively causing issues with Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As it's private internal detail there isn't a release note. Fixes Qiskit/qiskit#12425 Fixes Qiskit#2141
I wonder if I should wait for #11461 for this to continue, since it introduces a change to the way |
raynelfss
changed the title
Moving
Adding May 28, 2024
Target
and InstructionProperties
to rustTarget
and InstructionProperties
representations to rust
- Rename `InstructionProperties` as `BaseInstructionProperties`. - Remove `Calibration` from the rust space. - Restore `gate_map`, `coupling_map`, `instruction_schedule_map`, and `instruction_durations` to rust. - Remove all unnecessary data structures from rust space. - Other tweaks and fixes.
- Added rust native functionality to target such that a `py` would not be needed to use one. - Add Index trait to make `Target` subscriptable. - Other small tweaks and fixes.
- Remove uage of `inspect.isclass`. - Rename `Target` to `BaseTarget` in the rust side. - Rename `err.rs` to `errors.rs`. - Remove rust-native `add_inst` and `update_inst` as Target should not be modified from Rust. - Made `add_instruction` and `update_instruction_properties` private in `BaseTarget`. - Add missing `get` method in `Target`. - Other tweaks and fixes
One or more of the following people are relevant to this code:
|
doichanj
added a commit
to Qiskit/qiskit-aer
that referenced
this pull request
May 31, 2024
* release 0.14.2 * Disable test shot_branching on MacOS (#2143) * remove test_shot_branching * disable sho_branching tests on MacOS * fix test * fix test * format * fix test_shot_branching * fix test_runtime_parameterization * fix tests for the latest Qiskit (#2138) * Remove qiskit aer translation stage (#2142) This commit removes the qiskit aer translation plugin. This was added as a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit since 0.45.2 and is no longer necessary. The mechanism by which the workaround worked was unsound in practice as it was mutating the target and also explicitly using private attributes of the Target. This is causing real issues now as it only worked by assuming the target wasn't shared between passmanagers which is never guaranteed. Similarly the reliance on internal private attributes of the Target class will cause issues in the future when the target internals change (see Qiskit/qiskit#12292). This commit opts to remove the plugin in its entirity as it's no longer necessary and actively causing issues with Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As it's private internal detail there isn't a release note. Fixes Qiskit/qiskit#12425 Fixes #2141 * Fix issue 2084 again (#2119) * Fix issue 2084 again * format * fix test * fix test * Always hook omp functions in Mac (#2128) * always hook omp functions in Mac * fix recent test failures with the latest qiskit --------- Co-authored-by: Jun Doi <doichan@jp.ibm.com> * Add simulator_metadata in metadata of SamplerV2 (#2109) Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com> * Fix cuStateVec_enable option (#2146) * Fix cuStateVec_enable option * fix function name * Add support for rotation gates (#2147) * add rotation gates * add cr* gates to operations.hpp * fix test for stabilkize/extended-stabilizer * fix test again * Fix deterministic measure of stabilizer (#2132) * Fix deterministic measure of stabilizer * fix accumulation in loop * format --------- Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com> * Fix init of EstimatorV2 and SamplerV2 (#2120) * fix init of EstimatorV2 and SamplerV2 to handle method * add release note * fix from_backend and example in README * remove setting density_matrix * Fix deploy.yml (#2110) Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> * Add support for ECR gate to MPS (#2137) * Add support for ECR gate * replace is not to != * fix release note * Fix ecr implementation for stabilizer/extended-stabilizer * Handle gates with ctrl_stete=0 (#2148) * handle cx gate with ctrl_stete=0 * add handling *_o0, add test for cx_o0 * format * fix test * fix test * fix test cx * fix to handle multiple control states * fix ctrl_state * format * resolve conflict again * fix aer_compiler * fix random seed (#2151) Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com> * Move delay gate to custom instructions (#2153) --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com> Co-authored-by: Luciano Bello <bel@zurich.ibm.com> Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
Pull Request Test Coverage Report for Build 9367840412Details
💛 - Coveralls |
- Add temporary instruction representation to avoid repeated extraction from python.
- Move to different PR.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
API
affects user-facing API change
enhancement
mod: transpiler
Issues and PRs related to Transpiler
priority: high
Rust
This PR or issue is related to Rust code in the repository
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12052
As we continue moving more parts of the transpiler to Rust, it is important that some of the important data about the devices we're compiling for is easily accessible from the Rust side of things. These commits aim to implement representations of both the
Target
andInstructionProperties
classes, allowing most of their data to live inside of Rust but still be usable in Python.Details and comments
qiskit._accelerate
now has atarget
module which includes both theBaseTarget
andBaseInstructionProperties
structs.Here's a more detailed description of what has changed:
Rust
BaseTarget
will include the main data that theTarget
has in python. This will include all of the publicly available attributes of the existing Target class, except for the following:_coupling_graph
: of typerustworkx.PyDiGraph
_instruction_durations
: of typeInstructionDurations
_instruction_schedule_map
: of typeInstructionScheduleMap
Due to these properties are not usable through Rust without using python api's, they were left in python.
BaseInstructionProperties
represents the main data of `InstructionProperties, that being:f64
,f64
Python:
Target
: this is a subclass ofBaseTarget
and has the missing attributes + functions from the previous version._gate_map
attribute from the rust side for easy access in python without conversions from rust.Target._gate_map
is identical to the data insuper().gate_map
by calling thesuper()
's equivalent function when adding or updating an instruction.InstructionProperties
: is a subclass ofBaseInstructionProperties
calibration
to store the instruction's calibration object is present in this representation along with it's custom setter and getter.Possible breaking changes:
-Fixed!InstructionProperties
is now PyO3 class which means it cannot be subclassed by overloading__init__()
alone. The new architecture would require users to extend both__new__
and__init__
to add extra properties. These wouldn't necessarily be visible in rust.Broken tests
A procedure performed in Aer that attempts to erase theSolved by Qiskit/qiskit-aer#2142Target
's internal data is no longer possible due to the these attributes being hidden from python.Open to review!
Any suggestions, comments, feedback, or any request for changes are encouraged and welcome!