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

Compiler Top-Down Integration #49

Merged
merged 41 commits into from
Aug 22, 2024
Merged

Compiler Top-Down Integration #49

merged 41 commits into from
Aug 22, 2024

Conversation

KevinMTO
Copy link
Collaborator

@KevinMTO KevinMTO commented Aug 21, 2024

Description

This PR integrates the compiler in fully automated fashion from the circuit to the simulations results.

  • Introduced gate and circuit compilation.
  • Integrated fully mixed-dimensional, two-body gate compilation through compiler and ansatz optimization.
  • Introduced a lookahead strategy and data structure (Lanes) and a resynthesis tool for local gate compilation.
  • Integrated Givens Z rotation compression and removal.
  • Introduced a layer of abstraction using "blocks": crtot, crz, and pswap objects.
  • Modified matrix multiplications.
  • Explored sparsification algorithms.
  • Saved mappings and re-encoding of simulation results.
  • Fixed MS, LS, Perm gates, and matrix factory.
  • Fixed energy level graph for fake backends.

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 follows the project's style guidelines.

@@ -7,6 +7,9 @@
def __init__(self, backend, **kwargs) -> None:
self.backend = backend

def transpile_gate(self, gate) -> None:

Check notice

Code scanning / CodeQL

Mismatch between signature and use of an overridden method

Overridden method signature does not match [call](1), where it is passed too many arguments. Overriding method [method PhyLocAdaPass.transpile_gate](2) matches the call.
Comment on lines 131 to 136
(
alpha1_real * l1_norm_real
+ alpha2_real * l2_norm_real
+ alpha1_imag * l1_norm_imag
+ alpha2_imag * l2_norm_imag
) + den

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.
circuit = sparsify(u)
op = mini_unitary_sim(self.circuit, circuit.instructions)
sparsity_final = compute_F(op)
op = op.round(3)

Check notice

Code scanning / CodeQL

Unused local variable

Variable op is not used.

class CompilerPass(ABC):
def __init__(self, backend, **kwargs) -> None:
self.backend = backend

def transpile_gate(self, gate: Gate) -> list[Gate]:

Check notice

Code scanning / CodeQL

Mismatch between signature and use of an overridden method Note

Overridden method signature does not match
call
, where it is passed too many arguments. Overriding method
method PhyLocAdaPass.transpile_gate
matches the call.

import numpy as np
from scipy.optimize import minimize
from scipy.optimize import dual_annealing

Check notice

Code scanning / CodeQL

Unused import

Import of 'dual_annealing' is not used.
@KevinMTO
Copy link
Collaborator Author

@burgholzer I think pre-commit still changes x = x@y into x@=y which is not supported in older versions and it messes up with the code :/
Can we fix that?:) Or can you point me to resources? Thanks!

@burgholzer
Copy link
Member

burgholzer commented Aug 22, 2024

@burgholzer I think pre-commit still changes x = x@y into x@=y which is not supported in older versions and it messes up with the code :/

Can we fix that?:) Or can you point me to resources? Thanks!

Yeah. Update the versions that do not support it to versions that support it 😉

Edit: or, in cases where it really does not seem valid, place a corresponding "# noqa: " directive on the respective lines.

@KevinMTO KevinMTO merged commit a285729 into main Aug 22, 2024
20 of 24 checks passed
@KevinMTO KevinMTO deleted the two_dit branch August 22, 2024 19:01
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 74.36620% with 182 lines in your changes missing coverage. Please review.

Project coverage is 80.9%. Comparing base (a65af54) to head (670f4f2).
Report is 1 commits behind head on main.

Files Patch % Lines
...er/twodit/entanglement_qr/phy_ent_qr_cex_decomp.py 29.5% 31 Missing ⚠️
...iational_twodit_compilation/layered_compilation.py 0.0% 22 Missing ⚠️
...imulation/backends/fake_backends/fake_traps3six.py 68.3% 19 Missing ⚠️
src/mqt/qudits/compiler/dit_compiler.py 67.2% 18 Missing ⚠️
src/mqt/qudits/core/lanes.py 86.3% 13 Missing ⚠️
...n_aware_transpilation/log_local_adaptive_decomp.py 20.0% 12 Missing ⚠️
src/mqt/qudits/quantum_circuit/circuit.py 35.2% 11 Missing ⚠️
...g_aware_transpilation/phy_local_adaptive_decomp.py 9.0% 10 Missing ⚠️
...riational_twodit_compilation/ansatz/instantiate.py 53.3% 7 Missing ⚠️
...ping_un_aware_transpilation/log_local_qr_decomp.py 14.2% 6 Missing ⚠️
... and 15 more
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main     #49     +/-   ##
=======================================
+ Coverage   72.7%   80.9%   +8.1%     
=======================================
  Files        108     104      -4     
  Lines       5370    4372    -998     
  Branches     262       0    -262     
=======================================
- Hits        3907    3537    -370     
+ Misses      1463     835    -628     
Flag Coverage Δ
cpp ?
python 80.9% <74.3%> (+8.5%) ⬆️
Files Coverage Δ
src/mqt/qudits/compiler/__init__.py 100.0% <100.0%> (ø)
...er/compilation_minitools/numerical_ansatz_utils.py 54.5% <100.0%> (+36.3%) ⬆️
...qt/qudits/compiler/naive_local_resynth/__init__.py 100.0% <100.0%> (ø)
...dits/compiler/naive_local_resynth/local_resynth.py 100.0% <100.0%> (ø)
src/mqt/qudits/compiler/onedit/__init__.py 100.0% <100.0%> (ø)
...iler/onedit/local_phases_transpilation/__init__.py 100.0% <100.0%> (ø)
src/mqt/qudits/compiler/twodit/blocks/crot.py 95.0% <100.0%> (ø)
src/mqt/qudits/compiler/twodit/blocks/czrot.py 100.0% <100.0%> (ø)
...qudits/compiler/twodit/entanglement_qr/__init__.py 100.0% <100.0%> (ø)
.../variational_twodit_compilation/ansatz/__init__.py 100.0% <100.0%> (ø)
... and 34 more

... and 17 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants