Hi, I wanted to know if there is a limitation in number of qubits in “default.mixed” device. As I try to create a device with 17 qubits I get an error, but when I try 16 or lower or when I change the device to “default.qubit” it seems to work with no problems.
dev = qml.device("default.mixed", wires=range(17))
Here is the error:
ValueError Traceback (most recent call last)
<ipython-input-95-b3946235d6d5> in <cell line: 1>()
----> 1 dev = qml.device("default.mixed", wires=range(17))
6 frames
/usr/local/lib/python3.10/dist-packages/pennylane/devices/device_constructor.py in device(name, *args, **kwargs)
261
262 # Construct the device
--> 263 dev = plugin_device_class(*args, **options)
264
265 # Once the device is constructed, we set its custom expansion function if
/usr/local/lib/python3.10/dist-packages/pennylane/logging/decorators.py in wrapper_exit(*args, **kwargs)
63 @wraps(func)
64 def wrapper_exit(*args, **kwargs):
---> 65 output = func(*args, **kwargs)
66 if lgr.isEnabledFor(log_level): # pragma: no cover
67 f_string = _get_bound_signature(*args, **kwargs)
/usr/local/lib/python3.10/dist-packages/pennylane/devices/default_mixed.py in __init__(self, wires, r_dtype, c_dtype, shots, analytic, readout_prob)
219
220 # Create the initial state.
--> 221 self._state = self._create_basis_state(0)
222 self._pre_rotated_state = self._state
223 self.measured_wires = []
/usr/local/lib/python3.10/dist-packages/pennylane/devices/default_mixed.py in _create_basis_state(self, index)
237 rho = qnp.zeros((2**self.num_wires, 2**self.num_wires), dtype=self.C_DTYPE)
238 rho[index, index] = 1
--> 239 return qnp.reshape(rho, [2] * (2 * self.num_wires))
240
241 @classmethod
/usr/local/lib/python3.10/dist-packages/autoray/autoray.py in do(fn, like, *args, **kwargs)
79 backend = _choose_backend(fn, args, kwargs, like=like)
80 func = get_lib_fn(backend, fn)
---> 81 return func(*args, **kwargs)
82
83
/usr/local/lib/python3.10/dist-packages/numpy/core/fromnumeric.py in reshape(a, newshape, order)
283 [5, 6]])
284 """
--> 285 return _wrapfunc(a, 'reshape', newshape, order=order)
286
287
/usr/local/lib/python3.10/dist-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
57
58 try:
---> 59 return bound(*args, **kwds)
60 except TypeError:
61 # A TypeError occurs if the object does have such a method in its
ValueError: maximum supported dimension for an ndarray is 32, found 34
and the qml.about() results:
Name: PennyLane
Version: 0.39.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Author:
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions
Required-by: PennyLane_Lightning
Platform info: Linux-6.1.85±x86_64-with-glibc2.35
Python version: 3.10.12
Numpy version: 1.26.4
Scipy version: 1.13.1
Installed devices:
- default.clifford (PennyLane-0.39.0)
- default.gaussian (PennyLane-0.39.0)
- default.mixed (PennyLane-0.39.0)
- default.qubit (PennyLane-0.39.0)
- default.qutrit (PennyLane-0.39.0)
- default.qutrit.mixed (PennyLane-0.39.0)
- default.tensor (PennyLane-0.39.0)
- null.qubit (PennyLane-0.39.0)
- reference.qubit (PennyLane-0.39.0)
- lightning.qubit (PennyLane_Lightning-0.39.0)
Seems like it’s a problem of ndarray, as other people have encountered this error in other scenarios with ndarray, but the suggestions include changing the dimensions or have the array in a flat form.
But as it is an internal function in the Pennylane, I don’t think I can do that.
Can you tell me how can I work around this error and create a mixed device with 17 qubits?