my workflow is such that, I have 2 classes one that calculates some unitaries, and the other that build the circuit with those unitaries. The first class has a function that builds a object of the other classes passing to it all the unitaries. in the second classes I istantiate a kernel using the matrices passed.
At first I realized that I couldn’t pass numpy array, because it accept only list and scalars, so I passed a list. It give me this error "CompilerError: 443249349.py:17: error: Invalid type for variable (U) captured from parent scope (only int, bool, float, and list[int|bool|float] accepted, type was <class ‘list’>).
(offending source → U)
"
Hi,
Thanks for the question and sharing your use case. Are you using CUDA-Q’s register_operation
API in Python?
And do you pass the matrix to the function where custom operation is being created?
From the error message, it seems that the code is expecting U
to be available from global / parent scope but needs to be explicitly passed.
Can share code snippet(s) so I can reproduce this error and potentially be able to provide a fix?
Ref: User-Defined Custom Operations — NVIDIA CUDA-Q documentation