-
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
Draft
raynelfss
wants to merge
105
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.
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.
raynelfss
requested review from
alexanderivrii,
ShellyGarion,
a team,
eggerdj,
wshanks and
jyu00
as code owners
May 15, 2024 17:42
One or more of the the following people are requested to review this:
|
raynelfss
changed the title
[WIP] Moving
Moving May 15, 2024
Target
and InstructionProperties
to rustTarget
and InstructionProperties
to rust
mtreinish
added a commit
to mtreinish/qiskit-aer
that referenced
this pull request
May 17, 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
mtreinish
added a commit
to mtreinish/qiskit-aer
that referenced
this pull request
May 17, 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
- Use `GILOneCell` to import python modules only once at initialization. - Remove the custom data structure `Qargs` to avoid conversion overhead. - `Qargs` does not use `PhysicalQubits`, `u32` is used instead. - Fix `__setstate__ `and `__getstate__` methods for `PropsMap`, `GateMap`, and `key_like_set_iterator` macro_rule. - Update code to use the new structures. - TODO: Fix broken tests.
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.
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 both the
Target
andInstructionProperties
classes, allowing all 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 theTarget
andInstructionProperties
structs.Here's a more detailed description of what has changed:
Target
Qargs
was added as a representation of a tuple of qubits in rust. Allows for quick conversion of tuples from and to rust without compromising the information presented. Can be cast into atuple
when needed in Python.PropsMap
was added as a representation of adict[Option[Qarg], Option[InstructionProperties]]
in rust. Objects of this type are kept in the python heap which prevents PyO3 from performing expensive conversions.GateMap
was added as a representation of adict[str, PropsMap]
in rust. Created to avoid conversions todict
from PyO3.qiskit.transpiler.target
includes a Python extension of theTarget
class due to the following:build_coupling_map()
: This method was kept in Python due to the usage ofrustworkx.PyDiGraph
which doesn't have a proper representation in Rust._build_coupling_graph()
,_filter_coupling_graph()
were also left in python.__str__
method inTarget
to preserve the way data was displayed.Changes introduced:
qiskit.transpiler.target
includes Python extensions of theTarget
andInstructionProperties
classes which includes due to the following:__str__
methodInstructionProperties
to preserve the way data was displayed.InstructionProperties
to include custom properties depends highly on overloading the__new__
method, which cannot be done by extending__init__
. Therefore a wrapper of InstructionProperties was kept on the python side that correctly calls the__new__
method, and allows for extra attributes to be added when extended. However, since theTarget
class does not really use these extra properties, Rust is unable to see them.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 the
Target
'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!