Closed hsinyuryanwu closed 9 months ago
Multicontrol X seems to be implemented as Toffoli (it allows general number of controls) however when I go to use it as
import qadence as qd
qd.Toffoli((1,2,3,), 4)
I get the error message
module 'qadence' has no attribute 'Toffoli'
This method of calling other gates has worked so not sure why not for Toffoli. My only thought is I have noticed that Toffoli is not included in all of operations.py.
Any help in using Toffoli is appreciated!
Only MCZ is provided. display(MCZ([0,1,3], 2)) However, what we need is MCX.
Thanks @AnniePaine and @hsinyuryanwu for reporting this bug and feature request.
Toffoli((1,2,3,), 4)
Indeed, it seems that the Toffoli
gate is not properly exported. I opened a PR to fix this: https://github.com/pasqal-io/qadence/pull/195.
For the usage of Toffoli gate, recall that the Python indexing system starts from 0. The following should work:
import qadence as qd
block = qd.chain(
qd.X(0),
qd.operations.Toffoli((0,1,2), 3)
)
samples = qd.sample(block)
Only MCZ is provided. display(MCZ([0,1,3], 2)) However, what we need is MCX.
The MCRX
operation for multi-qubit controlled rotation is available. Does this work for you? The Sqrt(X)
gate is indeed currently missing, I will add the corresponding issue.
Hi Madagra,
display(qd.operations.Toffoli((0,1,3), 2))
Could we just use qd.Toffoli without "operations" sandwitched between them?
Hey @hsinyuryanwu, we just released qadence v1.1.0
which contains the qd.Toffoli
fix, so if you
pip install --upgrade qadence
you should be able to leave out the operations
.
I will close this issue, because the Sqrt
gate is tracked here. Let us know if you find/need anything else!
Hi Qadence team,
Would it be possible to add these two functions?
For example, MCX([0,2,3,4], 1, controlled type), where the controlled type is [|1>,|1>,|1>,|1>] by default. It would be great if the users can arbitrarily change it to [|1>,|0>,|0>,|1>] for MCRX, MCRZ and MCX functions.
We need their dagger (adjoint) version as well.
Thanks, Hsin-Yu