Support CUDA-Q kernels for CircuitToEinsum
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 499
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
For an upcoming demo, we need cuQuantum to accept CUDA-Q circuits into the CircuitToEinsum function here.
Here is an example of how to do this in Qiskit:
from cuquantum import cutensornet as cutn
from cuquantum import contract, CircuitToEinsum
import torch
from qiskit.circuit import QuantumCircuit, Parameter
num_qubits = 1
measurement_ops = 'Z'
light_cone = True
# Define the quantum circuit with one qubit and two parameters
theta = Parameter('θ')
phi = Parameter('φ')
circuit = QuantumCircuit(num_qubits)
circuit.rx(theta, 0)
circuit.ry(phi, 0)
parameters = [1,2]
circuit = circuit.bind_parameters({theta: parameters[0], phi: parameters[1]})
converter = CircuitToEinsum(circuit, backend='torch')
einsum_expression, tensor_operands = converter.expectation(measurement_ops, light_cone)
Note that you have to provide a bound circuit (circuit with values supplied for the variational gates).
It would be nice if we could support CircuitToEinsum to take in variational circuits that are unbound but I'm guessing that the einsum expression will look different for different parameter values and hence this is not feasible?
In CUDA-Q, the corresponding code looks like this:
import cudaq
from typing import List
cudaq.set_target("nvidia")
@cudaq.kernel
def kernel(angles: List[float]):
qubit = cudaq.qubit()
rx(angles[0], qubit)
ry(angles[1], qubit)
hamiltonian = cudaq.spin.z(0)
parameters = [1, 2]
expectation_value = cudaq.observe(kernel, hamiltonian, parameters).expectation()
Note how the binding of the parameters happens in the observe call. How do we deal with this? @1tnguyen @bettinaheim
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CircuitToEinsum API documentation and compare its Qiskit example with the CUDA-Q kernel and observe example in the issue. Determine how CUDA-Q circuits and parameter binding should be represented, including whether unbound variational circuits are feasible. Done means CircuitToEinsum accepts the requested CUDA-Q circuit workflow with a defined parameter-handling approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- quantum-computing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100