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

Some target tests don't work with translation to OpenQASM 2.0 #2325

Open
4 tasks done
kshyatt-aws opened this issue Oct 28, 2024 · 3 comments
Open
4 tasks done

Some target tests don't work with translation to OpenQASM 2.0 #2325

kshyatt-aws opened this issue Oct 28, 2024 · 3 comments

Comments

@kshyatt-aws
Copy link

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

Creating a new backend which uses OpenQASM 2.0 as the IR breaks several of the targettests/execution tests, including:

  • custom_operation_basic.cpp - custom ops aren't supported in OQ2
  • custom_operation_adj.cpp
  • custom_operation_ctrl.cpp
    These 3 fail with:
+ /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/custom_operation_adj.cpp
loc("-":30:1): error: 'cc.global' op unable to translate op to OpenQASM 2.0
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/custom_operation_adj.cpp

Also failing are:

  • graph_coloring-1.cpp
  • graph_coloring.cpp
    with:
+ /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/graph_coloring-1.cpp
loc(callsite("graph_coloring-1.cpp":42:3 at "graph_coloring-1.cpp":86:3)): error: cannot convert operation to OpenQASM 2.0.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/graph_coloring-1.cpp

and

loc(callsite(callsite("graph_coloring.cpp":41:3 at "graph_coloring.cpp":59:3) at "graph_coloring.cpp":105:3)): error: cannot create adjoint for this operation.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.
  • int8_t.cpp
  • int8_t_free_func.cpp
  • load_value.cpp
  • swap_gate.cpp
  • variable_size_qreg.cpp
    with
+ /workspaces/cuda-quantum/build/targettests/execution/Output/int8_t.cpp.tmp
+ /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/int8_t.cpp
loc("int8_t.cpp":26:5): error: 'cc.alloca' op unable to translate op to OpenQASM 2.0
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.
  • qspan_slices.cpp
    with
+ /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/qspan_slices.cpp
loc(callsite("qspan_slices.cpp":27:19 at "qspan_slices.cpp":35:3)): error: 'quake.subveq' op unable to translate op to OpenQASM 2.0
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.
  • sudoku_2x2.cpp
  • sudoku_2x2-1.cpp
  • sudoku_2x2-reg_name.cpp
  • sudoku_2x2-bit_names.cpp
    with
loc(callsite("sudoku_2x2-1.cpp":27:3 at "sudoku_2x2-1.cpp":49:5)): error: cannot convert operation to OpenQASM 2.0.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.

and

  • phase_estimation.cpp
    with
+ CUDAQ_DUMP_JIT_IR=1
+ /workspaces/cuda-quantum/build/targettests/execution/Output/phase_estimation.cpp.tmp
/workspaces/cuda-quantum/build/targettests/execution/Output/phase_estimation.cpp.script: line 2: 40075 Aborted                 CUDAQ_DUMP_JIT_IR=1 /workspaces/cuda-quantum/build/targettests/execution/Output/phase_estimation.cpp.tmp &> phase_estimation.cpp.ir

(didn't get much info from this about what the failure cause was).

My lowering pass is:

platform-lowering-config: "const-prop-complex,canonicalize,cse,lift-array-value,state-prep,unitary-synthesis,canonicalize,apply-op-specialization,aggressive-early-inlining,unrolling-pipeline,func.func(lower-to-cfg),canonicalize,func.func(multicontrol-decomposition),func.func(memtoreg{quantum=0})"

Steps to reproduce the bug

Create a new REST backend with the above lowering config in its backend.yml and use that as the target in the targettests/execution tests.

Expected behavior

Tests should ideally pass or offer a more descriptive error message in some cases.

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

Not a regression

Environment

  • CUDA Quantum version: 0.8, CUDA 11.8
  • Python version: N/A
  • C++ compiler: gcc 11.4.0
  • Operating system: Linux 01c0ebb026db 6.6.12-linuxkit #1 SMP Thu Feb 8 06:36:34 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux (the CUDA-Quantum dev container on a Mac M2)

Suggestions

No response

@kshyatt-aws
Copy link
Author

cc @khalatepradnya

@kshyatt-aws
Copy link
Author

Some more testing reveals that exp_pauli.cpp also fails with:

+ /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/exp_pauli.cpp
loc("exp_pauli.cpp":30:30): error: 'cc.string_literal' op unable to translate op to OpenQASM 2.0
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.

and test-6.cpp with:

+ /usr/local/llvm/bin/FileCheck /workspaces/cuda-quantum/targettests/execution/test-6.cpp
loc("test-6.cpp":42:17): error: 'quake.mx' op unable to translate op to OpenQASM 2.0
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not successfully translate to qasm2.
FileCheck error: '<stdin>' is empty.

(maybe related to #2219)?

@kshyatt-aws
Copy link
Author

The error: 'cc.alloca' op unable to translate op to OpenQASM 2.0 has been resolved by adding func.func(const-prop-complex,canonicalize,cse,lift-array-alloc),globalize-array-values to the pipeline lowering config, thank you to @khalatepradnya for the suggestion. The sudoku examples are still failing at this gate:

z<cudaq::ctrl>(qubits[0], qubits[1], qubits[2], qubits[3]);

Because gate modfiiers aren't supported in OQ2. However, I'm wondering if another compiler pass could lower this to gates which are supported (e.g. SWAP, CX, and friends)?

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

1 participant