Skip to content

Conversation

pehamTom
Copy link
Collaborator

@pehamTom pehamTom commented Aug 27, 2024

Description

This PR fixes some issues with certain codes.

There was a bug when the code was defined over a number of qubits, which is an exact power of 2, leading to the optimal state prep circuit failing to be synthesized.

Another issue occurred when looking at d=2 codes, which cannot be used for error correction but only for error detection. I have added functionality to set whether one wants to create the circuit for error detection or error correction in the StatePrepCircuit class.

Fixes #265

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.

If a code has a number of qubits that is a power of 2, then the assertion in `_generate_circ_with_bounded_gates` that
makes sure the bitvector variables encoding the CNOT qubits act only on valid qubits erroneously asserts that control
and target should be less than 0. This of course always returns `False`.
Computing  (d-1)//2 as the maximum number of errors is incorrect for codes with even distance.
So far we assumed that we always want to have an error correction code and thus the maximum number of independent errors
in the circuit was computed as (d-1)//2. But for an error detection code we allow d//2 independent errors.

For this I introduced a flag `error_detection_code` in the `StatePrepCircuit` class so that the errors are computed
correctly.

Furthermore, if d=2 this flag is set automatically.
@pehamTom pehamTom changed the title Fix small code bugs Fix small code bugs for FT Stateprep Aug 27, 2024
@burgholzer
Copy link
Member

@pehamTom could you maybe base this PR on top of #266?
I fixed a couple of mypy errors as part of updating the infrastructure and I am fairly sure this will create (small) conflicts.
I hope the other PR should be ready asap.

@burgholzer burgholzer added the fix Fix for something that isn't working label Aug 27, 2024
@pehamTom pehamTom changed the base branch from main to infrastructure-update August 27, 2024 08:22
@pehamTom
Copy link
Collaborator Author

@pehamTom could you maybe base this PR on top of #266? I fixed a couple of mypy errors as part of updating the infrastructure and I am fairly sure this will create (small) conflicts. I hope the other PR should be ready asap.

Done, and resolved the conflicts.

@pehamTom pehamTom changed the base branch from infrastructure-update to main August 27, 2024 11:46
@pehamTom pehamTom force-pushed the fix-small-code-bugs branch from ad84eba to c8213b8 Compare August 27, 2024 11:51
@pehamTom
Copy link
Collaborator Author

Rebasing to main because the other PR might be awhile

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.

Project coverage is 82.5%. Comparing base (2719a9b) to head (c8213b8).
Report is 132 commits behind head on main.

Files with missing lines Patch % Lines
src/mqt/qecc/ft_stateprep/state_prep.py 78.1% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #267   +/-   ##
=====================================
  Coverage   82.5%   82.5%           
=====================================
  Files         46      46           
  Lines       3985    3997   +12     
  Branches     362     362           
=====================================
+ Hits        3288    3298   +10     
- Misses       697     699    +2     
Flag Coverage Δ *Carryforward flag
cpp 82.7% <ø> (ø) Carriedforward from 2719a9b
python 82.3% <78.1%> (+<0.1%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
src/mqt/qecc/ft_stateprep/state_prep.py 72.1% <78.1%> (+0.2%) ⬆️

... and 1 file with indirect coverage changes

---- 🚨 Try these New Features:

@pehamTom pehamTom requested a review from lucasberent August 27, 2024 12:39
@pehamTom
Copy link
Collaborator Author

The patch coverage is incorrect due to the concurrent execution of processes. All new functionality is covered and the diff of the project does not change.

@pehamTom pehamTom merged commit 1558254 into main Aug 27, 2024
38 of 43 checks passed
@pehamTom pehamTom deleted the fix-small-code-bugs branch August 27, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fix for something that isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in gate_optimal_prep_circuit for [[4,2,2]] Code and gate_optimal_verification_circuit for [[6,4,2]] Code in ft_stateprep Module
3 participants