MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / pyObserveAsync

Function pyObserveAsync

python/runtime/cudaq/algorithms/py_observe_async.cpp:66–92  ·  view source on GitHub ↗

The base `observe` launcher.

Source from the content-addressed store, hash-verified

64
65// The base `observe` launcher.
66static async_observe_result pyObserveAsync(const std::string &shortName,
67 mlir::ModuleOp mod,
68 const spin_op &spin_operator,
69 std::size_t qpu_id, int shots,
70 nanobind::args args) {
71 auto &platform = get_platform();
72 args = simplifiedValidateInputArguments(args);
73 auto fnOp = getKernelFuncOp(mod, shortName);
74 auto opaques = marshal_arguments_for_module_launch(mod, args, fnOp);
75
76 // Launch the asynchronous execution.
77 nanobind::gil_scoped_release release;
78 auto clonedMod = std::shared_ptr<mlir::ModuleOp>(
79 new mlir::ModuleOp(mod.clone()), [](mlir::ModuleOp *p) {
80 p->erase();
81 delete p;
82 });
83 return detail::runObservationAsync(
84 detail::make_copyable_function(
85 [opaques = std::move(opaques), shortName, clonedMod]() mutable {
86 if (cudaq::getEnvBool("CUDAQ_DUMP_JIT_IR", false))
87 clonedMod->dump();
88 [[maybe_unused]] auto result =
89 clean_launch_module(shortName, *clonedMod, opaques);
90 }),
91 spin_operator, platform, shots, shortName, qpu_id);
92}
93
94static async_observe_result
95observe_async_impl(const std::string &shortName, MlirModule module,

Callers 2

observe_async_implFunction · 0.85
pyObserveParFunction · 0.85

Calls 7

getKernelFuncOpFunction · 0.85
runObservationAsyncFunction · 0.85
make_copyable_functionFunction · 0.85
getEnvBoolFunction · 0.85
eraseMethod · 0.80
cloneMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected