Skip to content

[Python] Nested kernel with exp_pauli failed #2693

@1tnguyen

Description

@1tnguyen

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.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

The following code failed with error error: 'func.call' op kernel call was not inlined, possible recursion in call tree

import cudaq

@cudaq.kernel           
def kernel(
        num_qubits: int,
        coefficients: list[complex] = None,
        words: list[cudaq.pauli_word] = None,
    ):
    K = 5
    t = 1.0
    # create the qubit vector
    qubits = cudaq.qvector(num_qubits)
    
  
    # determin delta for one trotter step
    dt = t / K
    
    # Apply K Trotter steps
    for _ in range(K): 
        trotter(qubits, dt, coefficients, words)
   
@cudaq.kernel
def trotter(
            qubits: cudaq.qview,
            dt: float, 
            coefficients: list[complex],
            words: list[cudaq.pauli_word]
        ):
   
    for i in range(len(coefficients)):
        exp_pauli(coefficients[i].real * dt, qubits, words[i])   # this crashes jupyter kernel on draw

num_qubits = 4
words =  [cudaq.pauli_word("XXXX")]
coefficients = [1.0]

counts = cudaq.sample(kernel, num_qubits, coefficients, words)

This used to work, as reported by @cuMikeBrown. Also, confirmed that it worked in 0.9.1.

Steps to reproduce the bug

See above

Expected behavior

Code runs

Is this a regression? If it is, put the last known working version (or commit) here.

0.9.1

Environment

  • CUDA-Q version: Latest main
  • Python version: 3.10
  • C++ compiler: 11
  • Operating system: Ubuntu

Suggestions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions