Required prerequisites
Describe the feature
C++ kernels can apply a Pauli-word exponential to explicitly listed
qubits: exp_pauli(theta, "YX", qubits[a], qubits[b]). The Python kernel
builder only accepts exp_pauli(angle, register, word) where the word
spans the whole register; the individual-qubit form is rejected with "too
many values".
import cudaq
cudaq.set_target("qpp-cpu")
@cudaq.kernel
def kernel(theta: float):
q = cudaq.qvector(3)
exp_pauli(theta, "YX", q[0], q[1]) # error: too many values
# Works today: contiguous runtime slice
@cudaq.kernel
def kernel2(theta: float, a: int):
q = cudaq.qvector(4)
exp_pauli(theta, q[a:a + 2], "YX") # OK, runtime offset supported
For contiguous pairs the runtime-slice form works (verified, including
runtime offsets), but non-contiguous operand sets require padding the word
with identities to full register width on the host. Parity with the C++
operand form would make C++-to-Python kernel ports mechanical.
Environment
- CUDA-Q built from source at commit
0be565550f4c23affdcbed9e4eaec38d2d0915e6
- Python 3.11.x, target
qpp-cpu (library mode)
- AlmaLinux 8.10, x86_64
All reproducers below were executed and verified against this build.
Required prerequisites
Describe the feature
C++ kernels can apply a Pauli-word exponential to explicitly listed
qubits:
exp_pauli(theta, "YX", qubits[a], qubits[b]). The Python kernelbuilder only accepts
exp_pauli(angle, register, word)where the wordspans the whole register; the individual-qubit form is rejected with "too
many values".
For contiguous pairs the runtime-slice form works (verified, including
runtime offsets), but non-contiguous operand sets require padding the word
with identities to full register width on the host. Parity with the C++
operand form would make C++-to-Python kernel ports mechanical.
Environment
0be565550f4c23affdcbed9e4eaec38d2d0915e6qpp-cpu(library mode)All reproducers below were executed and verified against this build.