@@ -657,6 +657,7 @@ class BaseRemoteRESTQPU : public cudaq::QPU {
657
657
localShots = executionContext->shots ;
658
658
659
659
executor->setShots (localShots);
660
+ bool isObserve = executionContext && executionContext->name == " observe" ;
660
661
661
662
// If emulation requested, then just grab the function
662
663
// and invoke it with the simulator
@@ -669,7 +670,7 @@ class BaseRemoteRESTQPU : public cudaq::QPU {
669
670
// Launch the execution of the simulated jobs asynchronously
670
671
future = cudaq::details::future (std::async (
671
672
std::launch::async,
672
- [&, codes, localShots, kernelName, seed,
673
+ [&, codes, localShots, kernelName, seed, isObserve,
673
674
reorderIdx = executionContext->reorderIdx ,
674
675
localJIT = std::move (jitEngines)]() mutable -> cudaq::sample_result {
675
676
std::vector<cudaq::ExecutionResult> results;
@@ -680,7 +681,7 @@ class BaseRemoteRESTQPU : public cudaq::QPU {
680
681
681
682
bool hasConditionals =
682
683
cudaq::kernelHasConditionalFeedback (kernelName);
683
- if (hasConditionals && codes. size () > 1 )
684
+ if (hasConditionals && isObserve )
684
685
throw std::runtime_error (" error: spin_ops not yet supported with "
685
686
" kernels containing conditionals" );
686
687
if (hasConditionals) {
@@ -710,18 +711,15 @@ class BaseRemoteRESTQPU : public cudaq::QPU {
710
711
}
711
712
}
712
713
713
- bool isObserve =
714
- executionContext && executionContext->name == " observe" ;
715
714
for (std::size_t i = 0 ; i < codes.size (); i++) {
716
715
cudaq::ExecutionContext context (" sample" , localShots);
717
716
context.reorderIdx = reorderIdx;
718
717
cudaq::getExecutionManager ()->setExecutionContext (&context);
719
718
invokeJITKernelAndRelease (localJIT[i], kernelName);
720
719
cudaq::getExecutionManager ()->resetExecutionContext ();
721
720
722
- // If there are multiple codes, this is likely a spin_op.
723
- // If so, use the code name instead of the global register.
724
- if (isObserve || (codes.size () > 1 )) {
721
+ if (isObserve) {
722
+ // Use the code name instead of the global register.
725
723
results.emplace_back (context.result .to_map (), codes[i].name );
726
724
results.back ().sequentialData =
727
725
context.result .sequential_data ();
@@ -743,7 +741,7 @@ class BaseRemoteRESTQPU : public cudaq::QPU {
743
741
// Allow developer to disable remote sending (useful for debugging IR)
744
742
if (getEnvBool (" DISABLE_REMOTE_SEND" , false ))
745
743
return ;
746
- future = executor->execute (codes);
744
+ future = executor->execute (codes, isObserve );
747
745
}
748
746
749
747
// Keep this asynchronous if requested
0 commit comments