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

New launch kernel is not invoked for python #2299

Open
3 of 4 tasks
annagrin opened this issue Oct 18, 2024 · 1 comment
Open
3 of 4 tasks

New launch kernel is not invoked for python #2299

annagrin opened this issue Oct 18, 2024 · 1 comment

Comments

@annagrin
Copy link
Collaborator

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

Python code using states as arguments fails to synthesize on quantum targets and remote sim due to the new launch kernel not being invoked (old synthesis message is displayed)

Steps to reproduce the bug

Code

# RUN: PYTHONPATH=../../.. python3 %s --target  --remote-mqpu
# RUN: PYTHONPATH=../../.. python3 %s --target  --quantinuum --emulate

import cudaq
import numpy as np
def test_init_from_data_state():
    c = np.array([1. / np.sqrt(2.) + 0j, 1. / np.sqrt(2.), 0., 0.],
                 dtype=np.complex128)
    state = cudaq.State.from_data(c)
    @cudaq.kernel
    def kernel(vec: cudaq.State):
        q = cudaq.qvector(vec)
    counts = cudaq.sample(kernel, state)
    assert '10' in counts
    assert '00' in counts
test_init_from_data_state()

def test_init_from_state():
    @cudaq.kernel
    def init(n: int):
        q = cudaq.qvector(n)
        ry(np.pi/2.0, q[0])
    @cudaq.kernel
    def kernel(vec: cudaq.State):
        q = cudaq.qvector(vec)
    state = cudaq.get_state(init, 2)
    counts = cudaq.sample(kernel, state)
    assert '10' in counts
    assert '00' in counts
test_init_from_state()

Output

root@f4bab51c0fb2:/workspaces/cuda-quantum# python3 python/tests/mlir/target/tmp.py --target quantinuum
error: 'func.func' op synthesis: unsupported argument type for remote devices and simulators: state*
error: 'func.func' op We cannot synthesize argument(s) of this type.
RuntimeError: Could not successfully apply quake-synth.

Expected behavior

For remote sim, the code should run successfully. For quantinuum, the code should run successfully after #2291

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

Not a regression

Environment

  • CUDA Quantum version:
  • Python version:
  • C++ compiler:
  • Operating system:

Suggestions

No response

@schweitzpgi
Copy link
Collaborator

This will require refactoring the platofrm/qpu interface along with the caching of Python kernels done in these layers. Specifically, this is caching a lower variant of the kernel with the expectation that the arguments will be provided late. The new argument synthesis takes the opposite approach: arguments are synthesized earlier. #2338 will help with many of the problems, but it will never support cudaq::state since that cannot be synthesized in the compiler.

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

No branches or pull requests

2 participants