epiqc / ScaffCC

Compilation, analysis and optimization framework for the Scaffold quantum programming language.
BSD 2-Clause "Simplified" License
188 stars 53 forks source link

Improved QFT benchmarks #24

Closed yipenghuang0302 closed 6 years ago

yipenghuang0302 commented 6 years ago

Cross validated QFT benchmarks against the QFT examples in the QX Simulator project.

Original QFT 5 qubit example was incorrect: cRz gates rotated phase in wrong direction.

Created a new, simpler QFT benchmark altogether, this new one is parameterized by qubit number n.

yipenghuang0302 commented 6 years ago

Hi Pranav,

Good question, and sorry for taking so long to get back to this. I think your question is about the ordering of CNOTs and Rz gates.

These two series of gates have the same effect:

Rz(target,angle/2); CNOT(ctrl, target); Rz(target,-1*angle/2); CNOT(ctrl, target);

and

CNOT(ctrl, target); Rz(target, -angle/2); CNOT(ctrl, target); Rz(target, angle/2);

To understand this, see Niesen & Chuang 2010 p176 to p181. Specifically, the two code snippets here are special cases of Figure 4.6 on p181 of that book. Either we keep unitary operators C and B, or B and A.

Thanks, Yipeng

On Sun, Jul 29, 2018 at 10:44 PM Pranav Gokhale notifications@github.com wrote:

@singular-value requested changes on this pull request.

In Algorithms/QFT/qft.scaffold https://github.com/epiqc/ScaffCC/pull/24#discussion_r206003415:

@@ -0,0 +1,42 @@ +#include +#define pi 3.141592653589793238462643383279502884197 + +#define n 5 + +module cRz ( qbit ctrl, qbit target, const double angle ) {

  • /* cRz identity matrix:
  • [ [ 1 0 0 0 ]
  • [ 0 1 0 0 ]
  • [ 0 0 e^(-i*angle/2) 0 ]
  • [ 0 0 0 e^(i*angle/2) ] ]
  • */
  • Rz(ctrl, angle/2);

Why is this cRz definition different from the one you updated above?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/epiqc/ScaffCC/pull/24#pullrequestreview-141378350, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJYR5-jJIMbAZW42yUPAb7r4C4uR6AAks5uLnMKgaJpZM4VKUsI .

-- yipenghuang.com

singular-value commented 6 years ago

No worries, we haven't really established code review norms and timelines yet. Okay thanks for the clarification.

Looking forward, we should try to have a library with a single CRz implementation. But looks good for now.