Skip to content

[python] exp_pauli lacks the individual-qubit operand form available in C++ #4849

Description

@wsttiger

Required prerequisites

  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions