Error while performing iterative mid-circuit measurements #113
Unanswered
Gopal-Dahale
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Why do you need the inner for loop? Would the following work for you? #include <cudaq.h>
struct kernel {
void operator()() __qpu__ {
cudaq::qreg q(2);
// Prepare the initial state by superposition
h(q[1]);
// Mid circuit measurement
auto c = mz(q[1]);
if(c){
x(q[0]);
}
}
};
int main() {
const int nShots = 100;
auto counts = cudaq::sample(nShots, kernel{});
counts.dump();
} should output {
__global__ : { 00:52 11:48 }
c : { 0:52 1:48 }
} Granted, that we should be throwing a better error message for the case when sampling with an inner for loop. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to perform mid-circuit measurements and apply unitary based on the outcome. Below is the sample code:
I was able to run the program with the following commands without any error.
For small value of
steps
(like 10) the following commands works fine too but for 100, it gives error on running./a.out
.Error:
Any help in this regard is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions