-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when running circuits #51
Comments
Thanks @renatomello for noting down this error. From the call stack, it seems the way quimb is invoked has some issue. Particularly, the args provided might not be compatible. @Vinitha-balachandran Can we take a look and prepare a PR for the fix? |
@liweintu Sure, will check. |
@renatomello computation settings has to be given before the set_backend. It was a mistake in doc. And, for your code with the import c= Circuit(2) instead of c = qibo.Circuit(2). There was no error when I run the code with this fix. I will update the doc. |
The problem was that |
If I try to print the result object instead of calling the In [17]: from qibo import Circuit, gates, set_backend
...:
...: computation_settings = {
...: "MPI_enabled": False,
...: "MPS_enabled": False,
...: "NCCL_enabled": False,
...: "expectation_enabled": False,
...: }
...:
...: # Set the quimb backend
...: set_backend(
...: backend="qibotn", platform="cutensornet", runcard=computation_settings
...: )
...:
...: # Construct the circuit with two qubits
...: c = Circuit(2)
...:
...: # Apply Hadamard gates on first and second qubit
...: c.add(gates.H(0))
...: c.add(gates.H(1))
...: c.add(gates.CZ(0, 1))
...:
...: # Execute the circuit and obtain the final state
...: result = c()
...:
...: # Print the final state
...: print(result) [Qibo 0.2.7|INFO|2024-03-28 10:44:57]: Using qibotn (cutensornet) backend on /CPU:0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[17], line 27
24 result = c()
26 # Print the final state
---> 27 print(result)
File ~/.local/lib/python3.10/site-packages/qibo/result.py:108, in QuantumState.__str__(self)
107 def __str__(self):
--> 108 return self.symbolic()
File ~/.local/lib/python3.10/site-packages/qibo/result.py:60, in QuantumState.symbolic(self, decimals, cutoff, max_terms)
56 terms = self.backend.calculate_symbolic_density_matrix(
57 self._state, self.nqubits, decimals, cutoff, max_terms
58 )
59 else:
---> 60 terms = self.backend.calculate_symbolic(
61 self._state, self.nqubits, decimals, cutoff, max_terms
62 )
63 return " + ".join(terms)
File ~/.local/lib/python3.10/site-packages/qibo/backends/numpy.py:578, in NumpyBackend.calculate_symbolic(self, state, nqubits, decimals, cutoff, max_terms)
576 terms = []
577 for i in np.nonzero(state)[0]:
--> 578 b = bin(i)[2:].zfill(nqubits)
579 if np.abs(state[i]) >= cutoff:
580 x = np.round(state[i], decimals)
TypeError: 'ndarray' object cannot be interpreted as an integer |
Also, calling the |
About the last two comments, primarily we were interested to have one to one comparison of state vector and tensor network method. So, at present we are converting the mps (or tensor ) form to dense vector. Sure, we will consider updating it to recover also in the MPS format. |
This is due to setting every possible computation setting to False. In order to use the quimb backend's dense vector function, MPS_enabled must be True since the function uses mps_opts for its calculation. I've proposed a PR to add a note for the user in the doc to let them know that this would be an invalid configuration for computation settings #57 Additionally, error handling can be introduced under quimb.py as follows: mps_enabled_value = runcard.get("MPS_enabled") |
@NithyasriVS , error encountered by you was due to the computation setting written after set backend. There is no issue when everything is false, I have tried it for the issue mentioned by @renatomello. This was the fix I proposed for the earlier issue. I don't think this statement is true "In order to use the quimb backend's dense vector function, MPS_enabled must be True since the function uses mps_opts for its calculation." |
Irrespective of the programmatical working, I feel my point about the configuration is still valid as setting all computation settings to False may not be a meaningful way to use qibotn as the user no longer knows what their output is a computation of, especially as more features/computations get added to the QuimbBackend in the future. So, it could be useful to restrict the user from wanting to use the configuration where are settings are False. |
I tried to run the example inside the
doc
file of this repo and got this errorMoreover, adding a two-qubit gate leads to this error
The text was updated successfully, but these errors were encountered: