quantum-compiler / quartz

The Quartz Quantum Compiler
Apache License 2.0
76 stars 19 forks source link

[Refactor] Handle all parameters in Context #159

Closed xumingkuan closed 7 months ago

xumingkuan commented 8 months ago

Close #17

This PR is a large-scale refactoring, moving all parameters from CircuitSeq to Context. It will reduce the memory usage of ECC sets.

Please review this PR if you are developing on Quartz.

Benchmark for generator on Nam gate set: Before: (3,3)-complete:

Before ECC simplification: num_total_dags = 4496, num_equivalence_classes = 4179, #transformations Nam_3_3 = 634
Nam_3_3 generated. Running Time (s): 9.253
Pruning Time (s): 0.029
Verification Time (s): 8.898
Num_total_dags = 82, num_equivalence_classes = 31
*** Number of transformations of Nam_3_3 = 102

(4,3)-complete (87.1KiB):

Before ECC simplification: num_total_dags = 38357, num_equivalence_classes = 36177, #transformations Nam_4_3 = 4360
Nam_4_3 generated. Running Time (s): 65.136
Pruning Time (s): 0.224
Verification Time (s): 61.132
Num_total_dags = 426, num_equivalence_classes = 193
*** Number of transformations of Nam_4_3 = 466

After (slightly worse, will be fixed in the next PR): (3,3)-complete:

Before ECC simplification: num_total_dags = 4496, num_equivalence_classes = 4179, #transformations Nam_3_3 = 634
Nam_3_3 generated. Running Time (s): 3.943
Pruning Time (s): 0.009
Verification Time (s): 3.848
Num_total_dags = 94, num_equivalence_classes = 37
*** Number of transformations of Nam_3_3 = 114

(4,3)-complete (70.1KiB):

Before ECC simplification: num_total_dags = 38357, num_equivalence_classes = 36177, #transformations Nam_4_3 = 4360
Nam_4_3 generated. Running Time (s): 29.053
Pruning Time (s): 0.143
Verification Time (s): 27.874
Num_total_dags = 542, num_equivalence_classes = 250
*** Number of transformations of Nam_4_3 = 584

Change list:

CircuitSeq

Json

Generator

Verifier

Optimizer

Context

Cython

QASMParser

Simulator

Utils

xumingkuan commented 7 months ago

The generator is not generating parameter expressions properly now. Fixing later.

xumingkuan commented 7 months ago

The generator is not generating parameter expressions properly now. Fixing later.

Fixed now.