str/repr blows up for large disjoint states #4477
Labels
area/simulation
kind/bug-report
Something doesn't seem to work.
needs agreed design
We want to do this, but it needs an agreed upon design before implementation
priority/p1-urgent
Fix is needed as soon as possible. Should be staffed. It is blocking some major flows for users
triage/accepted
there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Description of the issue
The repr and str functions of TrialResult and subclasses all compute the full state of the system as a kron of all disjoint states before displaying. In large disjoint states, this causes the system to hang. This can crop up in unusual places like assertions and stack traces. See #4360 (comment).
How to reproduce the issue
In the
density_matrix_simulator_test::test_large_untangled_okay
unit test, change the number of qubits to mismatch. The simulation works fine, but the test then hangs atassert set(result._final_step_result.qubits) == set(cirq.LineQubit.range(59))
, because it tries to calculate the repr ofresult
to display. This led to users thinking that the simulation itself was hanging, which was not the case.I propose we update these to display the individual state spaces and associated qubits, rather than joining into a single space prior to output.
The text was updated successfully, but these errors were encountered: