Skip to content

🚸 Allow indexed registers as operation arguments #839

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

Merged
merged 2 commits into from
Feb 24, 2025

Conversation

burgholzer
Copy link
Member

Description

This update enables the use of indexed registers as arguments for operations.
For example, in Python:

from mqt.core.ir import QuantumComputation

qc = QuantumComputation()
q = qc.add_qubit_register(2)
c = qc.add_classical_register(2)

qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q[0], c[0])
qc.measure(q[1], c[1])

In C++:

#include "ir/QuantumComputation.hpp"

auto qc = qc::QuantumComputation();
const auto& q = qc.addQubitRegister(2);
const auto& c = qc.addClassicalRegister(2);

qc.h(q[0]);
qc.cx(q[0], q[1]);
qc.measure(q[0], c[0]);
qc.measure(q[1], c[1]);

This improvement expands the usability of the IR as it no longer requires users to track the order in which registers were added to infer their qubits' indices.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

@burgholzer burgholzer self-assigned this Feb 24, 2025
@burgholzer burgholzer added usability Anything related to usability Core Anything related to the Core library and IR c++ Anything related to C++ code python Anything related to Python code labels Feb 24, 2025
@burgholzer burgholzer added this to the MQT Core milestone Feb 24, 2025
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.3%. Comparing base (34f2bfb) to head (eb4c786).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
include/mqt-core/ir/Register.hpp 83.3% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #839   +/-   ##
=====================================
  Coverage   92.3%   92.3%           
=====================================
  Files        127     127           
  Lines      13509   13520   +11     
  Branches    2080    2081    +1     
=====================================
+ Hits       12471   12487   +16     
+ Misses      1038    1033    -5     
Flag Coverage Δ
cpp 92.0% <91.6%> (+<0.1%) ⬆️
python 99.7% <ø> (ø)
Files with missing lines Coverage Δ
include/mqt-core/ir/QuantumComputation.hpp 100.0% <ø> (ø)
src/ir/QuantumComputation.cpp 92.5% <100.0%> (+<0.1%) ⬆️
include/mqt-core/ir/Register.hpp 91.6% <83.3%> (-1.7%) ⬇️

... and 5 files with indirect coverage changes

@burgholzer burgholzer enabled auto-merge (squash) February 24, 2025 16:14
@burgholzer burgholzer merged commit 47730e7 into main Feb 24, 2025
31 checks passed
@burgholzer burgholzer deleted the allow-register-indexing branch February 24, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Anything related to C++ code Core Anything related to the Core library and IR python Anything related to Python code usability Anything related to usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant