# Cirq: How to change atol in validate_density_matrix when using DensityMatrixSimulator

I have a code that essentially looks like this

# Density matrix simulator
sim = cirq.DensityMatrixSimulator(
split_untangled_states=True
)

# Simulate
result = sim.simulate(
circuit,
resolver,
initial_state=rho,
qubit_order=cirq.LineQubit.range(num_q)
)


My initial state rho is a density matrix. However, cirq.validate_density_matrix(rho) raises value error "The density matrix is not positive semidefinite.", but changing the default value of atol from 1e-7 to 1e-6 removes this value error. Therefore I would like to tell DensityMatrixSimulator to use atol of 1e-6 when simulating the circuit. How can I do that?

• A quick glance indicates there's no way to do it at the moment. I'd recommend opening an issue to get it fixed github.com/quantumlib/Cirq/issues . As a workaround in the meantime you could write a method to numerically project your density matrix closer to the valid subspace. Feb 7 at 10:59