qiboteam / qibo

A full-stack framework for quantum computing.
https://qibo.science
Apache License 2.0
294 stars 60 forks source link

Superoperator Transformation not working (potential backend issue?) #1445

Closed alhajri closed 2 months ago

alhajri commented 2 months ago

I am trying to use some superoperator_transformations to change between different representations of the same channel.

import numpy as np
from qibo.quantum_info import liouville_to_choi
from qibo.quantum_info.superoperator_transformations import to_liouville, to_choi

channel_liouville = to_liouville(np.eye(2))

channel_choi = liouville_to_choi(channel_liouville)

outputs:

[Qibo 0.2.11|INFO|2024-09-13 10:34:36]: Using qibojit (numba) backend on /CPU:0
INFO:qibo.config:Using qibojit (numba) backend on /CPU:0
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-1-ca85966dc827>](https://localhost:8080/#) in <cell line: 5>()
      3 from qibo.quantum_info.superoperator_transformations import to_liouville, to_choi
      4 channel_liouville = to_liouville(np.eye(2))
----> 5 channel_choi = liouville_to_choi(channel_liouville)

1 frames
[/usr/local/lib/python3.10/dist-packages/qibo/quantum_info/superoperator_transformations.py](https://localhost:8080/#) in _reshuffling(super_op, order, backend)
   2131         ndarray: Choi (Liouville) representation of the quantum channel.
   2132     """
-> 2133     super_op = backend.cast(super_op)
   2134 
   2135     if not isinstance(order, str):

AttributeError: 'NoneType' object has no attribute 'cast'[Qibo 0.2.11|INFO|2024-09-13 10:34:36]: Using qibojit (numba) backend on /CPU:0
INFO:qibo.config:Using qibojit (numba) backend on /CPU:0
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-1-ca85966dc827>](https://localhost:8080/#) in <cell line: 5>()
      3 from qibo.quantum_info.superoperator_transformations import to_liouville, to_choi
      4 channel_liouville = to_liouville(np.eye(2))
----> 5 channel_choi = liouville_to_choi(channel_liouville)

1 frames
[/usr/local/lib/python3.10/dist-packages/qibo/quantum_info/superoperator_transformations.py](https://localhost:8080/#) in _reshuffling(super_op, order, backend)
   2131         ndarray: Choi (Liouville) representation of the quantum channel.
   2132     """
-> 2133     super_op = backend.cast(super_op)
   2134 
   2135     if not isinstance(order, str):

AttributeError: 'NoneType' object has no attribute 'cast'[Qibo 0.2.11|INFO|2024-09-13 10:34:36]: Using qibojit (numba) backend on /CPU:0
INFO:qibo.config:Using qibojit (numba) backend on /CPU:0
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-1-ca85966dc827>](https://localhost:8080/#) in <cell line: 5>()
      3 from qibo.quantum_info.superoperator_transformations import to_liouville, to_choi
      4 channel_liouville = to_liouville(np.eye(2))
----> 5 channel_choi = liouville_to_choi(channel_liouville)

1 frames
[/usr/local/lib/python3.10/dist-packages/qibo/quantum_info/superoperator_transformations.py](https://localhost:8080/#) in _reshuffling(super_op, order, backend)
   2131         ndarray: Choi (Liouville) representation of the quantum channel.
   2132     """
-> 2133     super_op = backend.cast(super_op)
   2134 
   2135     if not isinstance(order, str):

AttributeError: 'NoneType' object has no attribute 'cast'

The above was ran on a colab notebook. I tested the same code snippet on my local computer where I have 'Qibo 0.2.7' and had no issues.

renatomello commented 2 months ago

Can you try on collab with this together with the other imports?

from qibo import set_backend
set_backend("numpy")
alhajri commented 2 months ago

same issue

renatomello commented 2 months ago

PR #1446 fixes the issue. In the meantime you can use qibo either from that branch or from release versions up to 0.2.9