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

⚡ Better performance in Qiskit import #441

Open
burgholzer opened this issue Oct 14, 2023 · 0 comments
Open

⚡ Better performance in Qiskit import #441

burgholzer opened this issue Oct 14, 2023 · 0 comments
Labels
Core Anything related to the Core library and IR enhancement New feature or request good first issue Good for newcomers python Anything related to Python code refactor Anything related to code refactoring
Milestone

Comments

@burgholzer
Copy link
Member

What's the problem this feature will solve?

Right now, the Qiskit import introduced in #371 incurs some unnecessary copies when translating operations from Qiskit to our internal representation.
This is because the code is organised so that it can simultaneously/recursively handle CompoundOperations and QuantumComputations. However, only the QuantumComputation class has convenience methods for directly constructing gates in-place right now.
As a consequence, the Qiskit import just always constructs an operation and then moves it to the QuantumComputation or CompoundOperaton (incurring a copy).

Describe the solution you'd like

It should be possible to avoid the copy and always construct the operations in-place (even if they are nested in a CompoundOperation).
Most likely, the solution is to replace the current call sites where a Compound operation is used by creating a QuantumComputation, then recursively calling the gate import on that circuit (using the convenience functions for adding gates in-place), and afterwards use the to_operation method to turn the circuit into a CompoundOperation that can then be added to the circuit.

An alternative solution involves also exposing convenience functions for adding gates in-place to the CompoundOperation class similar to the QuantumComputation. However, this creates quite some overhead in documentation and in terms of lines of code and is, therefore, not the preferred solution.

@burgholzer burgholzer added enhancement New feature or request good first issue Good for newcomers refactor Anything related to code refactoring Core Anything related to the Core library and IR python Anything related to Python code labels Oct 14, 2023
@burgholzer burgholzer added this to the MQT Core milestone Oct 14, 2023
@burgholzer burgholzer added this to MQT Core and MQT Oct 14, 2023
@burgholzer burgholzer moved this to Todo in MQT Oct 14, 2023
@burgholzer burgholzer moved this to Todo in MQT Core Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Anything related to the Core library and IR enhancement New feature or request good first issue Good for newcomers python Anything related to Python code refactor Anything related to code refactoring
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

1 participant