qiskit-aer
qiskit-aer copied to clipboard
encounter ERROR on LinuxONE Linux: Failed to load qobj: "unitary" matrix is not unitary.
Informations
- Qiskit Experiments version: qiskit 0.34.2
- Python version: 3.8.8
- Operating system: LinuxONE Linux (s390x), RedHat 8.4
What is the current behavior?
When I'm trying to run quantum volume measurement(https://github.com/Qiskit/qiskit-experiments/blob/main/docs/tutorials/quantum_volume.ipynb) on the LinuxONE Linux, I encountered following error :

QiskitError Traceback (most recent call last)
/tmp/ipykernel_2232758/2280933431.py in <module>
7
8 # Run experiment
----> 9 expdata = qv_exp.run(backend).block_for_results()
~/anaconda3/envs/qiskit/lib/python3.8/site-packages/qiskit_experiments/framework/base_experiment.py in run(self, backend, analysis, experiment_data, **run_options)
126 transpile_opts = copy.copy(self.transpile_options.__dict__)
127 transpile_opts["initial_layout"] = list(self._physical_qubits)
--> 128 circuits = transpile(self.circuits(backend), backend, **transpile_opts)
129 self._postprocess_transpiled_circuits(circuits, backend, **run_options)
130
~/anaconda3/envs/qiskit/lib/python3.8/site-packages/qiskit_experiments/library/quantum_volume/qv_experiment.py in circuits(self, backend)
165 "trial": trial,
166 "qubits": self.physical_qubits,
--> 167 "ideal_probabilities": self._get_ideal_data(qv_circ),
168 }
169 circuits.append(qv_circ)
~/anaconda3/envs/qiskit/lib/python3.8/site-packages/qiskit_experiments/library/quantum_volume/qv_experiment.py in _get_ideal_data(self, circuit, **run_options)
144
145 ideal_result = self._simulation_backend.run(ideal_circuit, **run_options).result()
--> 146 probabilities = ideal_result.data().get("probabilities")
147 else:
148 from qiskit.quantum_info import Statevector
~/anaconda3/envs/qiskit/lib/python3.8/site-packages/qiskit/result/result.py in data(self, experiment)
196 """
197 try:
--> 198 return self._get_experiment(experiment).data.to_dict()
199 except (KeyError, TypeError) as ex:
200 raise QiskitError(f'No data for experiment "{repr(experiment)}"') from ex
~/anaconda3/envs/qiskit/lib/python3.8/site-packages/qiskit/result/result.py in _get_experiment(self, key)
366 if key is None:
367 if len(self.results) != 1:
--> 368 raise QiskitError(
369 "You have to select a circuit or schedule when there is more than one available"
370 )
QiskitError: 'You have to select a circuit or schedule when there is more than one available'
Not sure whether it is a qiskit-experiment issue or qiskit-Aer issue as I do noticed that the error was reported from https://github.com/Qiskit/qiskit-aer/blob/main/src/framework/operations.hpp#L1002
Steps to reproduce the problem
Run the notebook https://github.com/Qiskit/qiskit-experiments/blob/main/docs/tutorials/quantum_volume.ipynb on LinuxONE Linux.
What is the expected behavior?
The measurement can be successfully performed.
Suggested solutions
I took a look at this while testing the output of https://github.com/Qiskit/qiskit-aer/pull/1504. I'm pretty sure this is an aer bug around running on big endian platforms (which in practice s390x linux is probably the only one). Probably specifically around around https://github.com/Qiskit/qiskit-aer/blob/main/src/framework/pybind_json.hpp#L241 and https://github.com/Qiskit/qiskit-aer/blob/main/src/framework/pybind_json.hpp#L143-L165 I think aer is interpreting the endianess of the input unitary 2d array from the circuit/qobj incorrectly and that's causing it to fail it's internal is_unitary() function. You can easily reproduce this same error without qiskit-experiments using:
from qiskit import Aer
from qiskit.quantum_info import random_unitary
from qiskit.circuit import QuantumCircuit
backend = Aer.get_backend("aer_simulator")
qc = QuantumCircuit(2)
qc.unitary(random_unitary(4), [0, 1])
qc.measure_all()
backend.run(qc)
Please open a new issue if the above workaround doesn't work.