diff --git a/python/runtime/cudaq/platform/py_alt_launch_kernel.cpp b/python/runtime/cudaq/platform/py_alt_launch_kernel.cpp index e3c29c67001..7bfcd5c0406 100644 --- a/python/runtime/cudaq/platform/py_alt_launch_kernel.cpp +++ b/python/runtime/cudaq/platform/py_alt_launch_kernel.cpp @@ -375,8 +375,9 @@ void bindAltLaunchKernel(py::module &mod) { auto name = kernel.attr("name").cast(); auto kernelFuncOp = getKernelFuncOp(module, name); cudaq::OpaqueArguments args; - cudaq::packArgs(args, runtimeArgs, kernelFuncOp, - [](OpaqueArguments &, py::object &) { return false; }); + cudaq::packArgs( + args, runtimeArgs, kernelFuncOp, + [](OpaqueArguments &, py::object &) { return false; }, false); return getQIRLL(name, module, args, profile); }, py::arg("kernel"), py::kw_only(), py::arg("profile") = ""); diff --git a/python/utils/OpaqueArguments.h b/python/utils/OpaqueArguments.h index 7bed619cb00..56cfc02d97d 100644 --- a/python/utils/OpaqueArguments.h +++ b/python/utils/OpaqueArguments.h @@ -184,16 +184,17 @@ inline mlir::func::FuncOp getKernelFuncOp(MlirModule module, return kernelFunc; } -inline void -packArgs(OpaqueArguments &argData, py::args args, - mlir::func::FuncOp kernelFuncOp, - const std::function - &backupHandler) { - if (kernelFuncOp.getNumArguments() != args.size()) - throw std::runtime_error("Invalid runtime arguments - kernel expected " + - std::to_string(kernelFuncOp.getNumArguments()) + - " but was provided " + - std::to_string(args.size()) + " arguments."); +inline void packArgs(OpaqueArguments &argData, py::args args, + mlir::func::FuncOp kernelFuncOp, + const std::function &backupHandler, + bool checkNumArgs = false) { + if (checkNumArgs) + if (kernelFuncOp.getNumArguments() != args.size()) + throw std::runtime_error("Invalid runtime arguments - kernel expected " + + std::to_string(kernelFuncOp.getNumArguments()) + + " but was provided " + + std::to_string(args.size()) + " arguments."); for (std::size_t i = 0; i < args.size(); i++) { py::object arg = args[i];