qiboteam / qibo

A framework for quantum computing
https://qibo.science
Apache License 2.0
287 stars 58 forks source link

Error when calculating samples with `clifford` backend #1453

Closed AlejandroSopena closed 1 week ago

AlejandroSopena commented 1 week ago

When calculating the samples of an 8-qubit Clifford circuit with the clifford backend, I get the error:

IndexError: index 9 is out of bounds for axis 1 with size 9

I have confirmed that this also happens when generating a random Clifford circuit with a number of qubits proportional to 8. In other cases, it works fine.

The error can be reproduced using:

import qibo
from qibo import gates
from qibo.quantum_info import random_clifford

qibo.set_backend('numpy')

nshots = 10
circ = random_clifford(8)
circ.add(gates.M(0,1))
backend = qibo.backends.CliffordBackend()
result = backend.execute_circuit(circ,nshots=nshots)
result.samples()
BrunoLiegiBastonLiegi commented 1 week ago

Thanks for reporting this, indeed there is a bug in the unpacking process of the symplectic matrix. I will open a PR with the fix soon.