-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Tweak DM normalization after factor #5922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -717,6 +717,11 @@ def factor_density_matrix( | |||
t2 = transpose_density_matrix_to_axis_order(t1, product_axes) | |||
if not np.allclose(t2, t, atol=atol): | |||
raise ValueError('The tensor cannot be factored by the requested axes') | |||
# Tweak trace back to 1 to avoid rounding error propagation | |||
extracted_dim = int(np.sqrt(np.prod(extracted.shape))) | |||
extracted /= np.trace(extracted.reshape((extracted_dim, extracted_dim))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question: should this go into partial_trace
instead? Since it appears that partial_trace
is the root cause of the rounding error.
I'm closing this because I think the right thing to do here is to do this in Of course fixing this in |
As reported in #5916, when repeatedly factoring and kronning a density matrix during simulation, the rounding error caused by partial_trace can propagate and explode after about 15 repetitions. This PR explicitly re-normalizes the density matrix after factoring.
Fixes #5916