quil-lang / quilc

The optimizing Quil compiler.
Apache License 2.0
452 stars 73 forks source link

Add: sqisw-decompose compiler #868

Closed macrologist closed 1 year ago

macrologist commented 1 year ago

This branch intends to add sqisw decomposition to quilc, as per #766 .

What remains to be done:

What has been done so far: A define-compiler definition has been added that decomposes an arbitrary 2 qubit gate into at most three SQiSW gates interleaved by single qubit gates, and, for 80% of all 2 qubit gates, only requires two SQiSW gates.

As this is my first attempt to contribute to the compiler, I am looking for critique on anything that is obviously wrong or obviously flouting conventions.

ecpeterson commented 1 year ago

Nice! I’ll try to have a look over the weekend.

macrologist commented 1 year ago

Nice! I’ll try to have a look over the weekend.

@ecpeterson

If you wait until next weekend, it might even work! I've got the two sqisw case working but something is amiss in the three sqisw case. I think its that I'm mis-using the output of canonical-decomposition to extract the canonical coordinates and then halving them with fingers crossed. I have to step through and see that it actually makes sense.

In any case, any feedback is appreciated!

macrologist commented 1 year ago

I've pushed again. the depth-3 case still is not working. I am going to narrow my search to canonicalize-for-sqisw (which, incidentally, I should rename) and check that each of the cases it addresses are conditioned correctly. This check entails stepping back through the paper and deriving each case condition in the function from the cases treated in the proof of the depth-3 proposition. I've pushed these changes in case inquiring minds wanted to know.

stylewarning commented 1 year ago

adding this before i forget: I imagine that we should call the gate SQRT-ISWAP to fit the Quil vibes, but I'm not actually picky about this whatsoever. If not that, then SQISWAP.

macrologist commented 1 year ago

This is not ready btw. Even though.. somewhat mysteriously, checks have passed. I should add tests specific to these compiler rules to the suite.

macrologist commented 1 year ago

I'm going to close this PR, flatten commits, and open a new one.