You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using qibojit as backend, the initial state is typically modified in-place. This generally works for simple gates and with density matrices. However, ResetChannel does not seem to modify the initial density matrix in-place, as the following example shows. Is this the intended behaviour?
importnumpyasnpimportqibofromqiboimportgatesfromqibo.modelsimportCircuitqibo.set_backend("qibojit", platform="numba")
circuit1=Circuit(2, density_matrix=True)
circuit2=Circuit(2, density_matrix=True)
# Create a simple circuitcircuit1.add(gates.H(0))
circuit1.add(gates.CNOT(0, 1))
# Create a second circuit that differs from the first only with a ResetChannelcircuit2.add(gates.H(0))
circuit2.add(gates.CNOT(0, 1))
circuit2.add(gates.ResetChannel(1, [1.0, 0.0])) # The only difference# Create two 4 x 4 identical density matricesinitial_state1=np.array(
[[0.5, 1, 0, 1], [1, 0.5, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0]], dtype=np.complex128
)
initial_state2=np.copy(initial_state1)
# Now execute the two circuitsfinal_state1=circuit1(initial_state1)
final_state2=circuit2(initial_state2)
# The intended behavior is that the initial states are modified in place (?)# As such, the initial states should be close to the corresponding final states# Test for closeness of the corresponding statesassertnp.allclose(final_state1.state(), initial_state1, atol=1e-6) # This passesassertnp.allclose(initial_state2, initial_state1, atol=1e-6) # This passes when it shouldn'tassertnp.allclose(final_state2.state(), initial_state2, atol=1e-6) # This fails
The text was updated successfully, but these errors were encountered:
When using qibojit as backend, the initial state is typically modified in-place. This generally works for simple gates and with density matrices. However, ResetChannel does not seem to modify the initial density matrix in-place, as the following example shows. Is this the intended behaviour?
The text was updated successfully, but these errors were encountered: