Error when using U gate
Hi Tyson,
Some code that was previously working fine now has a new error and I am not sure why.
The error I am getting is when applying a U gate, and it is saying that the matrix is not unitary.
It did not before complain my matrix is not unitary, which I know it is by construction as it is defined as $e^{-i \theta M}$ for some diagonal matrix M. As a sanity check I used the function 'UnitaryMatrixQ' to check, which also did not think it was unitary, but when I added a tolerance of 10^-12 it agreed it was ($M^{\dagger}M - I$ is a diagonal matrix with elements on the order of 10^-13).
Thanks, Joe
As some further information, this error seems only to be arising on my university computer, where I am using CreateLocalQuESTEnv with a pre-compiled executable to use the GPU, whereas the same code below does not have an error when I run it on my laptop and use CreateDownloadedQuESTEnv instead
Hi Joe,
There are two unrelated issues here!
issue 1
The matrix unitarity check is really a convenience/safety-check for users, to attempt to catch scenarios where a user has messed up their matrix. Unitarity isn't actually used/needed by the internal invoked function. Sometimes making a strictly unitary matrix is numerically difficult, and the unitarity check itself is susceptive to finite-precision errors. In these instances, when U will overzealously complain about unitarity for matrices you're confident should be treated as unitary, you can use the alternative gate UNonNorm. This behaves identically, except that it doesn't check matrix unitarity.
issue 2
This one's my fault. Version 0.14 changed how Mathematica and the C process communicate. If you obtain the Mathematica interface via...
Import["https://qtechtheory.org/questlink.m"];
then you must re-download and re-compile your local version of QuESTlink, using the latest Github code.
Generally, if you're using a local (and ergo static) copy of QuEST for manual compiling, you should not use the above Import[] URL. Instead, you should call
Import["QuESTlink/Link/QuESTlink.m"];
CreateLocalQuESTEnv[];
Otherwise, you risk obtaining incompatible versions of the "frontend" (the .m file) and "backend" (the quest_link executable).
You can also Import a specific version of the frontend via a direct/raw github link. For example:
Import["https://raw.githubusercontent.com/QTechTheory/QuESTlink/v0.13/Link/QuESTlink.m"]
This is a caution I really need to add to the documentation (iirc this was our first backward-breaking change), so please don't close this issue! I'll keep it open as a reminder to update the doc.
Thanks very much, and apologies for the confusion! Tyson
Hi Tyson, As you suggested, re-downloading and compiling again fixed my problem, thanks for the help!
Joe