CQCL / pytket-cutensornet

cuTensorNet Python API extensions for pytket quantum SDK
Apache License 2.0
8 stars 1 forks source link

Example `mps_tutorial.py` catches incorrect exception #127

Closed obackhouse closed 3 weeks ago

obackhouse commented 3 weeks ago

The example catches a RuntimeError

https://github.com/CQCL/pytket-cutensornet/blob/ef0d2fe04731dad1a219f668eb11a35432a0a98e/examples/python/mps_tutorial.py#L163-L167

however the code raises a ValueError

Traceback (most recent call last):
  File "/home/ollie/git/pytket-cutensornet/examples/python/mps_tutorial.py", line 165, in <module>
    simulate(libhandle, bad_circ, SimulationAlgorithm.MPSxGate, Config())
  File "/home/ollie/git/pytket-cutensornet/pytket/extensions/cutensornet/structured_state/simulation.py", line 116, in simulate
    state.apply_gate(g)
  File "/home/ollie/git/pytket-cutensornet/pytket/extensions/cutensornet/structured_state/mps.py", line 185, in apply_gate
    self.apply_unitary(unitary, gate.qubits)
  File "/home/ollie/git/pytket-cutensornet/pytket/extensions/cutensornet/structured_state/mps.py", line 243, in apply_unitary
    raise ValueError("Gates must be applied to adjacent qubits!")
ValueError: Gates must be applied to adjacent qubits!
PabloAndresCQ commented 3 weeks ago

Hi Ollie, thanks for reporting this, and I'm glad you're now able to run the examples!

This would be a trivial change to do, but it won't be needed: #119 (to be merged soon) will remove the error altogether, since non-adjacent gates are supported. The jupyter notebook is appropriately updated in that PR.