-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for n-controlled gates #22
base: development
Are you sure you want to change the base?
Conversation
Changes added: - Support for n-controlled Pauli operators - Intermediate gate caching - Circuit depth and circuit width optimisation NCU
Changes include: - Sample application demonstrating NCU usage - Unit tests using default and optimised decompositions - Fixes for NCU templating
Hi there, |
Hi @TysonRayJones to my knowledge this functionality does not exist in Intel-QS. Our proposed PR adds support for n-controlled gates using several decomposition strategies (using direct recursive, simple optimised known cases, or using auxiliary qubits to reduce depth). Direct simulation without decomposition would be nice, but I am not aware of how this could be achieved to ensure adjustment of all coefficients in the appropriate manner. The above decomposition approach does achieve very good performance and utilisation of system resources. We have run it using between 8-14 control lines in recent experiments, and had good success using additional nodes in MPI with it. |
Ah I see. I ask, because a direct n-controlled gate is actually quite straightforward if a 1-controlled gate already exists (and it's obviously faster and much more precise). Effecting an n-controlled gate involves modifying less amplitudes than the 1-controlled gate modifies. The (serial) logic for the 1-controlled gate is:
The logic for the n-controlled gate is then simply:
Even in a distributed application, evaluating the condition I implemented a distributed n-controlled gates in the Oxford simulator I work on (see here). While there's a bit of boilerplate there, the "main" part (that distinguishes it from the 1-controlled case) is here. Happy to explain the O(1) While supporting a decomposition to 1 and 2 qubit gates is certainly very useful to emulate precisely what a quantum computer (with those constraints) would effect (to e.g. capture noise accurately), it's unnecessary if one wishes to just effect the gate on the state. I'm happy to help out if you think this is worth adding to qHipster |
Ah, I understand. That sounds sensible, though you are correct in saying that matching the device (1 and 2 qubit) allowed gate-calls was the plan for the above work. I think it may be best to do this in another issue/PR following the merging of this work, as this is partly the result of an external collaborative project from the following repo: https://github.com/ICHEC/QNLP Though, I am also interested in your implementation of this from a pure simulation perspective, and would like to listen in if the Intel team are interested in pursuing this. |
Hi @TysonRayJones and hi @mlxd, Sorry for the late reply. For how I see it, there are a few possibilities.
I agree with Lee that this should be a separate pull request. Happy to discuss more about it. |
Hi all, sorry for the long delay, but only recently had time to revisit this. I have not been able to replicate the errors that appear on the Github Action test. Running locally on my Mac natively, in Docker, and inside a localised Github action version all pass. Simiarly, the same things are observed on the HPC system. Any thoughts as for why this is happening would be greatly appreciate. I initially thought it may be some thread safety issues with the Google testing framework on the Action, but it seems that may not be the case either. |
We add support for creating n-controlled gates using the decompositions described by Barenco et al. (https://arxiv.org/abs/quant-ph/9503016)
For this, we have added the following features: