parallelization / depth reduction pass
See original GitHub issueWhat is the expected enhancement?
The following circuit has depth 10:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
cx q[0],q[1];
cx q[1],q[0];
cx q[2],q[1];
cx q[0],q[1];
cx q[2],q[3];
cx q[3],q[2];
cx q[1],q[2];
cx q[2],q[3];
cx q[2],q[1];
cx q[1],q[2];
cx q[3],q[2];
βββββ
q_0: βββ βββ€ X βββββββββ ββββββββββββββββββββββββββββββββ
βββ΄βββββ¬ββββββββββ΄ββ βββββ
q_1: β€ X ββββ βββ€ X ββ€ X βββββββββ ββββββββ€ X ββββ βββββββ
βββββ βββ¬βββββββββββββββ΄ββ βββ¬βββββ΄βββββββ
q_2: βββββββββββββ βββββ βββ€ X ββ€ X ββββ βββββ βββ€ X ββ€ X β
βββ΄βββββ¬ββββββββββ΄ββ ββββββββ¬ββ
q_3: ββββββββββββββββ€ X ββββ ββββββββ€ X ββββββββββββββ ββ
βββββ βββββ
However by commuting one of the CNOTs to the left, the depth can be reduced to 9. I donβt think thereβs a pass that currently does this.
OPENQASM 2.0;
include "qelib1.inc";
qreg q[4];
cx q[0],q[1];
cx q[1],q[0];
cx q[2],q[3];
cx q[2],q[1];
cx q[0],q[1];
cx q[3],q[2];
cx q[1],q[2];
cx q[2],q[3];
cx q[2],q[1];
cx q[1],q[2];
cx q[3],q[2];
βββββ
q_0: βββ βββ€ X βββββββββ βββββββββββββββββββββββββββ
βββ΄βββββ¬ββββββββββ΄ββ βββββ
q_1: β€ X ββββ βββ€ X ββ€ X ββββ ββββββββ€ X ββββ βββββββ
βββββ βββ¬βββββββ€βββ΄ββ βββ¬βββββ΄βββββββ
q_2: βββ ββββββββββ βββ€ X ββ€ X ββββ βββββ βββ€ X ββ€ X β
βββ΄ββ βββ¬ββββββββββ΄ββ ββββββββ¬ββ
q_3: β€ X ββββββββββββββ ββββββββ€ X ββββββββββββββ ββ
βββββ βββββ
I think this should be easy to write using the DAGDependency
since the depth of that DAG is the shortest possible (taking into account all commutation relations). See the template matching passes for examples of how to write a pass utilizing DAGDependency.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Parallel Reduction - an overview | ScienceDirect Topics
This can be applied for many problems, a min operation being just one of them. It works by using half the number of...
Read more >Parallel Sequences: Fold, Reduce and Scan
Scans are trickier and use a 2-βpass algorithm that builds a tree. The map-βreduce-βfold paradigm, inspired by funclonal programming, is a big winner...
Read more >Parallel Computing Basics
Speculation to Decrease Depth. β’ Example: parallel execution of FSMs over input sequences. β Todd Mytkowicz et al., βData-Parallel Finite-State Machinesβ,.
Read more >Parallel Computing: Theory and Practice
There has been much research on the problem of reducing friction in scheduling. This research shows that distrubuted scheduling algorithms can work quite...
Read more >Parallelizing across multiple CPU/GPUs to speed up deep ...
However, this configuration runs deep learning inference on a single CPU and a single GPU core of the edge device. To reduce inference...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was interested in learning and working on this issue. Would it be okay if I took it up?
Thereβs not explicit order guarantee there, but the implementation does return a fixed order and that likely wonβt ever change (and Iβd probably be concerned about backwards compatibility if we did need to change it for some reason). It will always be in order of node indices in the graph. This is nominally insertion order unless there are deletions. If nodes are deleted and then subsequently new nodes are added those original node indices are reused. So for example if you did:
would return:
["A", "E", "C", "D"]
But without any node removals it will just be insertion order.