[x] Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.
Describe the feature
One may need to either grow, reduce or change the structure of the kernel within an algorithm. The idea of inserting a gate in a specific location comes into play here without having to modify/ copy the kernel once again.
For example:
import cudaq
@cudaq.kernel
def kernel():
q = cudaq.qvector (3)
x(q[0])
@cudaq.kernel
def dynamic_kernel(q1: cudaq.qubit, q2: cudaq.qubit):
cx(q1, q2)
for i in range(n_epochs):
result = scipy.optimize(obj)
if result < 1:
cudaq.insert(dynamic_kernel, kernel, position = 2) #insert dynamic kernel into kernel at position 2
#need to think about what position 2 means in this case
Required prerequisites
Describe the feature
One may need to either grow, reduce or change the structure of the kernel within an algorithm. The idea of inserting a gate in a specific location comes into play here without having to modify/ copy the kernel once again.
For example: