-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YaoBlocks.cunmat
has problems during tracing
#174
Comments
Why would it recurse infinitely? What would you add as extension for |
The problem is that What we need to do is a |
I mean honestly an intermediate thing we should do is define a convert(Array, TracedRArray) which throws an error saying that this is an illegal operation. |
YaoBlocks.cunmat
has problems during tracingsYaoBlocks.cunmat
has problems during tracing
Yeah, but we would like to trace over this function. |
Yeah but throwing an error will help anyone else with such a conversion in their code (and nicely show where/why/what's up). In this particular case though, I think the fix is better in YaoBlocks.jl to define their Array specialization to actually take a DenseArray and define TracedRArray as a densearray [meaning everything works properly without much extra handling] |
I'm ok with this: throwing an error when you call
Probably won't work either because it then tries to construct a sparse matrix and fill the bottom-right 2x2 sub matrix with the I agree that this should be a fix or a package extension in YaoBlocks.jl, but since Reactant.jl is moving fast and breaking, I guess is better if we do a package extension right now in here and later move it to YaoBlocks.jl when Reactant.jl achieves some stability. Also, we can ask @Roger-luo @GiggleLiu |
YaoBlocks.cunmat
generates the matrix representation of a controlled unitary gate. For that, it calls for theMatrix
representation of the controlled gate and it embeds it around a... "larger identity matrix". For example, it starts fromThe problema arises when trying to trace over
cunmat
, since the matrix representation of the controlled gate, calledU0
, will be aTracedRArray{ComplexF64,2}
which dispatches to this code:https://github.com/QuantumBFS/Yao.jl/blob/3c6a767623c34b376f131900110e71a8135e2ba3/lib/YaoBlocks/src/routines.jl#L212-L220
... and it will call
Matrix(::TracedRArray{ComplexF64,2})
which is not defined. Furthermore, if we defined this method as a no-op and just return the argument, it would just recurse infinitely. We may need a package extension forYaoBlocks
to fix this.CC @jofrevalles
The text was updated successfully, but these errors were encountered: