-
Notifications
You must be signed in to change notification settings - Fork 568
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
Support variable number of trotter steps in the UCCSD ansatz #5741
Comments
Hi @S-Erik , Thanks for your suggestion! My colleague Soran helped me with some insights here. It is correct the our implementation of UCCSD, following literature, assumes first-order Trotter expansion. Take a look at this template, it might be exactly what you were looking for! 😃 |
Thank you for your quick answer @CatalinaAlbornoz. Now, I have a few further questions: How do you imagine repeating the UCCSD template in PennyLane? Because a simple for loop in a circuit definition does not work. For example @qml.qnode(dev)
def circuit(params):
for rep in range(uccsd_reps):
qml.UCCSD(params[rep], wires, s_wires, d_wires, init_state=hf_state)
return qml.expval(H) does not work as intended because the A naïve approach trying to work around this reset by setting @qml.qnode(dev)
def circuit(params):
for rep in range(uccsd_reps):
init_state = hf_state if rep == 0 else None # ValueError: Elements of 'init_state' must be integers; got object
qml.UCCSD(params[rep], wires, s_wires, d_wires, init_state=init_state)
return qml.expval(H) , results in a You are correct that the implementation of the kUpCCGSD template is very similar to what I proposed in my initial comment. But, since the kUpCCGSD template uses generalized fermionic excitations it generates a different circuit than the UCCSD template even for I hope I did not make a mistake implementing your suggestion. |
Hi @S-Erik, I'm checking with the team on this. We'll be back in the next few days with more info on what can be done here. Thanks for your questions! |
Hi @S-Erik and thanks for opening the issue. Repeating the first-order UCCSD ansatz, as you suggested, is an option for improving accuracy but it will make your circuit deep and expensive to simulate. The better alternative is to build adaptive circuits, where extra gates are added systematically to improve the quality of your ansatz. You can find more details in this demo. Please let me know if the adaptive method is a solution for your problem. |
Hi @soranjh. Thank you for your concerns and suggestions. I am aware of the ADAPT-VQE approach and its usage in PennyLane. Unfortunately, my aim for this issue is that one can improve the accuracy of the UCCSD ansatz by using higher-orders. The main reason for this is to investigate the limit of the UCCSD ansatz and the error from different Trotter-orders. Since ADAPT-VQE converges to the FCI value for large ADAPT-steps value and not to the UCCSD limit, I cannot assess the UCCSD error with ADAPT-VQE. I hope you can better understand my aim now and I am open for any further suggestions. |
Thanks for the clarification @S-Erik. Have you considered using the
|
Thank you for your suggestion @soranjh. Building the circuit manually would indeed work. Your code suggestion is therefore very close to the already implemented UCCSD template and my I believe it would benefit PennyLane to incorporate this functionality of allowing repetitions into the existing UCCSD template. Similarly, one could argue that while a UCCSD template isn't strictly necessary, because the circuit can also be build manually, it does streamline the process by automating the creation of the circuit. |
Thanks @S-Erik, sounds good. Are you interested to open a quick PR and add a repeat parameter? The implementation will be similar to that of kUpCCGSD template. |
Sounds perfect @soranjh. I will prepare a PR in the coming days. I will orient myself on the kUpCCGSD template as you said. |
It's great to hear that you decided to prepare the PR! Let us know if you have any questions along the way and please mention this issue in the PR too! |
I have just created a PR, see #5801. |
Thanks @S-Erik ! |
Feature details
The UCCSD ansatz, as written in the documentation, implements a first order Trotter-approximation of the UCCSD unitary. I suggest introducing a new parameter to the UCCSD function that defines the Trotter order, e.g. via specifying the number of repetitions of the current UCCSD ansatz similar to the
reps
parameter in the qiskit UCCSD implementation.This is relevant to check and reduce the error coming from the first-order Trotter approximation.
Implementation
I am not sure how one would implement higher-order Trotter approximations in a way that is mathematically correct, but judging from the qiskit NLocal implementation on which their UCCSD ansatz is based it seems that simply repeating the first-order UCCSD ansatz
reps
times does the trick. Further I think that for each repetition one would have to introduce new parameters such that each repetition has its own set of parameters.I thought of the following code as a starting point:
How important would you say this feature is?
1: Not important. Would be nice to have.
Additional information
No response
The text was updated successfully, but these errors were encountered: