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

Hybrid QNN and VQE samples do not work with an external QPU provider #2373

Open
4 tasks done
nkushida-oqc opened this issue Nov 12, 2024 · 1 comment
Open
4 tasks done
Labels
needs triage Marks items that require a follow up for proper processing python-lang Anything related to the Python CUDA Quantum language implementation

Comments

@nkushida-oqc
Copy link
Contributor

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

After applied this PR, I tried to run Hybrid QNN sample with OQC's QPU. However, I got the following error;
`TypeError: init(): incompatible constructor arguments. The following argument types are supported:
1. cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.ObserveResult(arg0: float, arg1: cudaq::spin_op, arg2: cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SampleResult)

Invoked with: None, <cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SpinOperator object at 0x7ffb61af9270>, <cudaq.mlir._mlir_libs._quakeDialects.cudaq_runtime.SampleResult object at 0x7ffb5e346cf0>`

Another example is https://nvidia.github.io/cuda-quantum/0.8.0/examples/python/tutorials/vqe.html;
This gives;
python3: /home/.llvm-project/mlir/lib/IR/PatternMatch.cpp:276: virtual void mlir::RewriterBase::eraseOp(mlir::Operation*): Assertion op->use_empty() && "expected 'op' to have no uses"' failed.
Aborted (core dumped)
`

However, Max Cut example (https://nvidia.github.io/cuda-quantum/latest/applications/python/qaoa.html) seems to be working.
One of CPP test codes also works;
https://github.com/NVIDIA/cuda-quantum/blob/7b4222430542fe87b103ba58bf94dde5c875e739/targettests/execution/cudaq_observe.cpp

Steps to reproduce the bug

qnn.py.txt
QNN code is the above.

vqe.py.txt
VQE code is the above

Expected behavior

Reproduce the same result with the samples with local simulators.

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

Not a regression

Environment

  • 0.8.0:
  • 3.10:
  • GCC12/LLVM16:
  • Ubuntu 22.04:

Suggestions

It seems to be that an internal transpiler/compiler could not generate QIR for some reasons.

@schweitzpgi schweitzpgi added python-lang Anything related to the Python CUDA Quantum language implementation needs triage Marks items that require a follow up for proper processing labels Nov 19, 2024
@bmhowe23
Copy link
Collaborator

With all the latest fixes from main, this is no longer producing the errors provided in the original issue description, but it is failing in different ways. For example, the attached VQE example fails with:

error: 'cc.loop' op not a constant upper bound loop
...
error: 'cc.loop' op loop bounds exceed iteration threshold
...
error: did not unroll loops
RuntimeError: NLOpt runtime error: nlopt failure
...

(This can also be reproduced by running with the emulate flag, like this: cudaq.set_target("oqc", emulate=True).)

This particular example uses cudaq.kernels.uccsd(), which may exceed the limits to which the loops can be unrolled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Marks items that require a follow up for proper processing python-lang Anything related to the Python CUDA Quantum language implementation
Projects
None yet
Development

No branches or pull requests

3 participants