Open cqc-alec opened 1 week ago
The bug does not appear with quantum-pecos 0.6.0.dev3: it seems to have been introduced in quantum-pecos 0.6.0.dev4.
This is what appears to be happening:
R1XY(1.0pi, 1.75pi)
gate is equivalent (up to global phase) to an "H4" gate, where H4=S*S*S*H*S*S*H
(see here)
R1XY
gate with an H4
gate.H4
gate, so PECOS leaves it as an R1XY
gate. This explains why there's no bug when 1.75
is changed to 1.76
.state-vector
simulator does not support the H4
gate, so it errors out at self.bindings["H4"]
with a KeyError
.I do not know what's the code responsible for the conversion of R1XY
to H4
. However, a simple fix for this is to add H4
and all other Clifford gates in the list here to the simulators. I will do this in a PR + include a better error message when a gate is not supported by a simulator.
It is likely that the conversion from R1XY
to H4
has been a feature of PECOS since before .dev4
. The bug is likely to have appeared on .dev4
onwards due to a change of the default simulator from ProjectQ to Qulacs. The wrapper of ProjectQ had support for the H4
gate.
In theory, a workaround for users is to select ProjectQ as the simulator (the one that was used in .dev3
). Unfortunately, I'm getting a different error which may be related to my ProjectQ installation. Does this work for anyone else?
engine = HybridEngine(qsim="ProjectQSim")
Another option is to use the version of PECOS from PR #87.
When I run with dev3 I do get the following scary output:
Exception ignored in: <function ProjectQSim.__del__ at 0x77dadad91300>
Traceback (most recent call last):
File "/home/alec/r/pytket-quantinuum/env/lib/python3.12/site-packages/pecos/simulators/projectq/state.py", line 155, in __del__
File "/home/alec/r/pytket-quantinuum/env/lib/python3.12/site-packages/projectq/cengines/_main.py", line 326, in flush
File "/home/alec/r/pytket-quantinuum/env/lib/python3.12/site-packages/projectq/ops/_command.py", line 118, in __init__
File "/home/alec/r/pytket-quantinuum/env/lib/python3.12/site-packages/projectq/ops/_command.py", line 248, in control_state
ModuleNotFoundError: import of projectq.meta halted; None in sys.modules
However, I think this is harmless -- something to do with ProjectQ not being shut down correctly on program exit.
Yeah, it would be good to figure out the right way to approach turning on an off the general gate to Clifford conversion. But that might take some thinking out to do. Pablo's fix in PR #87 seems like a good solution for now.
The error with ProjectQ is a bit concerning. Although, it can be a bit frustrating to set up. @cqc-alec what operating system are you using?
Although, reading this again... I seem to recall that you had a similar issue in the past when using Python's REPL and not in other circumstances, which was never solved.
Yes I did get a similar issue in the past. I'm using Linux. It's not just using the REPL; I get it when exexuting python my_script.py
from bash.
@ciaranra Can we have a new dev release so that we can close this?
Version: quantum-pecos 0.6.0.dev5
Output:
If "1.75" is changed to "1.76", there is no error!