The default dtype of np.complex64 for the DensityMatrixSimulator is not precise enough for relatively small circuits. #6551
Labels
kind/bug-report
Something doesn't seem to work.
triage/accepted
there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Description of the issue
How to reproduce the issue
Use the example circuit:
example-circuit.json
Now, if we change the dtype to np.complex128, the error goes away.
Suggested solution: set the default value of dtype to np.complex128 or np.complex256
1018 raise ValueError(f'Density matrix does not have trace 1. Instead, it has trace {trace}.')
1019 if not np.all(np.linalg.eigvalsh(density_matrix) > -atol):
-> 1020 raise ValueError('The density matrix is not positive semidefinite.')
ValueError: The density matrix is not positive semidefinite.
Cirq version
1.3.0
The text was updated successfully, but these errors were encountered: