Skip to content
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

cudaq.kernels supported by hardware-efficient ansatz #2408

Open
1 task done
Squirtle007 opened this issue Nov 25, 2024 · 2 comments
Open
1 task done

cudaq.kernels supported by hardware-efficient ansatz #2408

Squirtle007 opened this issue Nov 25, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Squirtle007
Copy link

Squirtle007 commented Nov 25, 2024

Required prerequisites

  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.

Describe the feature

A related issue was being tracked here #361.

Currently, cudaq.kernels does not support the hardware-efficient ansatz (HWE), which is valuable for variational quantum algorithms like VQE in reducing computation and simulation costs. Although HWE is included in this directory, it cannot be used.

To be precise,
cudaq.kernels.hwe is accessible, but subsequent cudaq.observe call will raise an error:
RuntimeError: hwe is not a valid kernel to call (cudaq.kernels).
and CUDA-Q built-in optimizers can not be used accordingly.

A simple modified version with JIT decorator (aligning to uccsd):

@cudaq.kernel
def hwe(qubits:cudaq.qview, numQubits:int, numLayers:int, parameters:list[float]):
    """
    Generate the hardware-efficient CUDA-Q kernel.

    Args:
        qubits (:class:`qview`): Pre-allocated qubits
        `numQubits` (int): Number of qubits
        `numLayers` (int): Number of layers
        parameters (List[float]): The list of parameters
    """

    cnotCoupling = [[int(i), int(i+1)] for i in range(numQubits - 1)]

    thetaCounter = 0
    for i in range(numQubits):
        ry(parameters[thetaCounter], qubits[i])
        rz(parameters[thetaCounter + 1], qubits[i])
        thetaCounter = thetaCounter + 2

    for i in range(numLayers):
        for cnot in cnotCoupling:
            cx(qubits[cnot[0]], qubits[cnot[1]])
        for q in range(numQubits):
            ry(parameters[thetaCounter], qubits[q])
            rz(parameters[thetaCounter + 1], qubits[q])
            thetaCounter += 2
@Squirtle007 Squirtle007 added the enhancement New feature or request label Nov 25, 2024
@amccaskey
Copy link
Collaborator

This kernel is on the roadmap for CUDA-QX Solvers library cudaq_solvers.stateprep.hwe(...).

@Squirtle007
Copy link
Author

That would be great, thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants