You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Describe the bug
This is a continuation of #603, which has not been resolved entirely.
Some kernels don't translate to a valid QASM - specifically, gate definitions appear after their calls.
In this case, it has something to do with empty kernels (identity operators).
Steps to reproduce the bug
I ran the code below:
#include<cudaq.h>
#include<iostream>intmain() {
auto [kernel1, qubit1] = cudaq::make_kernel<cudaq::qubit>();
auto [kernel2, qubit2] = cudaq::make_kernel<cudaq::qubit>();
kernel2.x(qubit2);
kernel2.call(kernel1, qubit2);
auto [kernel3, qubit3] = cudaq::make_kernel<cudaq::qubit>();
kernel3.h(qubit3);
kernel3.call(kernel2, qubit3);
kernel3.h(qubit3);
kernel3.mz(qubit3);
auto kernel4 = cudaq::make_kernel();
auto qubit4 = kernel4.qalloc();
kernel4.call(kernel1, qubit4);
kernel4.call(kernel3, qubit4);
std::cout << kernel4.to_quake() << std::endl;
return0;
}
Then, I ran cudaq-translate --convert-to=openqasm example.qke. The following QASM code has been generated, with the gate nvqpp__mlirgen____nvqppBuilderKernel_367535629127 illegally being called before being defined.
// Code generated by NVIDIA's nvq++ compiler
OPENQASM 2.0;
include "qelib1.inc";
gate nvqpp__mlirgen____nvqppBuilderKernel_093606261879 q0 {
x q0;
nvqpp__mlirgen____nvqppBuilderKernel_367535629127 q0;
}
gate nvqpp__mlirgen____nvqppBuilderKernel_202375922897 q0 {
h q0;
nvqpp__mlirgen____nvqppBuilderKernel_093606261879 q0;
h q0;
creg var1[1];
measure q0 -> var1[0];
}
gate nvqpp__mlirgen____nvqppBuilderKernel_367535629127 q0 {
}
qreg var0[1];
nvqpp__mlirgen____nvqppBuilderKernel_367535629127 var0[0];
nvqpp__mlirgen____nvqppBuilderKernel_202375922897 var0[0];
Expected behavior
The code below or an equivalent:
// Code generated by NVIDIA's nvq++ compiler
OPENQASM 2.0;
include "qelib1.inc";
gate nvqpp__mlirgen____nvqppBuilderKernel_367535629127 q0 {
}
gate nvqpp__mlirgen____nvqppBuilderKernel_093606261879 q0 {
x q0;
nvqpp__mlirgen____nvqppBuilderKernel_367535629127 q0;
}
gate nvqpp__mlirgen____nvqppBuilderKernel_202375922897 q0 {
h q0;
nvqpp__mlirgen____nvqppBuilderKernel_093606261879 q0;
h q0;
creg var1[1];
measure q0 -> var1[0];
}
qreg var0[1];
nvqpp__mlirgen____nvqppBuilderKernel_367535629127 var0[0];
nvqpp__mlirgen____nvqppBuilderKernel_202375922897 var0[0];
Is this a regression? If it is, put the last known working version (or commit) here.
Required prerequisites
Describe the bug
This is a continuation of #603, which has not been resolved entirely.
Some kernels don't translate to a valid QASM - specifically, gate definitions appear after their calls.
In this case, it has something to do with empty kernels (identity operators).
Steps to reproduce the bug
I ran the code below:
And it generated the following Quake code:
Then, I ran
cudaq-translate --convert-to=openqasm example.qke
. The following QASM code has been generated, with the gatenvqpp__mlirgen____nvqppBuilderKernel_367535629127
illegally being called before being defined.Expected behavior
The code below or an equivalent:
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
Cudaq Docker image ID:
sha256:672fdd4393aab3b27162a5ede45bc5f651801442e372441bb1e3e516b643e0ea
Additional data:
Suggestions
No response
The text was updated successfully, but these errors were encountered: