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

cudaq.translate(format='openqasm2') fails for adjoint modifier #2465

Open
arulandu opened this issue Dec 11, 2024 · 0 comments
Open

cudaq.translate(format='openqasm2') fails for adjoint modifier #2465

arulandu opened this issue Dec 11, 2024 · 0 comments
Labels
python-lang Anything related to the Python CUDA Quantum language implementation

Comments

@arulandu
Copy link

arulandu commented Dec 11, 2024

Consider the following cudaq kernel.

  def s_kernel():
      k, q = cudaq.make_kernel(cudaq.qubit)
      k.s(q)
      return k

  kernel = cudaq.make_kernel()
  reg = kernel.qalloc(1)
  kernel.adjoint(s_kernel(), reg[0])
  
  print("CUDAQ", kernel)
  print("QASM", cudaq.translate(kernel, format="openqasm2"))

Output:

CUDAQ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen____nvqppBuilderKernel_NBJIEOE85U = "__nvqpp__mlirgen____nvqppBuilderKernel_NBJIEOE85U_PyKernelEntryPointRewrite"}} {
  func.func @__nvqpp__mlirgen____nvqppBuilderKernel_NBJIEOE85U() attributes {"cudaq-entrypoint"} {
    %0 = quake.alloca !quake.veq<1>
    %1 = quake.extract_ref %0[0] : (!quake.veq<1>) -> !quake.ref
    quake.apply<adj> @__nvqpp__mlirgen____nvqppBuilderKernel_FVE4B53IYY %1 : (!quake.ref) -> ()
    return
  }
  func.func @__nvqpp__mlirgen____nvqppBuilderKernel_FVE4B53IYY(%arg0: !quake.ref) {
    quake.s %arg0 : (!quake.ref) -> ()
    return
  }
}

QASM // Code generated by NVIDIA's nvq++ compiler
OPENQASM 2.0;

include "qelib1.inc";

gate nvqpp__mlirgen____nvqppBuilderKernel_FVE4B53IYY q0 {
  s q0;
}

qreg var0[1];
@__nvqpp__mlirgen____nvqppBuilderKernel_FVE4B53IYY var0[0];

As you can see, the MLIR has a quake.apply<adj> as intended but the translated OpenQASM 2.0 does not have the adjoint.

Produced on Ubuntu 24.04.1 LTS.

@schweitzpgi schweitzpgi added the python-lang Anything related to the Python CUDA Quantum language implementation label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python-lang Anything related to the Python CUDA Quantum language implementation
Projects
None yet
Development

No branches or pull requests

2 participants