Skip to content

Fix handling of output permutation and initial layout #509

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

Conversation

martin-fink
Copy link
Contributor

Description

Output permutation and initial layout need to be applied after the circuit is parsed completely.

This fixes an issue where an output permutation is declared with less qubits than are used in the circuit.

// i 0 2 1 3
// o 3 0
qubit[4] q;

Would result in an output permutation of

0: 1
1: 1
2: 2
3: 0

instead of

0: 1
3: 0

The issue is fixed by applying the output permutation after parsing the complete circuit.

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.

Output permutation and initial layout need to be applied after the
circuit is parsed completely.
Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8881fb0) 91.0% compared to head (6ba80dc) 91.0%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #509   +/-   ##
=====================================
  Coverage   91.0%   91.0%           
=====================================
  Files        128     128           
  Lines      13706   13709    +3     
  Branches    2143    2145    +2     
=====================================
+ Hits       12485   12488    +3     
  Misses      1221    1221           
Flag Coverage Δ
cpp 90.8% <100.0%> (+<0.1%) ⬆️
python 99.7% <ø> (ø)
Files Coverage Δ
src/parsers/QASM3Parser.cpp 90.5% <100.0%> (+<0.1%) ⬆️

Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Many thanks for the quick fix 😎

@burgholzer burgholzer added fix Fix for something that isn't working Core Anything related to the Core library and IR c++ Anything related to C++ code labels Dec 25, 2023
@burgholzer burgholzer added this to the OpenQASM 3.0 Support milestone Dec 25, 2023
@burgholzer burgholzer merged commit 49d0f76 into munich-quantum-toolkit:main Dec 25, 2023
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 fix Fix for something that isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants