matt-lourens / hierarqcal

Generate hierarchical quantum circuits for Neural Architecture Search.
https://matt-lourens.github.io/hierarqcal/
BSD 3-Clause "New" or "Revised" License
41 stars 15 forks source link

Add Qpivot primitive #34

Closed Aaron-Robertson closed 11 months ago

Aaron-Robertson commented 1 year ago

Fixes #26

Aaron-Robertson commented 1 year ago

Alright @matt-lourens, I went through the requested changes and think we're getting pretty close! Everything's running, at least. I'm not quite seeing where we're going wrong at the moment, but will come back to it to troubleshoot this afternoon. Feel free to take a look and review as you see fit. I still need to add the circuits for other frameworks, so that's one TODO on my list.

Otherwise, I'm still playing around with and thinking about our cycle boundary conditions. As implemented, the "open" condition is more in line with the "closed" we discussed this morning, while the "closed" condition is a bit too trivial for my liking. Happy to just remove the "open" option (and move the logic back to "closed"), or implement it based on feedback if you have any specific ideas!

matt-lourens commented 1 year ago

Hey @Aaron-Robertson, Sorry I haven't had a chance to look at the updated code yet but from a quick glance it looks good on the Qpivot implementation side. I wanted to check if you've tried the QFT with Qpivot primitive yet on the example side of the issue and if that is working?

Aaron-Robertson commented 1 year ago

@matt-lourens Great, glad it passes at a glance at least! I'll take another look tonight, but I wasn't getting the expected result with the example side of things. I tested variants of the circuit defined as:

N = 5
u_h = Qunitary(H2, 0, 2)
u_cr = Qunitary(CR2, 0, 2)
h_top = Qpivot(pattern="1*", mapping=u_h)
controlled_rs = Qpivot(pattern="1*", mapping=u_cr, share_weights=False)
hcr = h_top + controlled_rs
qft = Qinit(N)  + (hcr + Qmask("1*"))*(N)
circuit = get_circuit(qft)
draw_circuit(circuit)